#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#puzzle_input = "125 17" #example 6x blink=22 Stones / 25x blink = 55312
puzzle_input = "112 1110 163902 0 7656027 83039 9 74"
x_blink = 25

from time import time

start_time = time()
def str_list_to_int_list(str_list:list[str]) ->list[int]:
    result = []
    for part in str_list:
        result.append(int(part))
    return result

def split_integer(num):
    length = len(str(num))
    divisor = 10 ** (length // 2)
    left = num // divisor
    right = num % divisor
    return left, right


def blink(int_list:list[int]) -> list[int]:
    result = []
    for part in int_list:
        if part == 0:
            result.append(1)
        elif len(str(part)) % 2 == 0:
            result.extend(split_integer(part))
        else:
            result.append(part * 2024)
    return result


if __name__ == "__main__":
    puzzle = puzzle_input.split()
    puzzle = str_list_to_int_list(puzzle)
    for x in range(x_blink):
        print(x+1)
        puzzle = blink(puzzle)
    #print(puzzle)
    print(f'input: {puzzle_input} and {x_blink} blinks -> {len(puzzle)} stones')
    print(f'Runtime: {time()-start_time:.2f} s')