31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 1 month, 24 days
Difficulty Normal
Set -1 because **len(array) == 0**
PEP8: For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
Yes:
if not seq:
if seq:
No:
if len(seq)
if not len(seq)
More
Some notes about style:
no need parenthesis and you miss space after coma
return ",".join(phrases).replace("right", "left")
More
You can use tuple of tuples instead dict **elements = ((1000 : 'M'), ...)** to avoid sort.
More
You can sort a,b,c at the begining. This will simplify check and you will not need sort at the end.
a, b, c = sorted((a, b, c))
More
http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
you can use str.startswith it is more readable.
More
I down vote this solution because you use **fs += [str(p)]** instead of **fs.append(str(p))**.
**bool()** and **** has same behavior in condition expression, you can omit **bool**: **while data and data % p == 0:**
**int(''.join(sorted(fs)), 10)** you can omit **, 10** because it
More
http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
More
For one side it is clear and readable but for other is so uneducative for it algorithmic complexity.
You can use combinations from itertools to make all possible pairs.
More
It can be more cute and clever with string format:
return eval('%c%c%c(%s)' % (115, 117, 109, x))
More
string formatting will make it more readable '%c%c'.
you can use set methods to find intersection.
More
At line 5 you code works correct, but you implement you idea with error. Real name for variable **line** should be **char**.
You don't need **list(s)** in that code, just pass **s**.
return list(map(lambda s: "".join(list(s)), zip(*grid)))
line 30 and 45: you no need parenthesis arou
More
Check docs about string formatting.
text = ' ' + text + ' '
comment = " " + "_" * len(text) + "\n"
comment += "<" + text + ">\n"
comment += " " + "-" * len(text)
return "\n" + comment + COW
Using string formatting:
width = len(text) + 2
More