45
Valentin Bryukhanov
http://bryukh.com/
Last seen 2 years ago
Member for 11 years, 7 months, 16 days
Difficulty Normal
Developer, engineer and taskMaker.
"l" is not good name for variables - because it looks like "1" or "I" for many fonts and hard readable.
if l % 2 != 0 :
can be simpler:
if l % 2:
Your code is good, but PEP8 and good variables name can make nice code from it.
More
Nice code. You can make a micro-optimisation with
letter_count = text.count(letter)
With that you don't need count this twice.
More
copyOfData = data
For lists it's not a copy, you just created one more link for the same array. If you will change one, then you will change other.
You can count elements with the method "count"
[1, 2, 3, 1, 1].count(1) # return 3
More
Whitespaces can be useful. PEP8 can make your code is more readable.
And "Counter" here is overkill, I think. But I sure you can make this pretty and more simpler.
More
Sometimes you are using spaces around operators, sometimes - not. Not bad and if you will make it more "general" then it will be nice solution.
More
Why do you use class here? They look like simple dictionaries here.
More
Not universal, but funny :-) And I like "properties". Nice!
More
Change input data is not a good practice. You can use
work = sorted(data)
instead line 6-7
amount = len(data)
line 9 is overhead
if amount % 2: # the same as amount % 2 != 0
and line 13 is not needed.
More
Do you think A* is not overkill algorithm for this task? I don't sure about heuristic.
But +2 for implementation and +1 for good comments.
More
any([ch.isupper() for ch in data]) and
I prefer list comprehension. For memory problem, i can just to replace list comprehension to generator comprehension. If honestly, i don't like map and filter.
More
" == True" is redundant.
"range(0, len(list_of_words))" -- 0 is default, so you can use range(x) == range(0, x)
And you can iterate through list instead indexes:
for w1 in list_of_words:
for w2 in list_of_words:
More