Created
November 2, 2011 12:30
-
-
Save vvoody/1333503 to your computer and use it in GitHub Desktop.
find palindrome date
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/python | |
# -*- coding: utf-8 -*- | |
# find palindrome dates from today | |
# One date is same whatever you read it from left or right, | |
# like "20111102", "20200202"... we'll call it palindrome date. | |
import datetime | |
today = datetime.datetime.today() | |
oneday = datetime.timedelta(days=1) | |
while True: | |
left = "%s" % today.year | |
right = "%02d%02d" % (today.month, today.day) | |
if left == right[::-1]: | |
print "%s:%s" % (left, right) | |
today = today + oneday | |
# next a few dates: | |
#20200202 | |
#20211202 | |
#20300302 | |
#20400402 | |
#20500502 | |
#20600602 | |
#20700702 | |
#20800802 | |
#20900902 | |
#21100112 | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment