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

Reply via email to