Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
One line solutions (without imports) in Python2 to Lambdaheads 2012-01-09 challenge
from itertools import permutations
print '|'.join([''.join(comb) for comb in set(list(permutations(("YYYY", "MM", "DD"))) + list(permutations(("YYYY", "MM", "DD"), 2)) + list(permutations(("YYYY", "MM", "DD"), 1)) + list(permutations(("YY", "MM", "DD"))) + list(permutations(("YY", "MM", "DD"), 2)) + list(permutations(("YY", "MM", "DD"), 1)))])
from itertools import permutations
print '|'.join(map(''.join, reduce(lambda x, y: x | y, [set(permutations(("YYYY", "MM", "DD"), i)) for i in range(1,4)] + [set(permutations(("YY", "MM", "DD"), i)) for i in range(1,4)])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment