Skip to content

Instantly share code, notes, and snippets.

@cronin101
Created August 7, 2012 14:20
Show Gist options
  • Select an option

  • Save cronin101/3285759 to your computer and use it in GitHub Desktop.

Select an option

Save cronin101/3285759 to your computer and use it in GitHub Desktop.
This is how many times Wen is allowed to celebrate before she dies.
1.9.3p194 :001 > SINGAPOREAN_FEMALE_LIFE_EXPECTANCY = 83 #http://en.wikipedia.org/wiki/List_of_countries_by_life_expectancy
=> 83
1.9.3p194 :002 > AGE_OF_WEN = 22
=> 22
1.9.3p194 :003 > years = (2012..2012+(SINGAPOREAN_FEMALE_LIFE_EXPECTANCY - AGE_OF_WEN))
=> 2012..2073
1.9.3p194 :004 > oly_years = years.find_all { |y| y.modulo(4).zero? }
=> [2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072]
1.9.3p194 :005 > (1..oly_years.size).inject { |total, game_num| total + 2**game_num }
=> 131069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment