Am 28.03.2013 21:48, schrieb John W Higgins:
>
>
> On Thu, Mar 28, 2013 at 1:17 PM, Phil H. <lists / ruby-forum.com
> <mailto:lists / ruby-forum.com>> wrote:
>
>     This one is stumping me because of all the variables needed. Only thing
>     taught before this challenge was basic branches and loops. This is what
>     I have so far.
>
>     puts 'Leap Year Calculator'
>     puts ' '
>     puts 'Enter the starting year.'
>     starting_year = gets.chomp
>     puts 'Enter the ending year.'
>     ending_year = gets.chomp
>
>
> The rest doesn't work at all because if you put something like 2096-2104
> you would print out 2096, 2100 which is incorrect in two ways
>
> 1) 2100 isn't a leap year
> 2) 2104 should be printed and your second while clause precludes that
>
> You shouldn't be worrying about the starting year as much as you are -
> you need to handle every leap year in the same fashion
>
> So lets try something like this
>
> leap_year = starting_year + starting_year % 4 #set yourself onto a
> possible leap year to start with

does not work:

(1..12).each {|year| puts year + year % 4 }
2
4
6
4
6
8
10
8
10
12
14
12


-- 
<https://github.com/stomar/>