-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The three rules of Ruby Quiz 2:

1.  Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have passed from the time on this message.

2.  Support Ruby Quiz 2 by submitting ideas as often as you can! (A
permanent, new website is in the works for Ruby Quiz 2. Until then,
please visit the temporary website at

     <http://splatbang.com/rubyquiz/>.

3.  Enjoy!

Suggestion:  A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion.  Please reply to
the original quiz message, if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

## Cookie Monster (#178)


_Quiz description provided by Lee Jarvis._


Cookie Monster is trying to walk through the Cookie Forest and consume
as many cookies as possible. However, there are many different paths
that Cookie Monster can take, and he isn't sure which way is the best
way. Help him eat as many cookies as possible by writing a program
which finds the optimal path from the upper left part of the forest to
the bottom right. Cookie Monster can only move south and east. There
are also several thorn patches through which he cannot cross. The
forest can be represented as a grid of numbers, where the number
represents the amount of cookies in that acre and -1 represents an
impassible thorn patch. An example forest is provided below:

     1  3  0  5 -1  7 -1 -1  0  4  2  1
    -1  3  2  1 -1  4 -1  5  3 -1  1  0
     5  4  8 -1  3  2  2 -1  4 -1  0  0
     2  1  0  4  1 -1  8  0  2 -1  2  5
     1  4  0  1 -1  0  3  2  2  4  1  4
     0  1  4  1  1  6  1  4  5  2  1  0
     3  2  5  2  0  7 -1  2  1  0 -1  3
     0 -1  4 -1 -1  3  5  1  4  2  1  2
     5  4  8 -1  3  2  2 -1  4 -1  0  0
     2  1  0  4  1 -1  8  0  2 -1  2  5
     1  3  0  5 -1  7 -1 -1  0  4  2  1
     0  0  3  1  5  2  1  5  4  1  3  3



-- 
Matthew Moss <matthew.moss / gmail.com>