Ver Fonte

Solve day 19

Taddeus Kroes há 1 ano atrás
pai
commit
3e57a679cf
2 ficheiros alterados com 16 adições e 0 exclusões
  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))

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
2024/input/19


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff