You need to toss a coin. But why settle for the best of 3? cointoss3000 gives you the best of 3000.
- make
- C compiler
make./ct3Sample output:
heads
Use -n <number of tosses>. For example, if you want the best of 3,
./ct3 -n 3Of course, as the proud owner of cointoss3000, you won't want to limit yourself to a mere three coin tosses.
cointoss3000 is capable of tossing a coin up to (at least) 2^64 - 1 times. (Consult your C compiler's manual for the maximum number of coin tosses on your platform.) This will take a long time.
./ct3 -n 18446744073709551615Overflowing the unsigned long long is not allowed. Sorry, Matt Parker.
# not allowed
./ct3 -n 18446744073709551616You can do it backwards though.
./ct3 -n -1is equivalent to
./ct3 -n 18446744073709551615Matt Parker, you are welcome.
If you want to know how many heads and tails you got, pass the -v flag.
./ct3 -vSample output:
heads: 1546
tails: 1454
winner: headsBSD 3-Clause. See licence for full text.