18
Last seen 7 years ago
Member for 10 years, 9 months, 1 day
Difficulty Normal
\>>> r = ['012','345','678']
\>>> ["".join(r)[::e]for e in (4, -4)]+r+list(map("".join,zip(*r)))
['048', '840', '012', '345', '678', '036', '147', '258']
\# :'(
More
I think apostrophe(') in regex "[\w']+" should be excluded since the problem says 'words are separated by whitespaces and punctuation marks'.
More
Essentially same as my first solution, but a bit more compressed sacrificing readability.
More
I think this will take a lot of memory since it'll generate the whole list and then measure length. Maybe change this to instead? I think it'll take only O(1) memory.
sum(1 for d in range((to_date - from_date).days + 1)
if (from_date + timedelta(d)).weekday() in [5, 6])
More
Sorry to be a nitpicker but isn't this just a list of prime numbers in 1~10000? How is this a valid answer?
More