40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, I've played... the result is [here](http://www.checkio.org/mission/end-of-other/publications/suic/python-3/spotys-shortened/).
More
Hi, you don't need the last if:
return second in friends[first] # is enough
More
Hi, I have some comments
1. _bin()_ returns __str__ so _str()_ is redundant.
2. Look at the _str.count()_ method.
More
Hi, you don't need the tuple:
more, less = max(args), min(args)
# and in fact you don't need more and less
return max(args) - min(args)
More
Hi, in this case you don't need lambda. You can import mul from operator or basically use int.\_\_mul\_\_:
return reduce(int.__mul__, [int(x) for x in str(number) if x!= '0'])
# another approach:
return reduce(int.__mul__, filter(None, map(int, str(number))))
More
Hi,
1. you don't need `[]` as _sum()_ accepts generator expressions.
2. you don't need _list()_ as _bin()_ returns __str__, which is iterable.
3. instead of _int()_, you could simply `sum(i == "1" ...)`.
4. in fact you don't need _sum()_ at all. Upon closer inspection, that `sum()` from no. 3. is s
More
Hi, __bool__ is subtype of __int__, so you don't need those nested ifs and inner functions. For example:
def equivalence(x, y):
return x == y
# or:
equivalence = lambda x, y: x == y
More
Hi,
1. Lambda is redundant. key expects a function and _abs_ is a function so:
2. List comprehension is redundant. Tuple is iterable.
sorted(number_array, key=abs) # That's it :)
More
Hi,
1. common = list() is redundant, on the line 8 you reassign the common.
2. You can use _sorted()_ instead of sort.
def checkio(first, second):
firstTkn = first.split(',')
secondTkn = second.split(',')
return ",".join(sorted(word for word in firstTkn if word in
More
Hi, I have a few comments:
1. No offense: biggest, smallest, ... cislo(?) Why not number?
2. Look at _min()_ and _max()_ function in Python. ([Built-in functions](https://docs.python.org/3.4/library/functions.html))
More
Hi,
1. instead of _in cisla_ you can use _str.isnumeric()_ or _str.isdigit()_. (See [this](https://docs.python.org/3.4/library/stdtypes.html#text-sequence-type-str))
2. _jeSlovo_ is a predicate, so you can/should use True/False instead of 1/0.
3. Line 12 you can write this way: pocetSlov += 1
More
Hi, I have two comments:
1. Don't use _sum_ as variable name. _sum()_ is a useful built-in function.
2. Look at negative and extended slices in Python:
# For non-empty array:
array[::2] # even indexes
sum(array[::2]) # sum of even in
More
Hi, using _str.join()_ with generator expression or _filter()_ would be more efficient. Consider the fact that in python __str__ is immutable.
More