瀏覽代碼

Solve day 6

Taddeus Kroes 3 年之前
父節點
當前提交
6dc283f250
共有 2 個文件被更改,包括 15 次插入0 次删除
  1. 15 0
      2022/06_packets.py
  2. 0 0
      2022/input/6

+ 15 - 0
2022/06_packets.py

@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+import sys
+from collections import Counter, deque
+
+def marker(stream, winlen):
+    window = deque(stream[:winlen - 1])
+    for i, char in enumerate(stream[winlen - 1:]):
+        if char not in window and len(Counter(window)) == winlen - 1:
+            return i + winlen
+        window.popleft()
+        window.append(char)
+
+stream = sys.stdin.readline().rstrip()
+print(marker(stream, 4))
+print(marker(stream, 14))

文件差異過大導致無法顯示
+ 0 - 0
2022/input/6


部分文件因文件數量過多而無法顯示