123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- # -------
- # imports
- # -------
- from string import ascii_letters
-
- # ---------
- # constants
- # ---------
-
- DEBUG=True
- HEADER_LEN = 4
-
- # ----------------
- # helper functions
- # ----------------
-
- def debug(*args):
- if DEBUG:
- print(args)
-
- # -------------
- # main function
- # -------------
-
- def main():
- with open("input6.txt", "r") as file:
- intext = file.read()
-
- inlen = len(intext)
-
- for i in range(inlen):
- lets = []
- for j in range(HEADER_LEN):
- clet = intext[i+j]
- lets.append(clet)
-
- if len(set(lets)) != HEADER_LEN:
- print(f"Non-unique: {''.join(lets)} in {i+1}-{i+HEADER_LEN}")
- else:
- print(f"Unique! {''.join(lets)} in {i+1}-{i+HEADER_LEN}")
- break
-
- # --------------
- # run the script
- # --------------
-
- if __name__ == "__main__":
- main()
|