Re: Find word by given characters

2020-11-04 Thread duncan smith
On 04/11/2020 19:12, Avi Gross wrote: > My comments at end: > > -Original Message- > From: Python-list On > Behalf Of duncan smith > Sent: Wednesday, November 4, 2020 1:09 PM > To: python-list@python.org > Subject: Re: Find word by given characters > >

RE: Find word by given characters

2020-11-04 Thread Avi Gross via Python-list
My comments at end: -Original Message- From: Python-list On Behalf Of duncan smith Sent: Wednesday, November 4, 2020 1:09 PM To: python-list@python.org Subject: Re: Find word by given characters On 04/11/2020 04:21, Avi Gross wrote: > Duncan, my comments below yours at

Re: Find word by given characters

2020-11-04 Thread duncan smith
On 04/11/2020 04:21, Avi Gross wrote: > Duncan, my comments below yours at end. > > ---YOURS--- > The Counter approach only requires iterating over the letters once to > construct the letters bag, then each word once to create the relevant word > bag. After that it's (at worst) a couple of

RE: Find word by given characters

2020-11-03 Thread Avi Gross via Python-list
Duncan, my comments below yours at end. ---YOURS--- The Counter approach only requires iterating over the letters once to construct the letters bag, then each word once to create the relevant word bag. After that it's (at worst) a couple of lookups and a comparison for each unique character in

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 22:14, Avi Gross wrote: > I, too, have wondered what exactly the point was of the required > functionality for SCRABBLE but note you can extend a current word so > additional letters may be available in a game but only if they are an exact > fit to put before, after, or in middle of

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 23:35, Bischoop wrote: > On 2020-11-03, duncan smith wrote: >>> >> > from collections import Counter > letters = 'att' > letter_counts = Counter(letters) > word = 'tolerate' > wd_counts = Counter(word) > for char, cnt in letter_counts.items(): >> print

Re: Find word by given characters

2020-11-03 Thread dn via Python-list
On 04/11/2020 12:27, Bischoop wrote: On 2020-11-03, Chris Angelico wrote: This seems strangely backwards for a Scrabble game. Normally you would have a set of available tiles, and you have to form a word using only those tiles, but it doesn't necessarily have to use them all. You seem to have

Re: Find word by given characters

2020-11-03 Thread Bischoop
On 2020-11-03, duncan smith wrote: >> > from collections import Counter letters = 'att' letter_counts = Counter(letters) word = 'tolerate' wd_counts = Counter(word) for char, cnt in letter_counts.items(): > print (cnt == wd_counts[char]) > > > True >

Re: Find word by given characters

2020-11-03 Thread Bischoop
On 2020-11-03, Chris Angelico wrote: > > This seems strangely backwards for a Scrabble game. Normally you would > have a set of available tiles, and you have to form a word using only > those tiles, but it doesn't necessarily have to use them all. You seem > to have something where you must use

RE: Find word by given characters

2020-11-03 Thread Avi Gross via Python-list
three also has overhead. -Original Message- From: Python-list On Behalf Of Chris Angelico Sent: Tuesday, November 3, 2020 12:35 PM To: Python Subject: Re: Find word by given characters On Wed, Nov 4, 2020 at 1:11 AM Bischoop wrote: > Let me clarify what I want to do: > We all kn

Re: Find word by given characters

2020-11-03 Thread Chris Angelico
On Wed, Nov 4, 2020 at 1:11 AM Bischoop wrote: > Let me clarify what I want to do: > We all know Scrabble game. > there's a file with Dictionary containing word in each line, the idea is > to input some letters for example mentioned earlier: att, the script > supposed to find all words in which

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 14:06, Bischoop wrote: > On 2020-11-03, dn wrote: >> >> >> The (full) specs are not clear. There's certainly room for >> misunderstanding. I'd be happier if I could 'see' a full spec or >> recognise a practical application, because then we'd be better able to >> discuss facts.

Re: Find word by given characters

