Last active
May 24, 2018 02:36
-
-
Save seven0525/e11fe2315281fb6691552bf076652732 to your computer and use it in GitHub Desktop.
「自作Python100本ノック」5日目(Googleサマーインターン選考問題受けてみた:20本〜25本目) ref: https://qiita.com/ahpjop/items/0dffbfbae7609329c5ca
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cal_patern(a,b,c,x): | |
count = 0 | |
for i in range(a + 1): | |
for j in range(b + 1): | |
for k in range(c + 1): | |
if 500 * i + 100 * j + 50 * k == x: | |
count += 1 | |
return count | |
cal_patern(3,5,6,1500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pocket(aim): | |
count = 0 | |
biskets = 1 | |
while biskets < aim: | |
count += 1 | |
biskets = 2 ** count | |
else: | |
print("{}回ポケットを叩いてください".format(count)) | |
pocket(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_pass(password): | |
if len(password) >= 10 and not password.isalpha() and not password.isnumeric() and not password.islower() and not password.isupper(): | |
return True | |
else: | |
return False | |
print(check_pass("aiasgiHSU43")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
def find_frequent_word(text): | |
text = text.lower() | |
return max(string.ascii_lowercase, key=text.count) | |
a = find_frequent_word("aiasfiah faihasjn8348 y5iHsuasHuUUUUUuuuurbuurugjsghfoas") | |
print(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def long_repeat(line): | |
if line=='': | |
return(0) | |
else: | |
count=1 | |
count_chr=[1] | |
for i in range(1,len(line)): | |
if line[i-1]==line[i]: | |
count +=1 | |
else: | |
count = 1 | |
count_chr.append(count) | |
return max(count_chr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def long_repeat(line): | |
count = 1 | |
maxi = 1 | |
if line != "": | |
for i in range(1,len(line)): | |
if line[i] == line[i-1]: | |
count+=1 | |
if count > maxi: | |
maxi = count | |
else: | |
count = 1 | |
return maxi | |
else: | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment