summaryrefslogtreecommitdiffstats
path: root/4gen.py
blob: bc54c17fa080faa75926b797c0cfca0235eee4ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from math import log10, ceil
from random import shuffle, sample

BOARD_SIDE = 15
BOARD_COUNT = BOARD_SIDE * BOARD_SIDE * 4
NUMS = BOARD_COUNT

nums = list(range(NUMS))
shuffle(nums)

print(','.join(str(n) for n in nums))
print()

align = ceil(log10(NUMS))

boards = []
for b in range(BOARD_COUNT):
    bnums = sample(nums, BOARD_SIDE * BOARD_SIDE)
    rows = []
    for y in range(BOARD_SIDE):
        row = []
        for x in range(BOARD_SIDE):
            n = bnums.pop()
            row.append(f'{n:>{align}}')
        rows.append(' '.join(str(n) for n in row))
    boards.append('\n'.join(rows))

print('\n\n'.join(boards))