◂ 5 décembre 2015 ▸
Doesn't He Have Intern-Elves For This? :
- code.sh
- code.py
- codeOneLiners.py
- differencesOneLiners.diffy
- temps.txt
f = open('input.txt', 'r') f = open('input.txt', 'r')
linesOrig = list(map(str.strip, f.readlines())) linesOrig = list(map(str.strip, f.readlines()))
def deuxLettresIdentiquesALaSuite(s): def deuxLettresIdentiquesALaSuite(s):
return any(map(lambda i:s[i]==s[i+1], range(len(s)-1))) | for i in range(len(s) - 1):
> if s[i] == s[i+1]:
> return True
> return False
def pasCertainsDigraphes(s): def pasCertainsDigraphes(s):
return not any(map(lambda pattern:pattern in s, ['ab', 'c | for pattern in ['ab', 'cd', 'pq', 'xy']:
> if pattern in s:
> return False
> return True
def troisVoyelles(s): def troisVoyelles(s):
return len(list(filter(lambda x: x in 'aeiou', s))) >= 3 | nb = 0
# return sum(map(lambda x: x in 'aeiou', s)) >= 3 | for car in s:
> if car in 'aeiou':
> nb += 1
> if nb == 3:
> return True
> return False
def deuxLettresIdentiquesPresqueALaSuite(s): def deuxLettresIdentiquesPresqueALaSuite(s):
return any(map(lambda i:s[i]==s[i+2], range(len(s)-2))) | for i in range(len(s) - 2):
> if s[i] == s[i+2]:
> return True
> return False
def groupeDeuxLettresRepete(s): def groupeDeuxLettresRepete(s):
return any(map(lambda i:s[i:i+2] in s[i+2:], range(len(s) | for i in range(len(s) - 3):
> if s[i:i+2] in s[i+2:]:
> return True
> return False
lines = linesOrig[:] lines = linesOrig[:]
for func in [deuxLettresIdentiquesALaSuite, pasCertainsDigrap for func in [deuxLettresIdentiquesALaSuite, pasCertainsDigrap
lines = filter(func, lines) lines = filter(func, lines)
print(len(list(lines))) print(len(list(lines)))
lines = linesOrig[:] lines = linesOrig[:]
for func in [deuxLettresIdentiquesPresqueALaSuite, groupeDeux for func in [deuxLettresIdentiquesPresqueALaSuite, groupeDeux
lines = filter(func, lines) lines = filter(func, lines)
print(len(list(lines))) print(len(list(lines)))