\pi day riddles for LaTeX users
The best way to represent digits of Pi is, of course, with ducks. :)
E.g, 5 ducks of the same colour denote the digit 5, and so forth. However, this system had to rely on a duck to represent no ducks at all, so I used an American black duck species to act accordingly.
The following code has to be executed with LuaLaTeX, and the digit generator is courtesy of Rosetta Code. Beware, for this code is slow. If you want to specify the number of digits (and ducks), please change the n
variable in the Lua code scope. :)
Update: The algorithm starts with zero. :)
\documentclass[12pt]{article}
\usepackage{tikzducks}
\usepackage{xparse}
\usepackage[margin=1cm]{geometry}
\usepackage{luacode}
\ExplSyntaxOn
\NewDocumentCommand{\ducks}{mm}{
\int_compare:nTF { #1 != 0 }
{ \prg_replicate:nn { #1 } { \tikz[scale=.25]{ \duck[body=#2]; } \hspace{.16667em} } }
{ \tikz[scale=.25]{ \duck[body=black]; } \hspace{.16667em} }
}
\ExplSyntaxOff
\setlength{\parindent}{0pt}
\pagestyle{empty}
\begin{document}
\raggedright
\begin{luacode}
a = {}
n = 1000
cl = false
len = math.modf( 10 * n / 3 )
for j = 1, len do
a[j] = 2
end
nines = 0
predigit = 0
for j = 1, n do
q = 0
for i = len, 1, -1 do
x = 10 * a[i] + q * i
a[i] = math.fmod( x, 2 * i - 1 )
q = math.modf( x / ( 2 * i - 1 ) )
end
a[1] = math.fmod( q, 10 )
q = math.modf( q / 10 )
if q == 9 then
nines = nines + 1
else
if q == 10 then
tex.print('\\ducks{' .. (predigit + 1) .. '}{' ..
(cl and 'light' or '') .. 'gray}')
cl = not cl
for k = 1, nines do
tex.print('\\ducks{1}{black}')
end
predigit = 0
nines = 0
else
tex.print( '\\ducks{' .. predigit .. '}{' ..
(cl and 'light' or '') .. 'gray}' )
cl = not cl
predigit = q
if nines ~= 0 then
for k = 1, nines do
tex.print('\\ducks{9}{' ..
(cl and 'light' or '') .. 'gray}')
cl = not cl
end
nines = 0
end
end
end
end
tex.print( '\\ducks{' .. predigit .. '}{' ..
(cl and 'light' or '') .. 'gray}' )
\end{luacode}
\end{document}
Happy Pi day! Quack! :)
Almost random character generator, compile with XeTeX:
\font\forpi="[FreeSans.otf]"
\forpi
\def\printpi3.{3.\otherpi}
\def\otherpi#1#2#3{%
\iffontchar\font"#1#2
\char"#1#2
\else
\char"1#1#2
\fi
\ifx#3\end\else\expandafter\otherpi\fi#3
}
\printpi
3.
243F
6A88
85A3
08D3
1319
8A2E
0370
7344
A409
3822
299F
31D0
082E
FA98
EC4E
6C89
4528
21E6
38D0
1377
BE54
66CF
34E9
0C6C
C0AC
\end
Exercises.
- Where did all spaces go?
- Why does the code only features a single
%
?
Hexadecimal expansion of π courtesy of http://turner.faculty.swau.edu/mathematics/materialslibrary/pi/pibases.html
EDIT: translations provided for the non-English-speaking native.
Here are 2 simple riddles:
\documentclass{article}
\begin{document}
\noindent
You better watch out,\\
$u\beta \not \pi\dots$\\
Q: Who is coming to town?
\end{document}
Refers to the Christmas verse, "You better watch out, you better not cry, better not pout, I'm telling you why, Santa Claus is coming to town." Here, "u beta not pi" carries the same rhythm as "you better not cry."
\documentclass{article}
\parindent 0pt
\begin{document}
Clue: {3\tiny$\pi\gg$s}\\
Q: Who is the bad guy in this story?
\end{document}
"3 tiny piggs" is making reference to the fairy tale, "The 3 Little Pigs," in which the big bad wolf is the antagonist.
The following are decipher games. Construct the LaTeX code from reading the image.
\documentclass{article}
\begin{document}
The doctor says...$\pi\ss \in a \cup$
\end{document}
Perhaps intended for the older crowd, when asked to provide a urine specimen, the colloquial description is to "piss in a cup."
\documentclass{article}
\parindent0pt
\begin{document}
\def\you{8}
$\if \you 8 a \pi\ll\you'\ll b \fi\ne$,\\
but\\
$\if \you 8 5 \pi\ll{s}\you'\ll \not b \fi\ne$!
\end{document}
"If you [ate] a pill, you'll be fine, but if you [ate] 5 pills, you'll not be fine" is what the code essentially reads as. The LaTeX renditions is, of course, most subtle, as \if...\fi
are tests and not typeset text. It further relies on the macro \you
being set to 8
.
\documentclass{article}
\begin{document}
$a \big(\pi\ll) {\wedge}d \in a \cup$.
\end{document}
Just a stupid line here, "a big pill wedged in a cup" is what the code looks like.
\documentclass{article}
\parindent0pt
\begin{document}
The Mama circle asked her child what time ($t$) is it?\\
The reply: $t = 2 (\mathrm{Go})^{\pi D}$
\end{document}
Knowing t
is time, the math might be phonetically read as "time to go to the pottie (aka bathroom)."