2020-11-03 Thread Ben Bacarisse
Bischoop writes: > Let me clarify what I want to do: > We all know Scrabble game. > there's a file with Dictionary containing word in each line, the idea is > to input some letters for example mentioned earlier: att, the script > supposed to find all words in which letters: 'a','t','t' occur and

Re: Find word by given characters

2020-11-03 Thread Bischoop
On 2020-11-03, dn wrote: > > > The (full) specs are not clear. There's certainly room for > misunderstanding. I'd be happier if I could 'see' a full spec or > recognise a practical application, because then we'd be better able to > discuss facts. Meantime, we try to help with what we have been

Re: Find word by given characters

2020-11-02 Thread dn via Python-list
On 03/11/2020 13:13, duncan smith wrote: On 02/11/2020 19:09, dn wrote: On 02/11/2020 23:29, Bischoop wrote: On 2020-11-01, duncan smith wrote: But this generates the letters counts for each word. They only need to be generated once (outside the for loop). And using count requires iterating

Re: Find word by given characters

2020-11-02 Thread dn via Python-list
On 03/11/2020 12:10, Bischoop wrote: On 2020-11-02, dn wrote: If you have a working Py2 version, once print-statements were changed into functions, what errors were thrown-up? That was almost 15 if no more years ago when I was learning then had a long break beacause Life :-) Got married,

Re: Find word by given characters

2020-11-02 Thread duncan smith
On 02/11/2020 19:09, dn wrote: > On 02/11/2020 23:29, Bischoop wrote: >> On 2020-11-01, duncan smith wrote: >>> >>> But this generates the letters counts for each word. They only need to >>> be generated once (outside the for loop). And using count requires >>> iterating over the letters /

Re: Find word by given characters

2020-11-02 Thread Bischoop
On 2020-11-02, dn wrote: > > > If you have a working Py2 version, once print-statements were changed > into functions, what errors were thrown-up? > > That was almost 15 if no more years ago when I was learning then had a long break beacause Life :-) Got married, working as Chef, now have some

Re: Find word by given characters

2020-11-02 Thread dn via Python-list
On 02/11/2020 23:29, Bischoop wrote: On 2020-11-01, duncan smith wrote: But this generates the letters counts for each word. They only need to be generated once (outside the for loop). And using count requires iterating over the letters / words for each x in letters (rather than once). For

Re: Find word by given characters

2020-11-02 Thread Bischoop
On 2020-11-01, duncan smith wrote: >> > > But this generates the letters counts for each word. They only need to > be generated once (outside the for loop). And using count requires > iterating over the letters / words for each x in letters (rather than > once). For a large enough collection of

Re: Find word by given characters

2020-11-01 Thread duncan smith
On 01/11/2020 13:38, Bischoop wrote: > On 2020-11-01, Bischoop wrote: >> I'm working on a script i which user inputs letters and then a printed >> words containing those letters. The scripts works however I can't solve >> one problem , it prints also words in which these letters occur more >>

Re: Find word by given characters

2020-11-01 Thread Bischoop
On 2020-11-01, Bischoop wrote: > I'm working on a script i which user inputs letters and then a printed > words containing those letters. The scripts works however I can't solve > one problem , it prints also words in which these letters occur more > than once. > --- > Fore

Re: Find word by given characters

2020-10-31 Thread Terry Reedy
On 10/31/2020 8:36 PM, Bischoop wrote: I'm working on a script i which user inputs letters and then a printed words containing those letters. The scripts works however I can't solve one problem , it prints also words in which these letters occur more than once. --- Fore example:

Re: Find word by given characters

2020-10-31 Thread MRAB
On 2020-11-01 00:36, Bischoop wrote: I'm working on a script i which user inputs letters and then a printed words containing those letters. The scripts works however I can't solve one problem , it prints also words in which these letters occur more than once. --- Fore example:

Find word by given characters

2020-10-31 Thread Bischoop
I'm working on a script i which user inputs letters and then a printed words containing those letters. The scripts works however I can't solve one problem , it prints also words in which these letters occur more than once. --- Fore example: Letters: at Output: auto, autobahn.