Advertisement
illuminati229

Untitled

Dec 6th, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. def day06(filepath, unique_length):
  2.     with open(filepath) as fin:
  3.         line = fin.readline()
  4.  
  5.     for i in range(len(line)):
  6.         fourset = line[i:i+unique_length]
  7.         if all([fourset.count(line[j]) == 1 for j in range(i, i+unique_length)]):
  8.             return i + unique_length
  9.  
  10.  
  11. def main():
  12.     assert day06('test06', 4) == 7
  13.     print(day06('input06', 4))
  14.  
  15.     assert day06('test06', 14) == 19
  16.     print(day06('input06', 14))
  17.  
  18.  
  19. if __name__ == '__main__':
  20.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement