57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 15 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
> Python helps me to stay sane in this crazy world.
Ok, then maybe _don't_ read my solutions. :-D :-]
More
It seems I'm not the only one getting strange compliments on CiO. Python gets them too. :-D
More
I'm not absolutely sure, but I think Py2 also gives you better way of calling replace:
','.join(phrases).replace("right", "left")
More
Lines 5 and 7:
if i in "([{":
if i in ")]}":
Line 15: You can just
return not stack and not error
Or even `not (stack and error)` :-) But really, why error at all? It's not that you can recover anyway. When you find an error, don't set error to True, just `return False`. At the end,
More
http://www.checkio.org/mission/super-root/publications/veky/python-3/utilities/?ordering=most_voted
Not complicated at all, just compressed. :-D
More
It's ok, but if you use cmath, you'll see that there are no different cases. :-)
Also, why name something `r` (an empty name, probably for "value to **r**eturn") just to return it immediately afterwards. Especially at the end... just
return [round(func(a, c), 2) for func in (v, sa)]
But of co
More
Your code has a weird mix of using //2, /2 and /2.0. (That's probably the consequence of using Py2.:) Either stay with Py2 (without `from __future__ import division`), use `/2` and `/2.0`, or (much better;) switch to Py3, where you use `//2` and `/2`.
Also, length should be properly spelled. Or jus
More
It's even shorter than @StefanPochmann's :-O
"*" in the title stands for 'Grail', of course. ;-D
More
[Beat ya!](http://www.checkio.org/mission/weekend-counter/publications/veky/python-27/holly-this-is-short/#comment-35810)
More
LOL @ `'.' not in i[0]`... you obviously meant `'.' not in i`, or `'.' != i[0]`.
But much clearer would be just `if i in {'X'*3, 'O'*3}:`
Nice factoring out of `board[1][1].isalpha()`. :-)
More
A classic example of overthinking things. You can just remove line 1, and OrderedDict(), and .items(), and everything will work. :-D
More
Homework: eliminate duplication of data_len/2. :-) (Hint: (data_len-1)/2 is also data_len/2 in your case.:)
More
Nice shortcircuiting when len < 10.
Lines range(9, 18, 3) ;-): comparisons can be chained.
if 'a' <= i <= 'z':
Even better: `if i.isupper():` (also `islower` and `isdigit` are available).
Comments and those print "debug" statements should be deleted before publishing.
It's nice that you _co
More
Horribly complicated. Did you see the hint? .count is your friend.
del data[data.index(i)] ~~~> data.remove(i)
Partial unrolling of loops (line 6 == line 17) is a very common source of very hard to find bugs. Don't do that. Instead of lines 6 and 17 just write it in line 10.
Here
More
Line 6: chaining is cool.
if number % 3 == number % 5 == 0:
Lines 8 and 10: `not` is cool too when checking divisibility.
if not number % 3:
And `str("Fizz")` is like `list([3, 5])` or `float(3.14)`: completely redundant. ;-]
More
You don't have to write len(array) inside array[...]. Just
... * array[-1]
About součet: it's called `sum` in English.
def evens(array):
for index, element in enumerate(array):
if not index % 2: # remember this from FizzBuzz? ;-)
yield element
souč
More
As I said, line 2 is just
if not args:
Or you can hackingly use the fact that 0 is the same:
return len(args) and (...big - ...small)
(BTW naming can also be chained: `big = small = args[0]`.)
But for that to function, you have to calculate big and small in expressions. However, that's
More