13
Andrey Makarov
Last seen 2 years ago
Member for 9 years, 4 months, 23 days
Difficulty Normal
One-liners are WET!
wow, that's short. I took a long way of matrix rotation (as i understand it) to get diagonals https://pp.vk.me/c623930/v623930561/18ff7/wPgt0vP4oWY.jpg
More
`"exclusive"` can be implemented simpler: `int(x!=y)` http://stackoverflow.com/a/433161/1119602
P.S. built-in `operator` module has all needed operations except for implication
More
completely forgot about zip functionality and....)
map(lambda *a: a, *matrix)
More
oh. I always thought that fors in list comprehension run vice versa.) How did i manage to write any program??)
Very tricky solution, imho
More
Under Win7:
> unknown specifier: ?P.
It's ok? And what's a group 'whole'? I don't see its definition
More
I like `sum(array[::2])`, me myself used `enumerate`
What about using `array[-1]` to get the last element?)
More
It's mentioned in task that input is a `sequence of strings as a tuple`.
Ur solution solves a broader task.))
More
u can iterate directly through items (at least in the inner loop) `for sequence_j in sequence[i+1:]:`
Outer loop would need `enumerate` in that case
More
like your set-based approach.) i think it's a little faster to just check whether `set` is empty:
`not set(string.ascii_lowercase)-set(text.lower())`
More
`date1` and `date2` contain `datetime.date` arguments in the right order so you could use an asterisk to ask Python to "unpack" them: `d1 = datetime.date(*date1)`
https://docs.python.org/3.4/reference/expressions.html#calls
More
you could use `count+=number&1` instead of `if number%2:`.
one-liner:) `sum((n>>i)&1 for i in range(math.floor(math.log(n, 2)+1))) if n else 0`
More
inner loop is not needed. You could use `if r1 in y:` instead. Or better use sets `set(x)&set(y)`
More
`if x in y:` is a good way to avoid inner loop. Using `set(a)&set(b)` can help to avoid outer loop too.))
More
i == j and not m[i][j]
is it a check for zero on diagonal? The condition
m[i][j] == -m[j][i]
already checks this. Also
for i in xrange(len(m)) for j in xrange(len(m))
makes double checks of the same cells
More