29
Last seen 3 months ago
Member for 2 years, 3 months, 6 days
Difficulty Normal
Nice to see `with` used here on checkio not to to suppress exceptions
More
The conversion to numpy array is not needed, you may pass data directly to the det function.
More
I have seen some use for with, but no good use ... I used it for error suppression `with suppress(IndexError):`
More
The range function is more powerful, you may also use it to increase the value in bigger steps than 1. Or said otherwise, if you use range(0, len(items), size) you do not need to multiply by size inside the loop. In this case, if check is also not needed as the first element of the slice will always
More
2 comments:
- the else part is unnecessary as it does nothing, better not to include it
- you should remove the print line when you are done with your coding (I suppose you added it for debugging). Leaving it means the function has a side effect that is not in the documentation.
More
If you set X first and min afterwards, you're able to use X during the calculation of min.
Be careful with your variables names, min does exist as function in python, but of course you are allowed to override in python. Might cause confusion later.
More
In my opinion this is not a correct solution to the problem as stated. It passes the tests, but it does not create a class as requested. In some cases it behaves differently (Capital / c is the function, Capital2 the class, c2 is the object):
>>> c = Capital('Kyiv')
>>> c()
Traceback (m
More
nice idea to use a generator with two alternating yields!
More
The solution didn't age well, in the meantime we have the match-case statement in python 3.10
More
There is however a small issue, python passes lists a reference to the original list. This means changes to the list inside the function will reflect to the calling code:
>>> l = [5, 13, 27, 14]
>>> l
[5, 13, 27, 14]
>>> checkio(l)
59
>>> l
[59]
While no problem for thi
More
Very nice, double re power, as well as short and very readable (well, as readable as regex can be)
More
Using the generator syntax instead of list comprehension would be speedier.
More
Personally, I find the c.lower() != c not very clear. Maybe you have seen the c.isupper() in other solutions.
More
Nice, my code was very similar, I used bool(re.match...) instead of the if/else.
More