Taddeus Kroes 1 rok temu
rodzic
commit
3e57a679cf
2 zmienionych plików z 16 dodań i 0 usunięć
  1. 16 0
      2024/19_towels.py
  2. 0 0
      2024/input/19

+ 16 - 0
2024/19_towels.py

@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+import sys
+from functools import cache
+
+@cache
+def possible(design, towels):
+    if not design:
+        return 1
+    return sum(possible(design[len(towel):], towels)
+               for towel in towels if design.startswith(towel))
+
+towels = tuple(sys.stdin.readline().rstrip().split(', '))
+designs = sys.stdin.read().split()
+pos = [possible(design, towels) for design in designs]
+print(sum(map(bool, pos)))
+print(sum(pos))

Plik diff jest za duży
+ 0 - 0
2024/input/19


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików