@@ 7,11 7,11 @@
import unittest
-def doit(data):
- assert len(data) >= 4
- for i in range(len(data) - 4):
- if len(frozenset(data[i:i+4])) == 4:
- return i + 4
+def doit(data, n=4):
+ assert len(data) >= n
+ for i in range(len(data) - n):
+ if len(frozenset(data[i:i+n])) == n:
+ return i + n
class SelfTest(unittest.TestCase):
def testDoit(self):
@@ 26,4 26,5 @@ if __name__ == "__main__":
if len(argv) == 1:
unittest.main()
else:
- [print(doit(data)) for data in argv[1:]]
+ [print("Part 1:", doit(data, n=4)) for data in argv[1:]]
+ [print("Part 2:", doit(data, n=14)) for data in argv[1:]]