aboutsummaryrefslogtreecommitdiffstats
path: root/src/14
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/14
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/14')
-rw-r--r--src/14/input.txt1
-rw-r--r--src/14/solve.py42
2 files changed, 0 insertions, 43 deletions
diff --git a/src/14/input.txt b/src/14/input.txt
deleted file mode 100644
index 1c93252..0000000
--- a/src/14/input.txt
+++ /dev/null
@@ -1 +0,0 @@
-110201
diff --git a/src/14/solve.py b/src/14/solve.py
deleted file mode 100644
index fd6488c..0000000
--- a/src/14/solve.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from sys import argv as args
-
-inputstr = open("input.txt").read().replace("\n","")
-recipes = [3,7]
-
-def solve1():
- global recipes, inputstr
-
- end = int(inputstr)
- workers = [i for i in range(2)]
- while len(recipes) < end + 10:
- recipes += [int(c) for c in str(sum(recipes[workers[i]] for i in range(len(workers))))]
- for i in range(len(workers)):
- workers[i] = (workers[i] + recipes[workers[i]]+1) % len(recipes)
- print("".join([str(x) for x in recipes[end:]]))
-
-def solve2():
- global recipes, inputstr
-
- ilen = len(inputstr)
- inputstr = [int(c) for c in inputstr]
- workers = [i for i in range(2)]
- stop = False
- counter = 0
- while not stop:
- for v in [int(c) for c in str(sum(recipes[workers[i]] for i in range(len(workers))))]:
- if recipes[-ilen:] == inputstr:
- stop = True
- break
- recipes.append(v)
- for i in range(len(workers)):
- workers[i] = (workers[i] + recipes[workers[i]]+1) % len(recipes)
- print(len(recipes)-ilen)
-
-def main():
- if len(args) > 1:
- if args[1] == "1":
- solve1()
- elif args[1] == "2":
- solve2()
-
-main()