Phrogz schrieb: > On Jun 18, 11:42 am, Daniel Kempkens <Daniel.Kempk... / gmail.com> > wrote: >> Alex LeDonne schrieb: >>> On day 1, you get 1 gift. >>> On day 2, you get 3 gifts, not two (two doves AND one bird/tree combo). >>> On day 3, you get 6 gifts - 3 hens, 2 doves, one more pear tree >>> w/attendant partridge. > >> Well, I solved this for fun, my code looks like this: >> >> def gift_counter(max = 12) >> gifts = 0 >> 1.upto(max) do |day| >> gifts += day # I guess 'day' is a bad var-name here :D >> puts "Day: {#day}, Gifts: #{gifts}" >> end >> end >> >> It works quite good, so why does this Quiz-Site suggest to use two >> loops? Am I getting something of this quiz wrong? > > Does it work? It tells you how many gifts you GET on each day, but > does not tell you how many gifts you HAVE when the day is done. > > On day 1 you get 1 gift, resulting in 1 gift owned by you. > On day 2 you get 3 gifts, resulting in 4 gifts owned by you. > On day 3 you get 6 gifts, resulting in 10 gifts owned by you. > I think I missed the total-part of the quiz ;) But implementing a total-counter wouldn't be much difficult.