Skip to content

Instantly share code, notes, and snippets.

@yatharth
Created June 11, 2015 13:03
Show Gist options
  • Save yatharth/a850cda4b48b765bc38d to your computer and use it in GitHub Desktop.
Save yatharth/a850cda4b48b765bc38d to your computer and use it in GitHub Desktop.
USACO: "One-lining because you can" edition
#!/usr/bin/env python3
import itertools as it
from collections import Counter
open('friday.out', 'w').write(
' '.join(
(str(value) for key, value in sorted(
Counter(
it.islice(
(x % 7 for x in
it.accumulate(
it.chain(
[2 + (13 - 1)],
map(
lambda months: (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)[months % 12] + (
1 if months % 12 == (2 - 1) and (months // 12) % (4 if (months // 12) % 100 != 0 else 400) == 0 else 0
),
it.count(1900 * 12)
)
)
)
),
int(open('friday.in').readline()) * 12
)
).items()
))
) + '\n'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment