Sha256: ab90d040c476dc3fe01d48e5e1da2c8ec8d1459ec534abb4261c021287588be8

Contents?: true

Size: 1.92 KB

Versions: 74

Compression:

Stored size: 1.92 KB

Contents

# Grains

Calculate the number of grains of wheat on a chessboard given that the number
on each square doubles.

There once was a wise servant who saved the life of a prince. The king
promised to pay whatever the servant could dream up. Knowing that the
king loved chess, the servant told the king he would like to have grains
of wheat. One grain on the first square of a chess board. Two grains on
the next. Four on the third, and so on.

There are 64 squares on a chessboard.

Write code that shows:
- how many grains were on each square, and
- the total number of grains

## For bonus points

Did you get the tests passing and the code clean? If you want to, these
are some additional things you could try:

- Optimize for speed.
- Optimize for readability.

Then please share your thoughts in a comment on the submission. Did this
experiment make the code better? Worse? Did you learn anything from it?

## Installation
See [this guide](https://github.com/exercism/xr/blob/master/docs/INSTALLATION.md) for instructions on how to setup your local R environment.

## How to implement your solution
In each problem folder, there is a file named `<exercise_name>.R` containing a function that returns a `NULL` value. Place your implementation inside the body of the function.

## How to run tests
Inside of RStudio, simply execute the `test_<exercise_name>.R` script. This can be conveniently done with [testthat's `auto_test` function](https://www.rdocumentation.org/packages/testthat/topics/auto_test). Because exercism code and tests are in the same folder, use this same path for both  `code_path` and `test_path` parameters. On the command-line, you can also run `Rscript test_<exercise_name>.R`.

## Source

JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp)

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/r/exercises/grains/README.md
trackler-2.2.1.118 tracks/r/exercises/grains/README.md
trackler-2.2.1.117 tracks/r/exercises/grains/README.md
trackler-2.2.1.116 tracks/r/exercises/grains/README.md
trackler-2.2.1.115 tracks/r/exercises/grains/README.md
trackler-2.2.1.114 tracks/r/exercises/grains/README.md
trackler-2.2.1.113 tracks/r/exercises/grains/README.md
trackler-2.2.1.111 tracks/r/exercises/grains/README.md
trackler-2.2.1.110 tracks/r/exercises/grains/README.md
trackler-2.2.1.109 tracks/r/exercises/grains/README.md
trackler-2.2.1.108 tracks/r/exercises/grains/README.md
trackler-2.2.1.107 tracks/r/exercises/grains/README.md
trackler-2.2.1.106 tracks/r/exercises/grains/README.md
trackler-2.2.1.105 tracks/r/exercises/grains/README.md