From 5f23329b41bb3e76ed82c10c02a459f2383c09d4 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com> Date: Wed, 8 May 2019 19:19:26 +0200 Subject: [PATCH 1/2] Prevent solutions that simply duplicate the alphabet --- .../rotational-cipher/test_rotational-cipher.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/exercises/rotational-cipher/test_rotational-cipher.R b/exercises/rotational-cipher/test_rotational-cipher.R index 0cebadc2..1e8e4b43 100644 --- a/exercises/rotational-cipher/test_rotational-cipher.R +++ b/exercises/rotational-cipher/test_rotational-cipher.R @@ -64,4 +64,18 @@ test_that("rotate all letters", { "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.") }) +test_that("rotate through the alphabet an arbitrary number of times", { + text <- "The quick brown fox jumps over the lazy dog." + key <- 13 + (123 * 26) + expect_equal(rotate(text, key), + "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.") +}) + +test_that("rotate backwards", { + text <- "The quick brown fox jumps over the lazy dog." + key <- 13 - (123 * 26) + expect_equal(rotate(text, key), + "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.") +}) + message("All tests passed for exercise: rotational-cipher") From 4f2d35b92ab788f1086fcaf3735452feddb5eac0 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com> Date: Wed, 8 May 2019 19:25:11 +0200 Subject: [PATCH 2/2] Update README.md --- exercises/rotational-cipher/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/rotational-cipher/README.md b/exercises/rotational-cipher/README.md index 76f0fcb0..66f5a3d9 100644 --- a/exercises/rotational-cipher/README.md +++ b/exercises/rotational-cipher/README.md @@ -4,7 +4,7 @@ Create an implementation of the rotational cipher, also sometimes called the Cae The Caesar cipher is a simple shift cipher that relies on transposing all the letters in the alphabet using an integer key -between `0` and `26`. Using a key of `0` or `26` will always yield +(both positive or negative). Using the same key will always yield the same output due to modular arithmetic. The letter is shifted for as many values as the value of the key. @@ -28,7 +28,9 @@ Ciphertext is written out in the same formatting as the input including spaces a - ROT0 `c` gives `c` - ROT26 `Cool` gives `Cool` - ROT13 `The quick brown fox jumps over the lazy dog.` gives `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.` +- ROT39 `The quick brown fox jumps over the lazy dog.` gives `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.` - ROT13 `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.` gives `The quick brown fox jumps over the lazy dog.` +- ROT-13 `Gur dhvpx oebja sbk whzcf bire gur ynml qbt.` gives `The quick brown fox jumps over the lazy dog.` ## Installation See [this guide](https://exercism.io/tracks/r/installation) for instructions on how to setup your local R environment.