(indata: str)
| 2 | |
| 3 | @aoc.main('14') |
| 4 | def 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 | |
| 19 | if __name__ == "__main__": |
| 20 | main() |