45
Valentin Bryukhanov
http://bryukh.com/
Last seen 2 years ago
Member for 11 years, 7 months, 23 days
Difficulty Normal
Developer, engineer and taskMaker.
deepCopy2d == from copy import deepcopy == [row[:] for row in src]
makePermutations == from itertools import permutations
More
line 3-7 -- If you need indexes and elements, then you can use enumerate.
"int(dig_int / 2) -- for py2 it's already int. For py3 -- "//".
More
> THE ANSWERS TO EVERY QUESTION IN THE KNOWN UNIVERSE IS NOT 42 BUT YOGURT
THEY hide the Truth and 42 is a false track :-)
More
Looks like you love OOP :-)
Honestly I think you can easily use simple dictionary or named tuples instead Node class.
"inverse" is a simple dict that are wrapped in a function. I didn't get why do you need a function for that.
More
I didn't get it - how it can work in python3? Because string.lowercase was removed in py3.
More
"l" is very very bad variable name :-) Because it looks like "1" in monospace fonts.
More
"max" is a built-in function, thus it's a bad idea to use this as the variable name.
And brackets after "if" are redundant.
More
> 3.14159265358979
You don't like constants or "math" modules?
More
I think you can make
text = text.lower()
once.
And "count" method works for strings too, not only for lists.
The next:
(ord(i) < ord(most_common_letter)) == (i < most_common_letter)
More
for c in text.lower():
if c.islower():
I understand why do you use "islower", but for first glance it looks weird :-)
"isalpha" will be better here, just for readability.
More
if x.isalpha() is False:
Why do you use this construction?
text = list(phrase.lower())
"list" is redundant operation here.
line 7-10 can be simpler, even if you don't like "setdefault" or default dicts:
countDict[x] = countDict.get(x, 0) + 1
More
"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