Created
June 25, 2012 14:39
-
-
Save coldnebo/2989054 to your computer and use it in GitHub Desktop.
a set of diophantine equations relating father and son...
This file contains 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
# Interesting relationships: | |
# Say the father's age is 72 and the son's age is 40. | |
# The father was born in 1940 and the son in 1972. | |
# Isn't that curious? | |
# In english, the dad's age is the current year minus the dad's birth year, | |
# the right-most 2 digits of the dad's birth year is the son's age, | |
# the son's age is the current year minus the son's birth year, | |
# and the right-most 2 digits of the son's birth year is the dad's age, | |
# and the son was born at least 12 years after the dad. | |
# Or in math form, the system of diophantine equations: | |
# D=T-D_0 \\ | |
# D_0 \pmod{100} = S \\ | |
# S = T-S_0 \\ | |
# S_0 \pmod{100} = D \\ | |
# S_0 > D_0 + 12 | |
time_range = (1900..2100) | |
son_years = time_range | |
dad_years = time_range | |
#time_range = (2012..2012) | |
time_range.each do |t| | |
dad_years.each do |dad_dob| | |
son_years.each do |son_dob| | |
next if son_dob < (dad_dob + 12) | |
dad_age = t - dad_dob | |
son_age = t - son_dob | |
if dad_dob.modulo(100) == son_age && son_dob.modulo(100) == dad_age | |
#puts "t=#{t}; dad_dob: #{dad_dob} (#{dad_age}), son_dob: #{son_dob} (#{son_age})" | |
puts "#{t},#{dad_dob},#{son_dob}" | |
end | |
end | |
end | |
end | |
# prints the possible solutions of this system over time, e.g. for this year: | |
# t=2012; dad_dob: 1913 (99), son_dob: 1999 (13) | |
# t=2012; dad_dob: 1914 (98), son_dob: 1998 (14) | |
# t=2012; dad_dob: 1915 (97), son_dob: 1997 (15) | |
# t=2012; dad_dob: 1916 (96), son_dob: 1996 (16) | |
# t=2012; dad_dob: 1917 (95), son_dob: 1995 (17) | |
# t=2012; dad_dob: 1918 (94), son_dob: 1994 (18) | |
# t=2012; dad_dob: 1919 (93), son_dob: 1993 (19) | |
# t=2012; dad_dob: 1920 (92), son_dob: 1992 (20) | |
# t=2012; dad_dob: 1921 (91), son_dob: 1991 (21) | |
# t=2012; dad_dob: 1922 (90), son_dob: 1990 (22) | |
# t=2012; dad_dob: 1923 (89), son_dob: 1989 (23) | |
# t=2012; dad_dob: 1924 (88), son_dob: 1988 (24) | |
# t=2012; dad_dob: 1925 (87), son_dob: 1987 (25) | |
# t=2012; dad_dob: 1926 (86), son_dob: 1986 (26) | |
# t=2012; dad_dob: 1927 (85), son_dob: 1985 (27) | |
# t=2012; dad_dob: 1928 (84), son_dob: 1984 (28) | |
# t=2012; dad_dob: 1929 (83), son_dob: 1983 (29) | |
# t=2012; dad_dob: 1930 (82), son_dob: 1982 (30) | |
# t=2012; dad_dob: 1931 (81), son_dob: 1981 (31) | |
# t=2012; dad_dob: 1932 (80), son_dob: 1980 (32) | |
# t=2012; dad_dob: 1933 (79), son_dob: 1979 (33) | |
# t=2012; dad_dob: 1934 (78), son_dob: 1978 (34) | |
# t=2012; dad_dob: 1935 (77), son_dob: 1977 (35) | |
# t=2012; dad_dob: 1936 (76), son_dob: 1976 (36) | |
# t=2012; dad_dob: 1937 (75), son_dob: 1975 (37) | |
# t=2012; dad_dob: 1938 (74), son_dob: 1974 (38) | |
# t=2012; dad_dob: 1939 (73), son_dob: 1973 (39) | |
# t=2012; dad_dob: 1940 (72), son_dob: 1972 (40) | |
# t=2012; dad_dob: 1941 (71), son_dob: 1971 (41) | |
# t=2012; dad_dob: 1942 (70), son_dob: 1970 (42) | |
# t=2012; dad_dob: 1943 (69), son_dob: 1969 (43) | |
# t=2012; dad_dob: 1944 (68), son_dob: 1968 (44) | |
# t=2012; dad_dob: 1945 (67), son_dob: 1967 (45) | |
# t=2012; dad_dob: 1946 (66), son_dob: 1966 (46) | |
# t=2012; dad_dob: 1947 (65), son_dob: 1965 (47) | |
# t=2012; dad_dob: 1948 (64), son_dob: 1964 (48) | |
# t=2012; dad_dob: 1949 (63), son_dob: 1963 (49) | |
# t=2012; dad_dob: 1950 (62), son_dob: 1962 (50) | |
# t=2012; dad_dob: 2000 (12), son_dob: 2012 (0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Graphical results are here: Results