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


print("Does not work with only 32 GB of RAM......")


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

MULTIPLY_FACTOR = 2024

from time import time
import numpy as np
from numba import njit

@njit()
def blink(int_array:np.ndarray) -> np.ndarray:
    result = []
    for part in int_array:
        if part == 0:
            result.append(1)
        elif len(str(part)) % 2 == 0:
            left, right = divmod(part, 10**(len(str(part))//2))
            result.extend([left, right])
        else:
            result.append(part * MULTIPLY_FACTOR)
    return np.array(result, dtype=np.int64)

@njit()
def do_x_blinks(x:int, arr:np.ndarray) -> int:
    for i in range(x):
        print(i+1)
        arr = blink(arr)
    return len(arr)


if __name__ == "__main__":
    start_time = time()
    puzzle = np.array([int(x) for x in puzzle_input.split()], dtype=np.int64)
    p_len = do_x_blinks(x_blink, puzzle)
    #print(puzzle)
    print(f'input: {puzzle_input} and {x_blink} blinks -> {p_len} stones')
    print(f'Runtime: {time()-start_time:.2f} s')