Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.45 KB

README.md

File metadata and controls

51 lines (35 loc) · 1.45 KB

Project Euler in R

Dependencies

R packages (installed by calling install.packages('package-name'))

  • RUnit
  • gmp
  • sfsmisc

Running the tests

Rscript test.R

Directory/file structure

The directory structure is as follows:

docs/XXXX.md

docs/XXXX.md is a markdown file that contains the actual problem definition (from Project Euler) and any documentation I thought might be helpful for those looking at the code.

src/XXXX.R

src/XXXX.R must contain a function called problemX (problem1, problem99, etc.) that returns the desired result (i.e., the answer to the problem).

tests/XXXX.R

tests/XXXX.R is an R source file which must contain a function called test.problemX (test1, test99, etc.) that tests the result of the problemX function for correctness.

To have the test run as part of the RUnit test suite, this test must be added to the test suite in test.R in the root directory.

We have provided a function, test.wrapper, to encapsulate testing the correctness of the result and the time taken to get the result (Project Euler specifies that this should be less than one minute).

Further reading

RUnit

Check this out: Unit Testing in R: The Bare Minimum