Boy, that was a lot more elegant that I would have thought. Though hard for a greenhorn like me to really understand how the assignment are working, etc.
Anyway, what are these kind of statement call so that I can read up more on this? What Python feature are you using? num_whites = ticket_whites & drawing_whites black_matching = ticket_black == drawing_black Thanks, On Aug 10, 11:35 pm, Miki Tebeka <miki.teb...@gmail.com> wrote: > Python built in types are enough for this problem IMO. You can use sets of > tuples to specify ticket and drawings and then just do set intersection. > > Say the drawing is set([(5, 'wb'), (1, 'wb'), (45, 'wb'), (23, 'wb'), (27, > 'wb')]) (keeping black ball out). The you can create a score function: > > Side note: I might used a namedtuple to have drawing.whites, drawing.black. > > def score(ticket_whites, ticket_black, drawing_whites, drawing_black): > num_whites = ticket_whites & drawing_whites > black_matching = ticket_black == drawing_black > return { > (2, True) : 1, > (3, False) : 2, > (3, True) : 3, > (4, False) : 4, > (4, True) : 5, > (5, False) : 6, > (5, True) : 10 > }[(num_whites, black_matching)] -- http://mail.python.org/mailman/listinfo/python-list