57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 1 day ago
Member for 11 years, 6 months, 7 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
Wow! A surprisingly algebraic (for you) approach. :-D
One of those `image`s is really a `preimage`, right? :-) Also, `relation` deserves a better name. Though I don't know what it is. :-/ `precedes`?
`P[i] is a` is (PNI) a very risky thing to write. Those are one-letter strings, which are most pro
More
You're obsessed with lists. :-9 enumerate, .index, and a lot of other things work on many more data structures than lists.
And .index can receive additional parameters telling it where to start and stop checking.
And line 8 is really unnecessary. Much better is to enumerate the _reversed_ num.
Gi
More
Question category: sad. :-P
>>> print(*dir(a))
... days max microseconds min resolution seconds total_seconds
^^^^
Now any better? :-)
More
w(y,1+i,13)==4 for i in range(12)
same number of characters, but easier to read IMO. Of course, the true portable solution is
calendar.January + i
:-D
If you really want to have as few hits as possible, a month has Friday 13th iff it has Friday 6th. And 6 is shorter than 13. :-)
More
You don't need list in your parade of constructors. ;-)
BTW, without quotes is not really a restriction. Try without dots, for example. :-D
More
Not really puzzling if you know that str times negative is "", but still cool. :-)
More
Obligatory Youtube link: https://www.youtube.com/watch?v=o9pEzgHorH0 :-)
More
Line 6 can be improved in two ways: math.hypot instead of manual calculation, and round instead of int(...+0.5).
Double for in line 9 can be written using itertools.product. But not essential.
Line 12 is not pythonic. "if not data" (or even better: if data, and reversing branches) is much bett
More
Argh - there _is_ a number between 1 and 3 after all! :-D
And that is the number of thumbs you get. :-)
More
Please use `string.ascii_lowercase` instead of hardcoding. If you forget a letter, you'll notice it too late.
And cut out those parentheses.
And
a.find(b) < 0 ~~~> b not in a
Of course, the whole business can be written directly with `all`.
More
Don't ever index by index. You're separating your sequences that should be parallel, which is a maintenance horror. Python has dicts especially for that.
def boolean(x, y, op):
return dict(
conjunction = x and y,
disjunction = x or y,
implication = x
More
> #I think tihs is the only time my code is as long as Veky's one:)
You're [so](http://www.checkio.org/mission/funny-adding/publications/veky/python-3/o-rly/?ordering=most_voted) wrong. :-P
More
First, I know why you put line 7 in the loop, but it's not a valid reason. :-P Especially since then your try/except does nothing. :-] EAFP is cool, but you're doing it wrong.
Second, remove len(array) from []. Just array[-1] (or array[~0]).
Third, never iterate through indices when you need (only
More
It's not _so_ bad. I've seen much worse. :-D
You even use .index and sum and zip, though for some mysterious reason you _don't_ use builtin min. And why reversed?? Just convert >= to >. Of course, min does that for you automatically.
And your big problem is code duplication, of course. Factor that
More
Funny, this is exactly the same length:
safe_pawns=lambda p:sum(bool({chr(ord(c)+o)+chr(ord(r)-1)for o in(-1,1)}&p)for c,r in p)
More