first commit
This commit is contained in:
commit
31bda4481f
37 changed files with 4645 additions and 0 deletions
5
2015/five/example.input
Normal file
5
2015/five/example.input
Normal file
|
@ -0,0 +1,5 @@
|
|||
jchzalrnumimnmhp
|
||||
aaa
|
||||
haegwjzuvuyypxyu
|
||||
jchzalrnumimnmhp
|
||||
dvszwmarrgswjxmb
|
4
2015/five/exmpl
Normal file
4
2015/five/exmpl
Normal file
|
@ -0,0 +1,4 @@
|
|||
qjhvhtzxzqqjkmpb
|
||||
xxyxx
|
||||
uurcxstgmygtbstg
|
||||
ieodomkazucvgmuy
|
1000
2015/five/input
Normal file
1000
2015/five/input
Normal file
File diff suppressed because it is too large
Load diff
28
2015/five/solution-2.py
Normal file
28
2015/five/solution-2.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
with open("./exmpl", "r") as file:
|
||||
strings = list(file.read().split("\n"))
|
||||
|
||||
niceStrings = []
|
||||
|
||||
#broken af
|
||||
|
||||
for string in strings:
|
||||
lg = 0
|
||||
appeared = False
|
||||
|
||||
for i in range(len(string)-1):
|
||||
group = f"{list(string)[i]}{list(string)[i+1]}"
|
||||
appearances = -1
|
||||
for j in range(len(string)-1):
|
||||
if f"{list(string)[j]}{list(string)[j+1]}" == group:
|
||||
appearances += 1
|
||||
print(f"group {group} found in {string} - number {appearances}")
|
||||
if appearances > 0:
|
||||
if list(string)[j-1] == list(string)[j]:
|
||||
appeared = True
|
||||
for i in range(len(string)-2):
|
||||
if list(string)[i] == list(string)[i+2]:
|
||||
lg += 1
|
||||
if appeared and lg > 0:
|
||||
niceStrings.append(string)
|
||||
|
||||
print(len(niceStrings))
|
28
2015/five/solution.py
Normal file
28
2015/five/solution.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
vowels = ["a","e","i","o","u"]
|
||||
groups = ["ab", "pq", "cd", "xy"]
|
||||
with open("./input", "r") as file:
|
||||
strings = list(file.read().split("\n"))
|
||||
|
||||
niceStrings = []
|
||||
|
||||
for string in strings:
|
||||
n = 0
|
||||
dl = False
|
||||
notContains = True
|
||||
for character in list(string):
|
||||
if character in vowels:
|
||||
n += 1
|
||||
for i in range(len(string)-1):
|
||||
if list(string)[i] == list(string)[i+1]:
|
||||
dl = True
|
||||
break
|
||||
|
||||
for group in groups:
|
||||
if group in string:
|
||||
notContains = False
|
||||
break
|
||||
if n >= 3 and dl and notContains:
|
||||
niceStrings.append(string)
|
||||
print(string, n, dl, notContains)
|
||||
|
||||
print(len(niceStrings))
|
Loading…
Add table
Add a link
Reference in a new issue