Unfortunately my laptop crashed and then crashed again so we decided
against using it to develop our solution.  The dice generating code was
just itertools.product and then some list slicing to generate the right
number of dice with the right number of sides.

It's great to see improved code for the scoring.  Having quickly tested the
different solutions it seems that the fast approach is actually slower than
the simple approach for the supplied dice.  Do you get that as well?  I
wonder what size the dice need to be for the fast version to perform
better.  An optimised method that checks the sizes of the dice and then
calls the faster method could be useful.

I think some improved approach to generating the dice is also needed.
Running through the output of itertools.product with the code below on
smaller numbers of repeats and extrapolating indicates it would take over
170 days to run through all the iterations for 3 6-sided dice

>>> def exhaustive(num):
...     g = itertools.product(range(1,7), repeat=num)
...     for h in g:
...             pass
...

On the subject of talks I've heard a couple of other groups raise the
possibility of picking one or more pycon talks and watching them before
further discussion.



On 21 March 2012 14:42, Edward Saxton <[email protected]> wrote:

> On 19/03/2012 05:50, [email protected] wrote:
>
>> On 16 March 2012 11:14, Jonathan Street <[email protected]
>> <mailto:streetjonathan@gmail.**com <[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<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 <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<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: 
> python-north-west@**googlegroups.com<[email protected]>
> To unsubscribe: 
> python-north-west-unsubscribe@**googlegroups.com<[email protected]>
> Feeds: 
> http://groups.google.com/**group/python-north-west/feeds<http://groups.google.com/group/python-north-west/feeds>
> More options: 
> http://groups.google.com/**group/python-north-west<http://groups.google.com/group/python-north-west>
>

-- 
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

Reply via email to