44 lines
937 B
Python
44 lines
937 B
Python
from sys import argv, exit
|
|
|
|
try:
|
|
input_ = int(argv[1])
|
|
except IndexError:
|
|
print(f"Usage: {argv[0]} [input]")
|
|
exit(1)
|
|
|
|
recipes = [3, 7]
|
|
a, b = 0, 1
|
|
|
|
def print_recipes():
|
|
for i, recipe in enumerate(recipes):
|
|
if i == a:
|
|
print(f"({recipe:>2d})", end=" ")
|
|
elif i == b:
|
|
print(f"[{recipe:>2d}]", end=" ")
|
|
else:
|
|
print(f" {recipe:>2d} ", end=" ")
|
|
print()
|
|
|
|
target = None
|
|
i = 0
|
|
while len(recipes) < input_ + 10:
|
|
# print_recipes()
|
|
next_ = recipes[a] + recipes[b]
|
|
|
|
digits = []
|
|
if next_ == 0:
|
|
digits.append(0)
|
|
else:
|
|
while next_:
|
|
digits.append(next_ % 10)
|
|
next_ //= 10
|
|
|
|
recipes.extend(digits[::-1])
|
|
|
|
a = (a + recipes[a] + 1) % len(recipes)
|
|
b = (b + recipes[b] + 1) % len(recipes)
|
|
|
|
# print_recipes()
|
|
output = recipes[input_:input_ + 10]
|
|
assert len(output) == 10
|
|
print("".join(str(x) for x in output))
|