Advent of Code 2022 https://adventofcode.com/2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -------
  2. # imports
  3. # -------
  4. from string import ascii_letters
  5. # ---------
  6. # constants
  7. # ---------
  8. DEBUG=True
  9. # ----------------
  10. # helper functions
  11. # ----------------
  12. def debug(*args):
  13. if DEBUG:
  14. print(args)
  15. # -------------
  16. # main function
  17. # -------------
  18. def main():
  19. with open("input6.txt", "r") as file:
  20. intext = file.read()
  21. inlen = len(intext)
  22. for i in range(inlen):
  23. lets = []
  24. for j in range(14):
  25. clet = intext[i+j]
  26. lets.append(clet)
  27. if len(set(lets)) != 14:
  28. print(f"Non-unique: {''.join(lets)} in {i+1}-{i+14}")
  29. else:
  30. print(f"Unique! {''.join(lets)} in {i+1}-{i+14}")
  31. break
  32. # --------------
  33. # run the script
  34. # --------------
  35. if __name__ == "__main__":
  36. main()