Gerard Flanagan wrote:

> I don't think you need all those 'ifs'.
> 
> groups = [group1, group2, group3, group4]
> 
> def checkOrder(x, y):
>     x_votes = 0
>     y_votes = 0
>     for group in groups:
>         if group.index(x) < group.index(y):
>             x_votes += group[4]
>         else:
>             y_votes += group[4]
> 
> for order in all_perms(props):
>     winner = reduce(checkOrder, order)
>     print '%s wins!' % winner
>     print order
> 

Nice. I was shuddering as I copy and pasted each if block. :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to