Possible numbers for a drawing are:
5 whiteballs (wb): 1-55
1 blackball (bb): 1-49
example: wb1, wb2, wb3, wb4, wb5, bb
Example list of lottery drawings:
date,wb,wb,wb,wb,wb,bb
4/1/2011,5,1,45,23,27,27
5/1/2011,15,23,8,48,22,32
6/1/2011,33,49,21,16,34,1
7/1/2011,9,3,13,22,45,41
8/1/2011,54,1,24,39,35,18
...
Typically a lottery ticket can have multiple combinations for the
ticket to be a winner. For example:
2 wb, 1 bb
3 wb
3 wb, 1 bb
4 wb
4 wb, 1 bb
5 wb
5 wb, 1 bb (jackpot winner)
An object oriented solution might be to create a list of "Drawing"
objects and then loop through the list to find a match for the ticket
object. For example:
if oDrawing[x] == ticket then "Do XYZ"
Or I could just perform this task with procedures and loops and skip
the object solution idea.
Do Python developers have a preference?
Would it be worth the overhead to initialize a list of drawing objects
to search through?
There is no database back-end, so no SQL, etc.
I hope all that makes sense.
Thanks for you help.
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)]
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,