Drawing Straws in Haskell
Find a file
2015-05-04 10:42:40 +02:00
.gitignore Hello World 2015-04-26 20:51:25 +02:00
cabal.config Use only tested packages 2015-04-30 22:13:34 +02:00
DrawingStraws.cabal Relax base dependency requirements 2015-05-04 10:42:40 +02:00
DrawingStraws.hs evaluate with seepseq 2015-04-30 22:50:15 +02:00
LICENSE Initial commit 2015-04-26 20:43:42 +02:00
README.md Update build instructions with sandbox info 2015-04-28 10:22:01 +02:00
Setup.hs cabal init 2015-04-26 22:07:35 +02:00

Drawing Straws in Haskell

This command-line program simulates the drawing of straws over a series of random draws, and counts how many times each position drew the short straw.

Each position should have an equal probability to draw the short straw.

Usage

The DrawingStraws executable takes 2 parameters:

  1. The number of straws in each bunch of straws.
  2. How many random draws we should count.
$ .cabal-sandbox/bin/DrawingStraws 5 5000000
2015-04-27 19:42:06.782093 UTC | Counting short straw occurrences over 5000000 draws, with 5 straws in each bunch.

2015-04-27 19:42:06.783498 UTC | Performed 5000000 draws.
2015-04-27 19:42:08.207945 UTC | Counting position occurrences...

Short straw position counts:
1:	1000379
2:	999752
3:	1002413
4:	999431
5:	998025

Total: 5000000

2015-04-27 19:42:17.242081 UTC | Done.

Building

Needed only once after cloning repo:

$ cabal sandbox init

Compile and install after each code change:

$ cabal install -j

The binary is placed in this repository checkout under .cabal-sandbox/bin/DrawingStraws