Skip to content

Instantly share code, notes, and snippets.

@mcroydon
Created July 3, 2009 14:30
Show Gist options
  • Save mcroydon/140138 to your computer and use it in GitHub Desktop.
Save mcroydon/140138 to your computer and use it in GitHub Desktop.
# Calculate the years between 1900 and 2100 in which July 4th falls on a Saturday
import datetime
for year in range(1900,2101):
dt = datetime.datetime(year, 7, 4)
if dt.strftime('%w') == '6':
print year ,
# Yields 1903 1908 1914 1925 1931 1936 1942 1953 1959 1964 1970 1981 1987 1992 1998
# 2009 2015 2020 2026 2037 2043 2048 2054 2065 2071 2076 2082 2093 2099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment