Skip to content

Instantly share code, notes, and snippets.

@seven0525
Last active May 24, 2018 02:36
Show Gist options
  • Save seven0525/e11fe2315281fb6691552bf076652732 to your computer and use it in GitHub Desktop.
Save seven0525/e11fe2315281fb6691552bf076652732 to your computer and use it in GitHub Desktop.
「自作Python100本ノック」5日目(Googleサマーインターン選考問題受けてみた:20本〜25本目) ref: https://qiita.com/ahpjop/items/0dffbfbae7609329c5ca
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)
def pocket(aim):
count = 0
biskets = 1
while biskets < aim:
count += 1
biskets = 2 ** count
else:
print("{}回ポケットを叩いてください".format(count))
pocket(10)
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"))
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)
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)
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