Skip to content

Instantly share code, notes, and snippets.

@halexus
Created January 19, 2012 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halexus/1638626 to your computer and use it in GitHub Desktop.
Save halexus/1638626 to your computer and use it in GitHub Desktop.
One line solutions (without imports) in Python2 to Lambdaheads 2012-01-09 challenge https://metalab.at/wiki/Lambdaheads
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