aboutsummaryrefslogtreecommitdiff
path: root/Info/Binaersystem/gen_cards.py
blob: 01091c1c1332056e9c4a95d580099ad9ff2b4e32 (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
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3

def gen_numbers(end_pos=7, end_number=80) -> list[list[int]]:
    ns = []
    for pos in range(end_pos):
        n = []
        for i in range(end_number):
            if i & (1 << pos):
                n.append(i)
        ns.append(n)
    return ns


def main():
    all = gen_numbers()
    with open('cards.tex', 'w', encoding='utf-8') as card:
        print(r'\documentclass[landscape]{article}', file=card)
        print(r'\usepackage[margin=2cm]{geometry}', file=card)
        print(r'\setlength\parindent{0pt}', file=card)
        print(r'\usepackage{tikz}', file=card)
        print(r'\usepackage{varwidth}', file=card)
        print(r'\tikzstyle{card} = [align=center, minimum width=12cm, minimum height=8cm, rounded corners, draw=gray!50!black, line width=2pt]', file=card)

        print(r'\begin{document}', file=card)
        print(r'\pagestyle{empty}', file=card)
        for i, ns in enumerate(all):
            print(r'\begin{tikzpicture}', file=card)
            s = ''
            for n in ns:
                s += f'{n} '
            print(r'\node[card]', file=card)
            print(rf'  {{\begin{{varwidth}}{{9cm}}\huge {s}\end{{varwidth}}}};', file=card)
            print(r'\end{tikzpicture}', file=card)
        print(r'\end{document}', file=card)


if __name__ == '__main__':
    main()