README.md (2189B)
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 ## For bonus points 19 20 Did you get the tests passing and the code clean? If you want to, these 21 are some additional things you could try: 22 23 - Optimize for speed. 24 - Optimize for readability. 25 26 Then please share your thoughts in a comment on the submission. Did this 27 experiment make the code better? Worse? Did you learn anything from it? 28 29 ## Getting Started 30 31 Make sure you have read the "Guides" section of the 32 [C track](https://exercism.io/my/tracks/c) on the Exercism site. This covers 33 the basic information on setting up the development environment expected 34 by the exercises. 35 36 37 ## Passing the Tests 38 39 Get the first test compiling, linking and passing by following the [three 40 rules of test-driven development][3-tdd-rules]. 41 42 The included makefile can be used to create and run the tests using the `test` 43 task. 44 45 make test 46 47 Create just the functions you need to satisfy any compiler errors and get the 48 test to fail. Then write just enough code to get the test to pass. Once you've 49 done that, move onto the next test. 50 51 [3-tdd-rules]: http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd 52 53 As you progress through the tests, take the time to refactor your 54 implementation for readability and expressiveness and then go on to the next 55 test. 56 57 Try to use standard C99 facilities in preference to writing your own 58 low-level algorithms or facilities by hand. 59 60 ## Source 61 62 JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp) 63 64 ## Submitting Incomplete Solutions 65 It's possible to submit an incomplete solution so you can see how others have completed the exercise.