Last active
August 29, 2015 14:01
-
-
Save pidpawel/005191af5fce2a28ea1c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/python3 | |
hour_lambdas = [ | |
lambda h, m: h==m, | |
lambda h, m: len(set("%.2d%.2d" % (h,m))) == 1, | |
lambda h, m: "%.2d" % h == ("%.2d" % m)[::-1], | |
lambda h, m: h==13 and m==37, | |
lambda h, m: len(set("%.2d" % h)) == 1 and len(set("%.2d" % m)) == 1 | |
] | |
second_lambdas = [ | |
lambda h, m, s: h==m==s, | |
lambda h, m, s: len(set("%.2d%.2d%.2d" % (h,m,s))) == 1, | |
#lambda h, m, s: "%.2d" % h == ("%.2d" % m)[::-1] and s==h, | |
lambda h, m, s: h==3 and m==13 and s==37, | |
lambda h, m, s: ("%.2d:%.2d:%.2d" % (h,m,s)) == ("%.2d:%.2d:%.2d" % (h,m,s))[::-1], | |
lambda h, m, s: ("%.2d%.2d%.2d" % (h,m,s)) == ("%.2d%.2d%.2d" % (h,m,s))[::-1], | |
lambda h, m, s: len(set("%.2d" % h)) == 1 and len(set("%.2d" % m)) == 1 and len(set("%.2d" % s)) == 1 | |
] | |
def test_seconds(h, m, s): | |
for l in second_lambdas: | |
if l(h, m, s): | |
return "%.2d:%.2d:%.2d" % ( h, m, s ) | |
def test_hour(h, m): | |
for l in hour_lambdas: | |
if l(h, m): | |
return "%.2d:%.2d" % ( h, m ) | |
hour_results = [] | |
second_results =[] | |
for h in range(0,24): | |
for m in range(0, 60): | |
hr = test_hour(h, m) | |
if hr: | |
hour_results.append(hr) | |
for s in range(0, 60): | |
sr = test_seconds(h,m,s) | |
if sr: | |
second_results.append(sr) | |
print("\n".join(hour_results)) | |
print("\n".join(second_results)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment