exercism

Exercism solutions.
git clone git://code.dwrz.net/exercism
Log | Files | Refs

README.md (1167B)


      1 # Grains
      2 
      3 Calculate the number of grains of wheat on a chessboard given that the number
      4 on each square doubles.
      5 
      6 There once was a wise servant who saved the life of a prince. The king
      7 promised to pay whatever the servant could dream up. Knowing that the
      8 king loved chess, the servant told the king he would like to have grains
      9 of wheat. One grain on the first square of a chess board. Two grains on
     10 the next. Four on the third, and so on.
     11 
     12 There are 64 squares on a chessboard.
     13 
     14 Write code that shows:
     15 - how many grains were on each square, and
     16 - the total number of grains
     17 
     18 
     19 ## For bonus points
     20 
     21 Did you get the tests passing and the code clean? If you want to, these
     22 are some additional things you could try:
     23 
     24 - Optimize for speed.
     25 - Optimize for readability.
     26 
     27 Then please share your thoughts in a comment on the submission. Did this
     28 experiment make the code better? Worse? Did you learn anything from it?
     29 ## Source
     30 
     31 JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp)
     32 
     33 ## Submitting Incomplete Solutions
     34 It's possible to submit an incomplete solution so you can see how others have completed the exercise.