# Introduction

Hello there, fellow TeX.sx users! I'm organizing a lottery. The idea is very similar to Who Wants to Win a LaTeX Book?, but both the lottery algorithm and the prize are different. Let me explain some things first.

## Who are you?

I'm some random dude on the Internet who happens to hang out a lot in this very community. :)

## What is the prize?

The prize will be a lovely duck.

## Wait a minute, did you say duck?

Yes! :) But not a real duck, it will be a hand puppet duck:

Lovely, isn't it?

## Why a duck? Why not a lion?

Good question. :) I always like to provide examples with ducks when I write answers. To my surprise, the theme got a very positive feedback from the community and it spread to everybody. Of course, a lion would be better, but hey, it's free! And it's a duck! :)

## Why a hand puppet?

I have absolutely no idea. But since I got this duck, I thought it would be a good idea to start a contest! :)

# Rules

• To win the duck you must guess a number in the range 1-200. The first person who guesses the right number gets the duck.
• Contestants may submit 2 valid guesses.
• Contestants must have been a member of TeX.sx before 21 December, 2013.

# The lottery

I'll use the following code to pick the winner:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{expl3}
\usepackage{xparse}

\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed}

\ExplSyntaxOn

\prop_new:N \g_duck_contest_prop
\int_new:N \g_duck_contest_upper_limit_int
\bool_new:N \l_duck_contest_winner_bool
\bool_set_false:N \l_duck_contest_winner_bool
\tl_new:N \l_duck_contest_winner_tl
\int_new:N \l_duck_contest_winning_number_int

