**Paste:**#107105**Author:**1HaskellADay**Language:**Haskell**Channel:**-**Created:**2014-07-08 11:15:25 UTC**Revisions:**- 2014-07-09 21:35:21 UTC #107210 (diff): No title (1HaskellADay)
- 2014-07-08 11:15:25 UTC #107105: Well, that was RND... (1HaskellADay)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ```
{--
0. Time your standard, by-the-book, implementation of lotto and then time
your new-and-improved algorithm. How do they compare? What speed-up did
you observe? Use Haskell facilities provided by child modules of
Data.Time to do this.
1. getStdGen/Random gets you the SYSTEM (?!?) random number generator
that is good to at least 30 bits? THIRTY BITS ONLY?!?!
Pshaw!
Rule 30 gives you INFINITE BITS OF RANDOMNESS to choose from, eventually.
Kinda. Sorta.
Implement your own random number generator; have it be an instance of
RandomGen from the Random module. Use your own algorithm...
Or somebody else's algorithm you choose, but SYSTEM? SYSTEM? All kinds of
red flags with that choice, am I right?
I'm right.
That's just so ... platform-dependent! Ick! (even if the platform is GHC
or the standard libraries. YOU can write a better RNG, or a different one,
at least!)
Now that you have your own random number generator, use it instead of
StdGen to generate your random selection(s) for the LOTTO exercise at
http://lpaste.net/107104
2. Of course there's pseudorandomly-generated numbers, and then there's
purely-generated random numbers ('real' random numbers). Go to random.org,
implement your random number generator as a client of one of its (now) many
free services. Use it in your lotto function.
Then, just rewrite lotto as a client of random.org.
'30 bits'? Why settle for that when you could have this?
A solution provided at http://lpaste.net/107209
--}
``` |