Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Created March 11, 2022 19:59
Show Gist options
  • Save arthuralvim/5605d1451a69286b7205a8ff536e9de9 to your computer and use it in GitHub Desktop.
Save arthuralvim/5605d1451a69286b7205a8ff536e9de9 to your computer and use it in GitHub Desktop.
Somebody said that WWI was at 28/07/1914 (and that 28 + 07 + 19 +14 = 68) and WWII was at 01/09/1939 (and that 01 + 09 + 19 + 39 = 68)... and that the invasion of Ukraine was at 24/02/2022 (and that 24 + 02 + 20 + 22 = 68)...
# So... I took that as a challenge and displayed all dates that sums 68 from 1900 to 2088 (when I'm going to make 100 years).
# Be safe and avoid those dates. =P
from datetime import date
from datetime import timedelta
def sum_date(date):
date_str = date.strftime('%d %m %Y')
date_str = date_str[:8] + ' ' + date_str[8:]
return sum(map(int, date_str.split()))
start_date = date(1900, 1, 1)
end_date = date(2088, 1, 1)
delta = timedelta(days=1)
while start_date <= end_date:
if sum_date(start_date) == 68:
print(start_date.strftime("%d-%m-%Y"))
start_date += delta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment