-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse_age.py
More file actions
35 lines (24 loc) · 734 Bytes
/
Copy pathreverse_age.py
File metadata and controls
35 lines (24 loc) · 734 Bytes
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
#!/usr/bin/python3
def main():
ages = findAge()
print(ages)
def reverseNum(num):
num = str(num)
return int(num[::-1])
def findAge():
possibleAges = []
for num in range(10, 100):
if str(num)[0] > str(num)[1]:
possibleAges.append((num, reverseNum(num)))
for ageTuple in possibleAges:
countList = []
ageTupleDiff = ageTuple[0] - ageTuple[1]
for ageTuple1 in possibleAges:
ageTuple1Diff = ageTuple1[0] - ageTuple1[1]
if ageTupleDiff == ageTuple1Diff:
countList.append(ageTuple1)
if len(countList) > 6:
if ageTupleDiff > 20:
return countList
if __name__ == '__main__':
main()