From 79b1af8368c6da961040e1a9368e4845e5182d7f Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 20 Jan 2024 18:06:19 +0100 Subject: add cards containing all numbers with a certain bit set Those cards can be used to perform a magic tick guessing a number between 1 and 79. --- Info/Binaersystem/Makefile | 11 +++++++++++ Info/Binaersystem/cards.pdf | Bin 0 -> 12043 bytes Info/Binaersystem/cards.tex | 37 +++++++++++++++++++++++++++++++++++++ Info/Binaersystem/gen_cards.py | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 Info/Binaersystem/Makefile create mode 100644 Info/Binaersystem/cards.pdf create mode 100644 Info/Binaersystem/cards.tex create mode 100755 Info/Binaersystem/gen_cards.py diff --git a/Info/Binaersystem/Makefile b/Info/Binaersystem/Makefile new file mode 100644 index 00000000..6afb7d27 --- /dev/null +++ b/Info/Binaersystem/Makefile @@ -0,0 +1,11 @@ +CARDS_TEX:=cards.tex +CARDS_PDFS:=$(CARDS_TEX:.tex=.pdf) + +.PHONY: all +all: $(CARDS_PDFS) + +$(CARDS_TEX): gen_cards.py + ./gen_cards.py + +COMMON_MK = $(shell bash -c 'upfind() { [[ -f "$$1" ]] && printf "$$1" || ([ "$$(realpath $$(dirname "$$1"))" == "/" ] || upfind "../$$1") }; upfind common.mk') +include $(COMMON_MK) diff --git a/Info/Binaersystem/cards.pdf b/Info/Binaersystem/cards.pdf new file mode 100644 index 00000000..3bb21f75 Binary files /dev/null and b/Info/Binaersystem/cards.pdf differ diff --git a/Info/Binaersystem/cards.tex b/Info/Binaersystem/cards.tex new file mode 100644 index 00000000..14c59eb5 --- /dev/null +++ b/Info/Binaersystem/cards.tex @@ -0,0 +1,37 @@ +\documentclass[landscape]{article} +\usepackage[margin=2cm]{geometry} +\setlength\parindent{0pt} +\usepackage{tikz} +\usepackage{varwidth} +\tikzstyle{card} = [align=center, minimum width=12cm, minimum height=8cm, rounded corners, draw=gray!50!black, line width=2pt] +\begin{document} +\pagestyle{empty} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51 54 55 58 59 62 63 66 67 70 71 74 75 78 79 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60 61 62 63 68 69 70 71 76 77 78 79 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 40 41 42 43 44 45 46 47 56 57 58 59 60 61 62 63 72 73 74 75 76 77 78 79 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 \end{varwidth}}; +\end{tikzpicture} +\begin{tikzpicture} +\node[card] + {\begin{varwidth}{9cm}\huge 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 \end{varwidth}}; +\end{tikzpicture} +\end{document} diff --git a/Info/Binaersystem/gen_cards.py b/Info/Binaersystem/gen_cards.py new file mode 100755 index 00000000..e8fd58ed --- /dev/null +++ b/Info/Binaersystem/gen_cards.py @@ -0,0 +1,36 @@ +#!/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(f'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() -- cgit v1.2.3