Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102698

Re: Searching Sets (Lottery Results)

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Searching Sets (Lottery Results)
Date 2016-02-09 11:04 +1100
Message-ID <mailman.115.1454976306.2317.python-list@python.org> (permalink)
References <6afb7298-6da7-44f9-847e-9603554c2f09@googlegroups.com>

Show all headers | View raw


On Tue, Feb 9, 2016 at 8:45 AM, MrPink <tdsimpson@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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