def get_bits(number):
    bits = 0
    while 2 ** bits < number:
        bits += 1
    return bits


ms_per_year = 366 * 24 * 60 * 60 * 1000
ms_per_year_bits = get_bits(ms_per_year)

sn = int('9' * 17)
sn_bits = get_bits(sn)

min_amount = int('9' * 5)
min_amount_bits = get_bits(min_amount)

target_bytes = 15
target_bits = target_bytes * 8
print(f'Target bytes: {target_bytes} ({target_bits} bits)')

for years_bits in range(6, 12):
    years = 2 ** years_bits

    total_ms = ms_per_year * years
    total_ms_bits = get_bits(total_ms)

    bits_wo_amount = years_bits + ms_per_year_bits + sn_bits

    amount_bits = target_bits - bits_wo_amount
    amount = 2 ** amount_bits

    free_bits = amount_bits - min_amount_bits

    # let's check, if there will be difference in storing
    # year and the rest of the date/time together or separately
    # spoiler: no difference
    total_bits_separately = years_bits + ms_per_year_bits + sn_bits + amount_bits
    total_bits_together = total_ms_bits + sn_bits + amount_bits

    print(f'Years: {years}')
    if total_bits_separately == total_bits_together:
        print(f'  Total bits: {total_bits_separately}')
    else:
        print(f'  Total bits (years and date/time separately): {total_bits_separately}')
        print(f'  Total bits (years and date/time together): {total_bits_together}')
    print(f'  Max amount: £{amount / 100} ({amount_bits} bits, {free_bits} free bits used)')
