Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102722
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2016-02-09 06:04 -0800 |
| References | <6afb7298-6da7-44f9-847e-9603554c2f09@googlegroups.com> <mailman.115.1454976306.2317.python-list@python.org> |
| Message-ID | <09c7f060-e01f-48ff-a02d-b5ba1f52f41a@googlegroups.com> (permalink) |
| Subject | Re: Searching Sets (Lottery Results) |
| From | MrPink <tdsimpson@gmail.com> |
On Monday, February 8, 2016 at 7:05:24 PM UTC-5, Chris Angelico wrote: > On Tue, Feb 9, 2016 at 8:45 AM, MrPink wrote: > > I load the lottery drawings into memory for searching with the following code although, it is incomplete. I am stuck and need some guidance. > > > > The set datatype seems to be the best for searching, but how best can I implement it? > > > > And I want the results to highlight the numbers that were matched. For example, if the white balls in the drawing are: > > "42 15 06 05 29" > > > > AND the numbers on the lottery ticket are: > > "06 15 32 42 56" > > > > THEN the display might look like: > > "06* 15* 32 42* 56" > > > > WHERE * signifies a match. > > > > This suggests that there is an order to the numbers on your ticket > (you want to print them out in the same order), but not to the winning > numbers, which are simply a set. The easiest way to handle that would > be to iterate over your numbers, asking "if number in > winning_numbers:", and printing out a "match" marker if it is or a > "non-match" marker if it isn't. > > ChrisA Thanks Chris. Very good point. I was just too deep in the weeds to see that simple solution. I was overthinking it. ;-) Sincerely,
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Searching Sets (Lottery Results) MrPink <tdsimpson@gmail.com> - 2016-02-08 13:45 -0800
Re: Searching Sets (Lottery Results) Chris Angelico <rosuav@gmail.com> - 2016-02-09 11:04 +1100
Re: Searching Sets (Lottery Results) MrPink <tdsimpson@gmail.com> - 2016-02-09 06:04 -0800
csiph-web