40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, you can use __frozenset__.
return ','.join(sorted(frozenset(a.split(',')) & frozenset(b.split(','))))
Edit: Or even __set__:
return ','.join(sorted(set(a.split(',')) & set(b.split(','))))
More
Hi, a bit shorter:
return sum((x[0]-1, x[1]-1) in b or (x[0]+1, x[1]-1) in b for x in b)
More
Hi, a lot of redundant variables. In fact you don't need `ma`, `mi` and `dif`.
More
Hi, you can remove number 3 and 5. `n` is redundant:
return number.count('1')
More
Hi, you can omit []. Your progress is visible :)
More
Hi,
Look at
1. extended slices e. g. `array[::2]`
2. negative slices e. g. `array[-1]`
3. _sum()_ built-in function.
More
Hi,
1. Line 3 is redundant.
2. You can nest method calls:
return ','.join(phrases).replace('right', 'left')
More
Hi,
1. Line 17 is redundant.
2. Instead of lines 13-17 you could write: `return c == 3`
More
Hi,
1. `round(float())`s are redundant.
2. You can handle the `len(args) == 0` case with `try..except` but there are more elegant ways.
More
Hi. A small note: Using dictionary instead of if .. elif .. else could save you some typing.
More
This solution is for demonstration purposes ([see](https://py.checkio.org/forum/post/10113/help-please/)).
More
Hi,
1. Instead of lines 10-14 you can write: `return sum(x[0]!=x[1] for x in zip(*(map(int, i) for i in (x, y))))`.
2. Look at `^` (alias `xor`) operator.
Regards,
Gabriel
More
Hi,
1. _issufix()_ is redundant see [_str.endswith()_](https://docs.python.org/3.5/library/stdtypes.html?highlight=str.endswith#str.endswith)
2. `is not` and `!=` don't do the same thing (look at [this](https://docs.python.org/3.5/library/stdtypes.html#comparisons))
3. Instead of:
if word1 is
More
Hi,
1. look at the _sum()_ builtin:
sum(int(digit) for digit in xnorm)
2. In fact, you just need to count the number of "1" in xnorm, therefore:
return bin(n^m).count('1')
More