first commit
This commit is contained in:
commit
31bda4481f
37 changed files with 4645 additions and 0 deletions
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))
|
Loading…
Add table
Add a link
Reference in a new issue