MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / main

Function main

2018/src/14.py:4–17  ·  view source on GitHub ↗
(indata: str)

Source from the content-addressed store, hash-verified

2
3@aoc.main('14')
4def main(indata: str):
5 r = int(indata)
6 res = [int(c) for c in str(r)]
7 e1,e2,recipes = 0,1,[3,7]
8 while recipes[-len(res):] != res:
9 x = recipes[e1] + recipes[e2]
10 if x > 9:
11 recipes.append(1)
12 if recipes[-len(res):] == res:
13 break
14 recipes.append(x % 10)
15 e1 = (e1 + recipes[e1] + 1) % len(recipes)
16 e2 = (e2 + recipes[e2] + 1) % len(recipes)
17 return ''.join(str(i) for i in recipes[r:r+10]),len(recipes) - len(res)
18
19if __name__ == "__main__":
20 main()

Callers 1

14.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected