Find word by given characters
Bischoop
Bischoop at vimart.net
Mon Nov 2 18:10:31 EST 2020
On 2020-11-02, dn <PythonList at DancesWithMice.info> 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
more time, working part time so a got back to old hobby and learning
again, however I see now with age everything is going slower lol
> Multiple loops written in Python are likely to be slower than same in
> compiled code - which was probably part of the motivation for @Terry's
> response. Plus, "re-use" - why write something ourselves if someone else
> has already done the work?
>
For educating purposes?
>
> How about a change of tactics?
>
> - str.find() or .index() will locate a character within the string
> (starting from character[0]/the left-hand side)
> - if this fails, tears will fall...
> - repeat, from the right
> - if both results are the same character/position, it must be unique
> within the string
> - repeat for each character in "Letters"
>
> This process assumes that built-in functions are faster than exhaustive
> scans written in Python, and thus (presumably) also that the number of
> "Letters" is small in comparison with the lengths of words.
>
ha, everything seems easy only if you know that.
Sorry mate, for you it's obvious for me: oh, OK.
>
> Once the algorithms are proven, a speed comparison might be an
> interesting exercise...
>
> For extra credit: once you've solved both, and compared the alternatives
> on your machine; post the code (and test data), and ask various
> colleagues 'here' to repeat the speed/performance comparisons on other
> machines.
>
> Will/should the results be identical?
I'll look into that tomorrow, your sugestions guys and hopefully I've
achieve these goals.
Thanks again
More information about the Python-list
mailing list