aboutsummaryrefslogtreecommitdiff
path: root/challenge-048/user-person/python/ch-2.py
blob: bcf648a352ca36c488e12ca50d1d183f7f34bf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python

###########################################################################
# script name: ch-2.py                                                    #
#                                                                         #
# https://perlweeklychallenge.org/blog/perl-weekly-challenge-048/         #
#                                                                         #
# Palindrome Dates                                                        #
# Write a script to print all Palindrome Dates between 2000 and 2999.     #
# The format of date is mmddyyyy. For example, the first one was on       #
# October 2, 2001 as it is represented as 10022001.                       #
#                                                                         #
###########################################################################

#  M   M   D   D  Y   Y   Y   Y
# [01][*][012][2][2][012][*][01]
#   k  j   i          i   j   k
#
# k - Months can only begin with 0 or 1.
# j - The second months digit needs all numbers e.g. January 01 to October 10 (and of course beyond).
# i - Days begin with 0,1,2,3, However all years begin with 2 so the corresponding number
# means all days end in 2. 32 is not a valid day so the 3 is not needed.

for i in range(3):
    for j in range(10):
        for k in range(2):
            if (k == 1 and j > 2) or (k == 0 and j == 0):
                continue
            print(k,j,"-",i,"2-2",i,j,k,sep='')
            k += 1
        j += 1
    i += 1

# output:
#
# 10-02-2001
# 01-02-2010
# 11-02-2011
# 02-02-2020
# 12-02-2021
# 03-02-2030
# 04-02-2040
# 05-02-2050
# 06-02-2060
# 07-02-2070
# 08-02-2080
# 09-02-2090
# 10-12-2101
# 01-12-2110
# 11-12-2111
# 02-12-2120
# 12-12-2121
# 03-12-2130
# 04-12-2140
# 05-12-2150
# 06-12-2160
# 07-12-2170
# 08-12-2180
# 09-12-2190
# 10-22-2201
# 01-22-2210
# 11-22-2211
# 02-22-2220
# 12-22-2221
# 03-22-2230
# 04-22-2240
# 05-22-2250
# 06-22-2260
# 07-22-2270
# 08-22-2280
# 09-22-2290