# Assignment 2: Solving the Lazy Hobo Riddle

## Due Thursday, April 17, 6pm

This assignment is to write a Java application.

The following riddle dates back to the late 19th century (its revival is credited to Will Shortz, crossword puzzle editor of the New York Times).
There once were 4 hoboes traveling across the country.  During their journey, they ran short on funds, so they stopped at a farm to look for some work.  The farmer said there were 200 hours of work that could be done over the next several weeks.  The farmer went on to say that how they divided up the work was up to them.  The hoboes agreed to start the next day.  The following morning, one of the hoboes --- who was markedly smarter and lazier than the other 3 --- said there was no reason for them all to do the same amount of work.  This hobo went on to suggest the following scheme.  The hoboes would all draw straws.  A straw would be marked with a number.  The number would indicate both the number of days the drawer must work and the number of hours to be worked on each of those days.  For example, if the straw was marked with a 3, the hobo who drew it would work 3 hours a day for 3 days.  It goes without saying that the lazy hobo convinced the others to agree to this scheme and that through sleight of hand, the lazy hobo drew the best straw.  The riddle is to determine the possible ways to divide up the work according to the preceding scheme.
A solution to the riddle consists of 4 numbers a, b, c, and d such that a squared + b squared + c squared + d squared = 200.  So, what you need to do is to systematically generate combinations of 4 numbers, and check whether the current combination has the property that the squares of its numbers sum to 200.

Since the squares of numbers that are 15 or greater exceed 200, the only values that you need to consider for  a, b, c, and d occur in the interval [1, 14].  As there is no advantage to evaluate the same combination more than once, you should generate the combinations in a manner that eliminates duplicate combinations (e.g., {1,2,3,3} is the combination as {2,1,3,3}).  An easy way to ensure no duplication is to generate the combinations in ascending order.  As a result, each generated combination will have the property that  a <= b <=  c <= d .

To solve the riddle, consider the various possibilities for a in the interval [1, 14].  For a given value of a, consider all possibilities of  b, c, and d subject to the constraints discussed above.  In particular, the possibilities for b are [a, 14].  In a similar manner, given that a and b are fixed, consider all possibilities for c and d.  The possible values for c are [b, 14].  Once a, b, and c have been fixed, the possible values for d are [c, 14].

Your application's output should look like what appears between the horizontal rules:

Lazy hobo possible solutions:
1. 2 4 6 12
2. 6 6 8 8
End.

## Turn In Procedure

Email your Hobos.java file to cs10@cs.ucsb.edu. Emailing to the wrong address is not an acceptable reason for a late turn-in. Be sure to email your file while logged into your own account

Submit a hard copy of your Hobos.java file to the CS10 homework box.