On 19/03/2012 05:50, [email protected] wrote:
On 16 March 2012 11:14, Jonathan Street <[email protected]
<mailto:[email protected]>> wrote:
The session last night seemed to go fairly well. We decided to work
on a generator of nontransitive dice
(https://en.wikipedia.org/wiki/Nontransitive_dice). Both groups
began with writing generators for all possible dice given upper and
lower bounds and fixed number of dice and sides. As such much time
was spent on getting (re)acquainted with itertools.
Seems like an interesting evening. I often find my self getting
(re)(re)(re)acquainted with itertools every time I start a new project.
Any code to share?
This isn't from that night, but over the weekend I realized there was an
O(n+m) solution to part of the problem (scoring the dice) where
everything we wrote on the day was O(nm).
https://gist.github.com/2147071 .
Full and simple are about what was written on the night from what I
remember, and oneline is me playing with reduce.
Actually generating dice and finding nontransitive sets is left as an
exercise for the reader ;)
In the pub afterwards a piece of code, I think written in matlab,
was mentioned which cycled through all possible RGB colours and displayed
them in an image. Apparently this code took 30 minutes to run. I was
curious to see how long it would take in python so on the train home I
wrote a snippet of code to check (https://gist.github.com/2049532). On my
laptop it never takes more than 30 seconds.
Another nice use of itertools.
Yeah very nice, I'm always impressed by how much hard work suddenly
hides when you remember itertools. Normally closely followed by my CPU
maxing out as I ask it to do something far too big for it.
Ed
--
To post: [email protected]
To unsubscribe: [email protected]
Feeds: http://groups.google.com/group/python-north-west/feeds
More options: http://groups.google.com/group/python-north-west