Created
April 3, 2013 16:36
-
-
Save mhrivnak/5302891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
version_elements = [ | |
'1', | |
'12', | |
'1a', | |
'12abc3d4ef', | |
] | |
def foo(x, y): | |
if isint(x[-1]) != isint(y): | |
y = '.' + y | |
return x + y | |
def isint(n): | |
try: | |
int(n) | |
return True | |
except ValueError: | |
return False | |
for x in version_elements: | |
print reduce(foo, x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment