Skip to content

Commit

Permalink
Merge pull request #183 from Stegallo/2015
Browse files Browse the repository at this point in the history
simplify day5
  • Loading branch information
Stegallo authored Nov 6, 2023
2 parents 299f2df + 198ad30 commit ca715c7
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions y_2015/day5.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ def nice(self) -> bool:

def __has_pair_twice(self) -> bool:
twice_pair = False
for c in range(len(self.text) - 2):
for j in range(c + 2, len(self.text) - 1):
if self.text[c : c + 2] == self.text[j : j + 2]:
len_text = len(self.text)
for i in range(len_text - 2):
for j in range(i + 2, len_text - 1):
if self.text[i : i + 2] == self.text[j : j + 2]:
twice_pair = True
break
return bool(twice_pair)

def __has_letter_repeats_with_one_between(self) -> bool:
letter_repeat = False
for c, i in enumerate(self.text):
if c >= len(self.text) - 2:
break
if self.text[c] == self.text[c + 2]:
letter_repeat = True
break
return bool(letter_repeat)
return any(self.text[i] == self.text[i + 2] for i in range(len(self.text) - 2))

@property
def correct_nice(self) -> bool:
Expand Down

0 comments on commit ca715c7

Please sign in to comment.