Skip to content

Instantly share code, notes, and snippets.

@benjamn
Created June 26, 2009 19:51
Show Gist options
  • Save benjamn/136693 to your computer and use it in GitHub Desktop.
Save benjamn/136693 to your computer and use it in GitHub Desktop.
#!/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
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment