Created
June 26, 2009 19:51
-
-
Save benjamn/136693 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/env python | |
def count_down_up(max): | |
countdown = "-".join("x" * (max - i) for i in range(max)) + "-" | |
countup = "-".join("x" * i for i in range(1, max+1)) + "-" | |
overlaps = 0 | |
for i in range(min(len(countup), len(countup))): | |
if countdown[i] == "-" and countup[i] == "-": | |
overlaps += 1 | |
return overlaps, countdown, countup | |
from sys import argv | |
max = 0 | |
for i in range(1, int(argv[1])): | |
overlaps, countdown, countup = count_down_up(i) | |
if overlaps >= max: | |
max = overlaps | |
print "Overlapping %d time%s:" % (max, "s"[:int(max != 1)]) | |
print countdown | |
print countup | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment