Searching for Lottery drawing list of ticket match...

MrPink tdsimpson at gmail.com
Wed Aug 10 14:55:27 EDT 2011


I need a little nudge into the right direction with this problem.
As an exercise for me to learn about Python, I am trying to determine
the best way to search a list of "lottery drawings" for a match with a
lottery ticket.

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.



More information about the Python-list mailing list