22
Last seen 5 years ago
Member for 8 years, 4 months
Difficulty Normal
Would like to receive comments/critics of my published solutions.
Instead of checking if something is in your list (line 5), you could have directly checked if there’s something in args, and if there is, find max and min of args - so you don’t need your first three lines where you create 'list_of_numbers’:
if not args:
return 0
return max(args) -
More
What's the difference between 'x' and 'z'?
Why not just define one of them above if-else, and use that for both cases?
More
Lines 9-13:
1. you don't need line 10
2. more pythonic way of iterating through data would be:
for value in data:
if data.count(value) > 1:
final_list.append(value)
More
Why didn't you add a check to see if you have already been at (h, v)? It would save you some time stepping on the same position over and over again
More
(this is just a test of a random review by mail)
Instead of manually counting number of '1', you could have done:
return binary.count('1')
More
'sum' is a python's built-in keyword for, wait for it, summing :D You shouldn't use variables with the same name.
More
You can get even indexes of an array using slicing:
array[::2]
and then summing them is as easy as:
sum(array[::2])
For more info about slicing see [here](http://pythoncentral.io/how-to-slice-listsarrays-and-tuples-in-python/)
More
Line 6: this is usually checked like this:
if array:
Lines 7-9: You can get even indexes of an array using slicing:
array[::2]
and then summing them is as easy as:
sum(array[::2])
For more info about slicing see [here](http://pythoncentral.io/how-to-slice-listsarrays-and-tuples-in-
More
1. ‘sum’ is a python’s built-in keyword for, wait for it, summing :D You shouldn’t use variables with the same name.
2. You could have avoided line 10 if you did this on the previous line:
for i in range(0, len(array), 2):
3. Prettier version of line 11 is (I changed 'sum' to 'sum_' becau
More
if c == c.upper() and c != c.lower():
There's no need for both conditions. And usual way for checking this is:
if c.isupper():
More
'min' and 'max' are python's built-in functions and your variables shouldn't be named the same.
And when you use them as built-ins, your lines 4-11 can be replaced with:
return max(args) - min(args)
P.S. You don't need ; at the end of the lines.
More
You might want to learn about [bitwise operators](https://wiki.python.org/moin/BitwiseOperators), they would make your life easier here. (And there are some other task where you’ll find them useful)
More
You might want to learn about [bitwise operators](https://wiki.python.org/moin/BitwiseOperators), they would make your life easier here. (And there are some other task where you’ll find them useful)
More
You might want to learn about [bitwise operators](https://wiki.python.org/moin/BitwiseOperators), they would make your life easier here. (And there are some other task where you’ll find them useful)
More
You might want to learn about [bitwise operators](https://wiki.python.org/moin/BitwiseOperators), they would make your life easier here. (And there are some other task where you’ll find them useful)
More
(random review by mail test)
There's no need to create a list (by using "[" and "]") before joining.
More
1. ‘sum’ is a python’s built-in keyword for, wait for it, summing :D You shouldn’t use variables with the same name.
2. "array[len(array)-1]" is usually written as:
array[-1]
3. You could have avoided line 6 if you did this on the previous line:
for i in range(0, len(array), 2):
More