aboutsummaryrefslogtreecommitdiffstats
path: root/src/12
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-04-07 16:16:42 -0400
committerLouis Burda <quent.burda@gmail.com>2023-04-07 16:16:42 -0400
commit277e5d08e28b5fcab8b019f66211883d976efbad (patch)
treeb1e8ae3ae602edb98236ea79676f913d0328c798 /src/12
parent73b29dfa9d07c37e8d4db2136cd73fdd9f0650b8 (diff)
downloadaoc2018-python-277e5d08e28b5fcab8b019f66211883d976efbad.tar.gz
aoc2018-python-277e5d08e28b5fcab8b019f66211883d976efbad.zip
Add helper to check solutions and reorder to new layout
Diffstat (limited to 'src/12')
-rw-r--r--src/12/input.txt34
-rw-r--r--src/12/solve.py61
2 files changed, 0 insertions, 95 deletions
diff --git a/src/12/input.txt b/src/12/input.txt
deleted file mode 100644
index 6dcf208..0000000
--- a/src/12/input.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-initial state: ##..#.#.#..##..#..##..##..#.#....#.....##.#########...#.#..#..#....#.###.###....#..........###.#.#..
-
-..##. => .
-..... => .
-##..# => .
-...#. => .
-#.... => .
-...## => #
-.#.#. => .
-#..#. => #
-##.#. => .
-#..## => .
-..#.. => .
-#.#.# => .
-###.# => .
-###.. => .
-.#... => #
-.##.# => .
-##... => #
-..### => .
-####. => .
-#...# => #
-.#..# => #
-##### => #
-..#.# => #
-.#.## => #
-#.### => .
-....# => .
-.###. => .
-.#### => #
-.##.. => .
-##.## => #
-#.##. => #
-#.#.. => #
diff --git a/src/12/solve.py b/src/12/solve.py
deleted file mode 100644
index 8c4784c..0000000
--- a/src/12/solve.py
+++ /dev/null
@@ -1,61 +0,0 @@
-from sys import argv as args
-
-lines = open("input.txt").read().split("\n")
-istate = lines[0].split(": ")[1]
-rules = [l.split(" => ") for l in lines[2:] if l != ""]
-rules = [r[0] for r in rules if r[1] == "#"]
-
-def nextGen(pots):
- pmin = min(pots)
- pmax = max(pots)
- npots = list()
- for i in range(pmin-4, pmax+1):
- for r in rules:
- match = True
- for j in range(5):
- if (r[j] == "#") != ((i+j) in pots):
- match = False
- break
- if match:
- npots.append(i+2)
- break
- return npots
-
-def getPots():
- pots = list()
- for i in range(len(istate)):
- if istate[i] == "#":
- pots.append(i)
- return pots
-
-def solve1():
- pots = getPots()
- for i in range(20):
- pots = nextGen(pots)
- print(sum(pots))
- return
-
-def solve2():
- pots = getPots()
- psum = sum(pots)
- pdif = None
- i = 0
- while (True):
- pots = nextGen(pots)
- i += 1
- csum = sum(pots)
- if pdif == csum - psum:
- print(csum + pdif * (50000000000 - 164))
- break
- pdif = csum - psum
- psum = csum
- return
-
-def main():
- if len(args) > 1:
- if args[1] == "1":
- solve1()
- elif args[1] == "2":
- solve2()
-
-main()