15
Last seen 9 years ago
Member for 9 years, 11 months, 9 days
Difficulty Normal
Very nice code! If you wanted to be more concise, you could just use 'args' everywhere you used arg_list.
def checkio(*args):
if len(args) == 0:
return 0
return max(args) - min(args)
Works just as well.
More
There is no need to sort after every number is appended to the 'number' list, once after all numbers are appended would work.
More
Well named variables and well commented :-)
More
Nice code! If you wanted to be more concise, you could make three changes.
1, args is treated as a tuple (a list you can't edit) so turning them into a list is unnecessary.
2. The '*' is not needed anywhere except in the function argument.
3. Checking to see if there is only 1 argument isn
More
Am I reviewing my own code? :-) I guess there was one obvious way to do it, what with the hints and all.
More
Sets can not preserve order, so sorting the list before making it a set in lines #2 and #3 is immediately undone. Also, the "sorted()" function returns a list, so "sorted(list(...))" could just be "sorted(...)".
def checkio(first, second):
f = set(first.split(','))
s = set(s
More
abs() is already a function, the lambda is not needed.
def checkio(numbers_array):
return sorted(numbers_array, key=abs)
More
Very nice code :-)
If you didn't want to type out math.XXX each time, you could alter your import statement like this:
from math import pi, sqrt, atanh, asin
print(pi)
>>> 3.1415....
print(sqrt(4))
>>> 2.0
If you want to get even fancier...
from math impor
More
Very cool recursive function! It would probably start to run slowly as n increases though because triangle(n) is called once on each number for every n above it. triangle(4) calls triangle(1) 4 times, for instance.
More
Very clear code, I like it. Why do you convert 'attacked' back into a list after every minute? You could leave it as a set if you wanted.
def capture(matrix):
time = 0
attacked = {0}
new_infected = []
while any(matrix[a][a] > 0 for a in range(len(matr
More
Very nice! If you wanted to shorten the code however,
if cmd[1] == "O":
try: somme += int(stack.pop())
except: pass
Can be:
if cmd[1] == 'O' and stack:
somme += int(stack.pop())
More
Nice, clear code. Just a note though, it's considered bas practice to use a built in function as a variable name (min for minutes is already used for the minimum function).
More