\NewDocumentCommand { \person } { m m }
{
\clist_map_inline:nn { #1 }
{
\prop_if_in:NnTF \g_duck_contest_prop { ##1 }
{
Hey! ~ #2 ~ wants ~ to ~ be ~ naughty! ~
The ~ number ~ ##1 ~ was ~ already ~ chosen! \par
}
{
\prop_gput:Nnn \g_duck_contest_prop { ##1 } { #2 }
\int_gset:Nn \g_duck_contest_upper_limit_int
{
\int_max:nn { \g_duck_contest_upper_limit_int } { ##1 }
}
}
}
}

\NewDocumentCommand{ \winner } { }
{
\bool_do_until:Nn \l_duck_contest_winner_bool
{
\pgfmathrandom{1, \g_duck_contest_upper_limit_int}
\prop_get:NoN \g_duck_contest_prop { \pgfmathresult } \l_duck_contest_winner_tl
\quark_if_no_value:NF \l_duck_contest_winner_tl
{
\bool_set_true:N \l_duck_contest_winner_bool
}
}
\int_set_eq:NN \l_duck_contest_winning_number_int \pgfmathresult
\l_duck_contest_winner_tl
}

\cs_generate_variant:Nn \prop_get:NnN { No }

\NewDocumentCommand{ \winningnumber } { }
{
\int_to_arabic:n \l_duck_contest_winning_number_int
}

\ExplSyntaxOff

\begin{document}

% ==============================
% For example, in the following line
% I picked 1 and 27, but I'm not
% participating in the contest :)
% \person{1,27}{Paulo Cereda}

\person{137,143}{Marco Daniel}
\person{65,105}{Ethan Bolker}
\person{68,130}{giordano}
\person{123,77}{Werner}
\person{124,100}{Stiff Jokes}
\person{15,97}{David Carlisle}
\person{22,44}{egreg}
\person{42,37}{tohecz}
\person{108,69}{Count Zero}
\person{47,167}{ppr}
\person{26,2}{marczellm}
\person{3,30}{Papiro}
\person{131,144}{percusse}
\person{33,66}{Harish Kumar}
\person{1,200}{Przemysław Scherwentke}
\person{4,5}{Frank Mittelbach}
\person{23,177}{cgnieder}
\person{11,121}{texenthusiast}
\person{50,52}{Peter LeFanu Lumsdaine}
\person{14,29}{ricmarques}
\person{117,183}{Newb}
\person{82,88}{Francesco Endrici}
\person{122,171}{Claudio Fiandrino}
\person{17,21}{Dror}
\person{153,154}{topskip}
\person{74,147}{Sigur}
\person{193,38}{ComFreek}
\person{113,31}{Wayne Werner}
\person{6,7}{Andrew Stacey}
\person{12,171}{azetina}
\person{8,63}{Ignasi}
\person{28,99}{Andrea L.}
\person{25,116}{Benedikt Bauer}
\person{126,129}{Alan Munn}
\person{99,199}{lvaneesbeeck}
\person{197,53}{Pouya}
\person{20,125}{afrendeiro}
\person{45,152}{kan}
\person{114,115}{Philip}
\person{24,133}{doncherry}
\person{27,35}{Yori}
\person{79,186}{knut}
\person{12,173}{fifaltra}
\person{28,196}{Michael Hoppe}
\person{94,81}{XZS}
\person{10,172}{OSjerick}
\person{56,163}{laxxy}

% there was an entry to the code, but not as
% a proper answer, I'm sorry
% \person{8,9}{Joe Corneli}
% ==============================

% the announcement
The winner is \winner, with \winningnumber! Congratulations!

\end{document}


I'll run this code with all the contestants, post a video of it and announce the winner.

# The date

Hopefully, I'll get the code running on January 1st, 2014, and announce the winner. :)

Good luck! :) And by the way, welcome to TeX.sx, the friendliest and most awesome community in the whole StackExchange network! They give us hats, right? We give ducks!

----------------------------------------------------------------------------------
|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|009|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|016|◖■◗|018|019|◖■◗|
----------------------------------------------------------------------------------
|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|032|◖■◗|034|◖■◗|036|◖■◗|◖■◗|039|040|
----------------------------------------------------------------------------------
|041|◖■◗|043|◖■◗|◖■◗|046|◖■◗|048|049|◖■◗|051|◖■◗|◖■◗|054|055|◖■◗|057|058|059|060|
----------------------------------------------------------------------------------
|061|062|◖■◗|064|◖■◗|◖■◗|067|◖■◗|◖■◗|070|071|072|073|◖■◗|075|076|◖■◗|078|◖■◗|080|
----------------------------------------------------------------------------------
|◖■◗|◖■◗|083|084|085|086|087|◖■◗|089|090|091|092|◖■◗|◖■◗|095|096|◖■◗|098|◖■◗|◖■◗|
----------------------------------------------------------------------------------
|101|102|103|104|◖■◗|106|107|◖■◗|109|110|111|112|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|118|119|120|
----------------------------------------------------------------------------------
|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|◖■◗|127|128|◖■◗|◖■◗|◖■◗|132|◖■◗|134|135|136|◖■◗|138|139|140|
----------------------------------------------------------------------------------
|141|142|◖■◗|◖■◗|145|146|◖■◗|148|149|150|151|◖■◗|◖■◗|◖■◗|155|156|157|158|159|160|
----------------------------------------------------------------------------------
|161|162|◖■◗|164|165|166|◖■◗|168|169|170|◖■◗|◖■◗|◖■◗|174|175|176|◖■◗|178|179|180|
----------------------------------------------------------------------------------
|181|182|◖■◗|184|185|◖■◗|187|188|189|190|191|192|◖■◗|194|195|◖■◗|◖■◗|198|◖■◗|◖■◗|
----------------------------------------------------------------------------------

◖■◗


# Update

Congrats to Dror for picking 17, the winning number! And thanks to all that joined the contest! Happy New Year! Here's the video with me running the code. :)

• Gambling is not good for children. – kiss my armpit Dec 22 '13 at 18:48
• @StiffJokes: maybe it teaches a valuable lesson: do not gamble. Not even once. :) – Paulo Cereda Dec 22 '13 at 18:56
• Nine nine nine nine nine nine. – Qrrbrbirlbel Dec 22 '13 at 23:42
• @Qrrbrbirlbel: LOL if you check some of the previous reviews of the code, you'll see David's optimization, which employs quite the same implementation of Dilbert's. :P – Paulo Cereda Dec 23 '13 at 10:46
• 4 - the IEEE vetted random number (according to XKCD's hovertext) – Wayne Werner Dec 23 '13 at 20:15
• $$\pi$$ – Kartik Dec 27 '13 at 8:02
• 4 numbers per person might be useful to finalize this game much faster. – kiss my armpit Dec 28 '13 at 20:19
• Am I supposed to edit the code above so that I'm in it? Because I can't. Does that mean I can't take part in the lottery? – fifaltra Dec 29 '13 at 0:28
• With no better way to close competitions, 'off-topic' it is: the competition is now closed to new entries, and a winner will be announced (edited in/accepted) soon. – Joseph Wright Dec 31 '13 at 23:01
• Interesting things about the video: (1) You failed to highlight your code from top to bottom so you needed to do it from bottom to top. (2) Sadly, even you did not use arara to compile the code. :-) – kiss my armpit Jan 1 '14 at 23:12
• @JosephWright: How long do we have to wait for closing this question? Or should it be in "on hold" status forever? – kiss my armpit Jan 5 '14 at 19:17
• @StiffJokes The 'on hold' business lasts a week: it's there because there was a feeling that 'closed' was too 'final' in general. It's not something that's selectable for individual questions: closing puts them on hold for one week then they show closed. – Joseph Wright Jan 5 '14 at 22:02

• Number I: 17
• Number II: 21
• Congrats, you won the duck! :) – Paulo Cereda Jan 1 '14 at 2:07
• <blushes>... :) – Dror Jan 1 '14 at 12:14

I missed the previous one by one. As every broke gambler knows, patience is the archenemy of the odds. So here we go;

131; I'm a random number generator myself and this is the result.

Also another generator agrees;

I have generated a new one which is 144.

• Great use of Rain Man there. – Newb Dec 23 '13 at 4:22

Number 1: 68

Number 2: 130

Numbers generated using Emacs' random function, I'm sure you will appreciate it :) Here is the code

(dolist (i '(1 2))
(insert (concat (number-to-string (1+ (random 199))) " ")))


15,97

(97 feels very lucky)

• 97 seems to be too lucky after your edit :-/ – giordano Dec 21 '13 at 17:37
• @giordano: I was wondering what the edit was until I ran the code. :P – Paulo Cereda Dec 21 '13 at 17:42

42, 37

Number 1: 137

Number 2: 143

Number 1: 65

Number 2: 105

(65 is the smallest number expressible as the sum of two squares two ways. 105 is the product of the first three odd primes, and what 7 NYC subway tokens cost when I lived there many years ago.)

Number 1: 22

Number 2: 44

My favorite numbers: 108, 69. :)

47, 167 :-)

"Body must be at least 30 characters; you entered 20." : not too short anymore...

26, 2.

..............................

My luck numbers are 4 and 5 but I need a few more words here to make it stick.

Number 1: 123

Number 2: 77

With PSTricks' tools.

\documentclass[preview,border={6pt 6pt 22pt 12pt},varwidth]{standalone}
\usepackage{pst-tools}

\def\GetRand{\psPrintValue{rand 201 mod}}

\begin{document}
\pstVerb{realtime srand}
\GetRand\\\GetRand
\end{document}


Why can't we give a duck (0) as the answer? ;-)

Number 1: 33

Number 2: 66

• @paulo won't understand the cricket reference:-) – David Carlisle Dec 22 '13 at 15:09
• @DavidCarlisle: Hehe. I know. I think only you and me are in this gang. You people taught us the game. – user11232 Dec 22 '13 at 22:24
• ooh there's cricket involved? – Paulo Cereda Dec 23 '13 at 8:50
• I'm trying hard to forget that I ever heard of cricket right now ... – Andrew Stacey Dec 23 '13 at 20:47
• @PauloCereda In cricket, if a batsman gets out without scoring, we say " he is gone for a duck" :-) – user11232 Dec 23 '13 at 22:49
• @PauloCereda BTW '0' is India's contribution to the world of mathematics. We say on a lighter note, India's contribution to mathematics is 0. ;-) – user11232 Dec 23 '13 at 22:54
• @Harish: ooh! :) – Paulo Cereda Dec 23 '13 at 23:35

Number 1: 117

Number 2: 183

Thanks for hosting this raffle :-)

99 and 199. Do you really think they're chosen at random?

1 and 200. Should I explain, that they are the ends of the interval? ;-)

Number 1: 13

Number 2: 93

23, 177

My wild guesses

Number 1 : 11

Number 2: 121

(50, 52) // chosen by fair d100 roll.
// guaranteed to be random.


1st Number: 29 (current Paulo Cereda's age, according to his profile page)
2nd Number: 14 (because the lottery will happen in 2014).

And yes, I understood that the numbers in the lottery will be randomly picked... but that does not mean my guesses have to be random as well! ;-)

153 and number 154. Both will win!

Number 1: 74

Number 2: 147

No reason to choice them.

Number 1: 193
Number 2:  38

These are parts of Donald Knuth's year of birth: 1938

6,​​​​​​​​​​​​​​​​​​​​​​​​​​​​7

12 and 171. Hopefully I will win a duck for the first time.

• Now that I'm tabulating the answers, I noticed that Claudio already picked 171. Hurry up, I'll wait for you to pick another number. :) – Paulo Cereda Dec 31 '13 at 19:29

Number 1: 8

Number 2: 63

Number 1: 113

Number 2: 31

Maybe they'll turn out to be lucky for me and I'll get a duck!