trackler 2.2.0.0 → 2.2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/CONTRIBUTING.md +1 -1
- data/tracks/bash/.travis.yml +1 -1
- data/tracks/bash/config.json +30 -3
- data/tracks/c/README.md +1 -1
- data/tracks/c/config.json +131 -39
- data/tracks/ceylon/README.md +6 -6
- data/tracks/ceylon/config.json +21 -3
- data/tracks/chapel/.travis.yml +1 -1
- data/tracks/clojurescript/.travis.yml +1 -1
- data/tracks/clojurescript/README.md +6 -6
- data/tracks/clojurescript/exercises/.keep +0 -0
- data/tracks/coffeescript/.travis.yml +1 -1
- data/tracks/coldfusion/.travis.yml +1 -1
- data/tracks/coq/.travis.yml +1 -1
- data/tracks/cpp/CMakeLists.txt +1 -0
- data/tracks/cpp/README.md +1 -1
- data/tracks/cpp/config.json +8 -0
- data/tracks/cpp/exercises/atbash-cipher/CMakeLists.txt +52 -0
- data/tracks/cpp/exercises/atbash-cipher/atbash_cipher_test.cpp +68 -0
- data/tracks/cpp/exercises/atbash-cipher/example.cpp +54 -0
- data/tracks/cpp/exercises/atbash-cipher/example.h +13 -0
- data/tracks/csharp/config.json +315 -6
- data/tracks/d/.travis.yml +1 -1
- data/tracks/dart/README.md +2 -2
- data/tracks/dart/config.json +21 -3
- data/tracks/delphi/README.md +1 -1
- data/tracks/delphi/config.json +83 -1
- data/tracks/ecmascript/config.json +10 -0
- data/tracks/ecmascript/exercises/accumulate/accumulate.spec.js +3 -9
- data/tracks/ecmascript/exercises/acronym/acronym.spec.js +2 -2
- data/tracks/ecmascript/exercises/all-your-base/all-your-base.spec.js +131 -133
- data/tracks/ecmascript/exercises/all-your-base/example.js +1 -3
- data/tracks/ecmascript/exercises/allergies/allergies.spec.js +8 -10
- data/tracks/ecmascript/exercises/allergies/example.js +3 -5
- data/tracks/ecmascript/exercises/alphametics/alphametics.spec.js +61 -63
- data/tracks/ecmascript/exercises/alphametics/example.js +99 -99
- data/tracks/ecmascript/exercises/anagram/anagram.spec.js +35 -37
- data/tracks/ecmascript/exercises/anagram/example.js +1 -3
- data/tracks/ecmascript/exercises/atbash-cipher/atbash-cipher.spec.js +1 -3
- data/tracks/ecmascript/exercises/atbash-cipher/example.js +3 -3
- data/tracks/ecmascript/exercises/beer-song/beer-song.spec.js +0 -2
- data/tracks/ecmascript/exercises/beer-song/example.js +9 -9
- data/tracks/ecmascript/exercises/binary/binary.spec.js +1 -2
- data/tracks/ecmascript/exercises/binary/example.js +3 -3
- data/tracks/ecmascript/exercises/binary-search/binary-search.spec.js +1 -3
- data/tracks/ecmascript/exercises/binary-search-tree/binary-search-tree.spec.js +13 -15
- data/tracks/ecmascript/exercises/binary-search-tree/example.js +2 -2
- data/tracks/ecmascript/exercises/bob/bob.spec.js +1 -3
- data/tracks/ecmascript/exercises/bob/example.js +3 -3
- data/tracks/ecmascript/exercises/bracket-push/example.js +2 -2
- data/tracks/ecmascript/exercises/circular-buffer/circular-buffer.spec.js +10 -12
- data/tracks/ecmascript/exercises/circular-buffer/example.js +12 -11
- data/tracks/ecmascript/exercises/clock/clock.spec.js +0 -8
- data/tracks/ecmascript/exercises/clock/example.js +11 -11
- data/tracks/ecmascript/exercises/connect/connect.spec.js +75 -77
- data/tracks/ecmascript/exercises/connect/example.js +27 -29
- data/tracks/ecmascript/exercises/crypto-square/crypto-square.spec.js +11 -11
- data/tracks/ecmascript/exercises/crypto-square/example.js +11 -10
- data/tracks/ecmascript/exercises/custom-set/custom-set.spec.js +2 -4
- data/tracks/ecmascript/exercises/custom-set/example.js +1 -1
- data/tracks/ecmascript/exercises/diamond/diamond.spec.js +20 -21
- data/tracks/ecmascript/exercises/diamond/example.js +12 -13
- data/tracks/ecmascript/exercises/difference-of-squares/difference-of-squares.spec.js +0 -5
- data/tracks/ecmascript/exercises/diffie-hellman/diffie-hellman.spec.js +7 -28
- data/tracks/ecmascript/exercises/etl/etl.spec.js +36 -18
- data/tracks/ecmascript/exercises/etl/example.js +3 -3
- data/tracks/ecmascript/exercises/flatten-array/example.js +1 -1
- data/tracks/ecmascript/exercises/flatten-array/flatten-array.spec.js +2 -3
- data/tracks/ecmascript/exercises/food-chain/example.js +12 -12
- data/tracks/ecmascript/exercises/food-chain/food-chain.spec.js +0 -1
- data/tracks/ecmascript/exercises/gigasecond/example.js +1 -1
- data/tracks/ecmascript/exercises/gigasecond/gigasecond.spec.js +0 -1
- data/tracks/ecmascript/exercises/grade-school/grade-school.spec.js +18 -19
- data/tracks/ecmascript/exercises/grains/grains.spec.js +0 -1
- data/tracks/ecmascript/exercises/hamming/example.js +3 -3
- data/tracks/ecmascript/exercises/hamming/hamming.spec.js +5 -6
- data/tracks/ecmascript/exercises/hello-world/example.js +1 -1
- data/tracks/ecmascript/exercises/hello-world/hello-world.spec.js +1 -1
- data/tracks/ecmascript/exercises/hexadecimal/example.js +2 -2
- data/tracks/ecmascript/exercises/hexadecimal/hexadecimal.spec.js +9 -11
- data/tracks/ecmascript/exercises/isogram/isogram.spec.js +22 -23
- data/tracks/ecmascript/exercises/kindergarten-garden/example.js +7 -7
- data/tracks/ecmascript/exercises/kindergarten-garden/kindergarten-garden.spec.js +0 -5
- data/tracks/ecmascript/exercises/largest-series-product/example.js +4 -8
- data/tracks/ecmascript/exercises/largest-series-product/largest-series-product.spec.js +5 -7
- data/tracks/ecmascript/exercises/leap/leap.spec.js +4 -6
- data/tracks/ecmascript/exercises/linked-list/example.js +2 -2
- data/tracks/ecmascript/exercises/list-ops/example.js +19 -19
- data/tracks/ecmascript/exercises/list-ops/list-ops.spec.js +2 -18
- data/tracks/ecmascript/exercises/luhn/example.js +1 -1
- data/tracks/ecmascript/exercises/luhn/luhn.spec.js +1 -3
- data/tracks/ecmascript/exercises/matrix/example.js +2 -4
- data/tracks/ecmascript/exercises/matrix/matrix.spec.js +0 -2
- data/tracks/ecmascript/exercises/meetup/example.js +12 -15
- data/tracks/ecmascript/exercises/meetup/meetup.spec.js +0 -2
- data/tracks/ecmascript/exercises/minesweeper/example.js +60 -0
- data/tracks/ecmascript/exercises/minesweeper/minesweeper.spec.js +174 -0
- data/tracks/ecmascript/exercises/minesweeper/package.json +69 -0
- data/tracks/ecmascript/exercises/nth-prime/example.js +3 -2
- data/tracks/ecmascript/exercises/nth-prime/nth-prime.spec.js +0 -1
- data/tracks/ecmascript/exercises/ocr-numbers/example.js +3 -3
- data/tracks/ecmascript/exercises/ocr-numbers/ocr-numbers.spec.js +16 -18
- data/tracks/ecmascript/exercises/octal/example.js +1 -1
- data/tracks/ecmascript/exercises/octal/octal.spec.js +0 -2
- data/tracks/ecmascript/exercises/palindrome-products/example.js +14 -11
- data/tracks/ecmascript/exercises/palindrome-products/palindrome-products.spec.js +15 -18
- data/tracks/ecmascript/exercises/pangram/example.js +6 -5
- data/tracks/ecmascript/exercises/pangram/pangram.spec.js +10 -12
- data/tracks/ecmascript/exercises/pascals-triangle/example.js +2 -2
- data/tracks/ecmascript/exercises/pascals-triangle/pascals-triangle.spec.js +6 -8
- data/tracks/ecmascript/exercises/perfect-numbers/example.js +3 -5
- data/tracks/ecmascript/exercises/perfect-numbers/perfect-numbers.spec.js +0 -10
- data/tracks/ecmascript/exercises/phone-number/example.js +2 -2
- data/tracks/ecmascript/exercises/phone-number/phone-number.spec.js +0 -2
- data/tracks/ecmascript/exercises/pig-latin/example.js +4 -4
- data/tracks/ecmascript/exercises/pig-latin/pig-latin.spec.js +0 -1
- data/tracks/ecmascript/exercises/prime-factors/example.js +2 -2
- data/tracks/ecmascript/exercises/prime-factors/prime-factors.spec.js +0 -2
- data/tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js +3 -11
- data/tracks/ecmascript/exercises/queen-attack/example.js +17 -17
- data/tracks/ecmascript/exercises/queen-attack/queen-attack.spec.js +7 -8
- data/tracks/ecmascript/exercises/raindrops/example.js +1 -1
- data/tracks/ecmascript/exercises/raindrops/raindrops.spec.js +1 -2
- data/tracks/ecmascript/exercises/rna-transcription/example.js +5 -5
- data/tracks/ecmascript/exercises/rna-transcription/rna-transcription.spec.js +4 -5
- data/tracks/ecmascript/exercises/robot-name/example.js +6 -6
- data/tracks/ecmascript/exercises/robot-name/robot-name.spec.js +10 -11
- data/tracks/ecmascript/exercises/robot-simulator/example.js +1 -1
- data/tracks/ecmascript/exercises/robot-simulator/robot-simulator.spec.js +31 -32
- data/tracks/ecmascript/exercises/roman-numerals/example.js +16 -16
- data/tracks/ecmascript/exercises/saddle-points/saddle-points.spec.js +3 -3
- data/tracks/ecmascript/exercises/say/example.js +25 -25
- data/tracks/ecmascript/exercises/say/say.spec.js +2 -3
- data/tracks/ecmascript/exercises/scrabble-score/example.js +27 -9
- data/tracks/ecmascript/exercises/scrabble-score/scrabble-score.spec.js +6 -7
- data/tracks/ecmascript/exercises/secret-handshake/example.js +2 -3
- data/tracks/ecmascript/exercises/secret-handshake/secret-handshake.spec.js +3 -5
- data/tracks/ecmascript/exercises/series/series.spec.js +1 -3
- data/tracks/ecmascript/exercises/sieve/example.js +4 -3
- data/tracks/ecmascript/exercises/sieve/sieve.spec.js +0 -2
- data/tracks/ecmascript/exercises/simple-cipher/example.js +8 -9
- data/tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js +4 -4
- data/tracks/ecmascript/exercises/space-age/example.js +1 -1
- data/tracks/ecmascript/exercises/space-age/space-age.spec.js +9 -11
- data/tracks/ecmascript/exercises/strain/example.js +4 -4
- data/tracks/ecmascript/exercises/strain/strain.spec.js +14 -16
- data/tracks/ecmascript/exercises/sum-of-multiples/example.js +4 -4
- data/tracks/ecmascript/exercises/triangle/triangle.spec.js +2 -4
- data/tracks/ecmascript/exercises/trinary/example.js +3 -3
- data/tracks/ecmascript/exercises/trinary/trinary.spec.js +0 -2
- data/tracks/ecmascript/exercises/two-bucket/example.js +30 -27
- data/tracks/ecmascript/exercises/two-bucket/two-bucket.spec.js +4 -8
- data/tracks/ecmascript/exercises/word-count/example.js +2 -2
- data/tracks/ecmascript/exercises/word-count/word-count.spec.js +2 -3
- data/tracks/ecmascript/exercises/wordy/example.js +6 -6
- data/tracks/ecmascript/exercises/wordy/wordy.spec.js +2 -4
- data/tracks/factor/config.json +15 -6
- data/tracks/fortran/.travis.yml +1 -1
- data/tracks/fsharp/config.json +312 -10
- data/tracks/go/README.md +1 -1
- data/tracks/go/config.json +523 -155
- data/tracks/haskell/README.md +2 -2
- data/tracks/haskell/config.json +256 -7
- data/tracks/haxe/.travis.yml +1 -1
- data/tracks/haxe/Makefile +2 -2
- data/tracks/haxe/config.json +8 -5
- data/tracks/java/CONTRIBUTING.md +2 -2
- data/tracks/java/config.json +277 -17
- data/tracks/java/exercises/rotational-cipher/build.gradle +17 -0
- data/tracks/java/exercises/rotational-cipher/src/example/java/RotationalCipher.java +37 -0
- data/tracks/java/exercises/rotational-cipher/src/main/java/.keep +0 -0
- data/tracks/java/exercises/rotational-cipher/src/test/java/RotationalCipherTest.java +81 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/twelve-days/src/main/java/TwelveDays.java +4 -0
- data/tracks/julia/.travis.yml +1 -1
- data/tracks/julia/README.md +1 -1
- data/tracks/kotlin/README.md +2 -2
- data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +3 -3
- data/tracks/lisp/config.json +97 -3
- data/tracks/lisp/exercises/pascals-triangle/example.lisp +21 -0
- data/tracks/lisp/exercises/pascals-triangle/pascal.lisp +7 -0
- data/tracks/lisp/exercises/pascals-triangle/pascals-triangle-test.lisp +34 -0
- data/tracks/lua/.travis.yml +1 -1
- data/tracks/lua/README.md +1 -1
- data/tracks/mips/.travis.yml +1 -1
- data/tracks/mips/config.json +56 -17
- data/tracks/nasm/.travis.yml +1 -1
- data/tracks/nim/.travis.yml +1 -1
- data/tracks/ocaml/README.md +3 -3
- data/tracks/ocaml/config.json +130 -4
- data/tracks/perl5/docs/TESTS.md +40 -26
- data/tracks/plsql/.travis.yml +1 -1
- data/tracks/plsql/config.json +40 -13
- data/tracks/pony/.travis.yml +1 -1
- data/tracks/pony/bin/install-deps +4 -3
- data/tracks/prolog/.travis.yml +1 -1
- data/tracks/r/README.md +5 -5
- data/tracks/r/config.json +102 -30
- data/tracks/rust/.travis.yml +1 -1
- data/tracks/rust/config.json +172 -4
- data/tracks/rust/docs/EXERCISE_README_INSERT.md +1 -1
- data/tracks/sml/config.json +26 -3
- data/tracks/vimscript/config.json +60 -3
- metadata +16 -1
data/tracks/ceylon/config.json
CHANGED
@@ -5,14 +5,20 @@
|
|
5
5
|
"active": false,
|
6
6
|
"exercises": [
|
7
7
|
{
|
8
|
+
"uuid": "9ae32021-a7c3-4ddf-88b1-629b708b9cb9",
|
8
9
|
"slug": "leap",
|
10
|
+
"core": false,
|
11
|
+
"unlocked_by": null,
|
9
12
|
"difficulty": 1,
|
10
13
|
"topics": [
|
11
14
|
"Integers"
|
12
15
|
]
|
13
16
|
},
|
14
17
|
{
|
18
|
+
"uuid": "a93dbf6e-c65d-4793-9407-f8187abd0ad7",
|
15
19
|
"slug": "hamming",
|
20
|
+
"core": false,
|
21
|
+
"unlocked_by": null,
|
16
22
|
"difficulty": 2,
|
17
23
|
"topics": [
|
18
24
|
"Strings",
|
@@ -20,7 +26,10 @@
|
|
20
26
|
]
|
21
27
|
},
|
22
28
|
{
|
29
|
+
"uuid": "bc986de4-f76f-4435-b7aa-08e561693c49",
|
23
30
|
"slug": "sieve",
|
31
|
+
"core": false,
|
32
|
+
"unlocked_by": null,
|
24
33
|
"difficulty": 3,
|
25
34
|
"topics": [
|
26
35
|
"Filtering",
|
@@ -28,7 +37,10 @@
|
|
28
37
|
]
|
29
38
|
},
|
30
39
|
{
|
40
|
+
"uuid": "fe43a5a0-9f83-45ab-af37-76f8a3e84393",
|
31
41
|
"slug": "anagram",
|
42
|
+
"core": false,
|
43
|
+
"unlocked_by": null,
|
32
44
|
"difficulty": 4,
|
33
45
|
"topics": [
|
34
46
|
"Strings",
|
@@ -36,7 +48,10 @@
|
|
36
48
|
]
|
37
49
|
},
|
38
50
|
{
|
51
|
+
"uuid": "0112a648-dca1-425d-9c1c-67fc6e6247a7",
|
39
52
|
"slug": "largest-series-product",
|
53
|
+
"core": false,
|
54
|
+
"unlocked_by": null,
|
40
55
|
"difficulty": 4,
|
41
56
|
"topics": [
|
42
57
|
"Strings",
|
@@ -45,7 +60,10 @@
|
|
45
60
|
]
|
46
61
|
},
|
47
62
|
{
|
63
|
+
"uuid": "6b95f859-3395-4936-bbc3-601041b6744b",
|
48
64
|
"slug": "bracket-push",
|
65
|
+
"core": false,
|
66
|
+
"unlocked_by": null,
|
49
67
|
"difficulty": 6,
|
50
68
|
"topics": [
|
51
69
|
"Parsing",
|
@@ -54,7 +72,10 @@
|
|
54
72
|
]
|
55
73
|
},
|
56
74
|
{
|
75
|
+
"uuid": "94e3684c-3646-42ea-909c-c1f9daab552a",
|
57
76
|
"slug": "react",
|
77
|
+
"core": false,
|
78
|
+
"unlocked_by": null,
|
58
79
|
"difficulty": 10,
|
59
80
|
"topics": [
|
60
81
|
"Reactive programming",
|
@@ -64,9 +85,6 @@
|
|
64
85
|
"Callable"
|
65
86
|
]
|
66
87
|
}
|
67
|
-
],
|
68
|
-
"deprecated": [
|
69
|
-
|
70
88
|
],
|
71
89
|
"foregone": [
|
72
90
|
|
data/tracks/chapel/.travis.yml
CHANGED
@@ -12,11 +12,11 @@ The simplest way to install ClojureScript is ...
|
|
12
12
|
|
13
13
|
Thank you so much for contributing! :tada:
|
14
14
|
|
15
|
-
Please start by reading how to [get involved in a track](https://github.com/exercism/exercism.io/blob/master/docs/getting-involved-in-a-track.md). Comprehensive details on contributing can be found [here](https://github.com/exercism/
|
15
|
+
Please start by reading how to [get involved in a track](https://github.com/exercism/exercism.io/blob/master/docs/getting-involved-in-a-track.md). Comprehensive details on contributing can be found [here](https://github.com/exercism/problem-specifications/blob/master/CONTRIBUTING.md). Be sure to read the Exercism [Code of Conduct](https://github.com/exercism/exercism.io/blob/master/CODE_OF_CONDUCT.md).
|
16
16
|
|
17
17
|
We welcome pull requests of all kinds. No contribution is too small.
|
18
18
|
|
19
|
-
We encourage contributions that provide fixes and improvements to existing exercises. Please note that this track's exercises must conform to the standards determined in the [exercism/
|
19
|
+
We encourage contributions that provide fixes and improvements to existing exercises. Please note that this track's exercises must conform to the standards determined in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repo. Changes to the tests or documentation of a common exercise will often warrant a PR in that repo before it can be incorporated into this track's exercises. If you're unsure, then go ahead and open a GitHub issue, and we'll discuss the change.
|
20
20
|
|
21
21
|
## Exercise Tests ##
|
22
22
|
|
@@ -53,20 +53,20 @@ Please keep the following in mind:
|
|
53
53
|
|
54
54
|
## Contributing a New Exercise ##
|
55
55
|
|
56
|
-
- All Exercism exercises must be defined in [
|
56
|
+
- All Exercism exercises must be defined in [problem-specifications](https://github.com/exercism/problem-specifications/tree/master/exercises) before they are implemented for a specific track. Please submit a PR there if your exercise is new to Exercism.
|
57
57
|
|
58
|
-
- Please make sure the new exercise conforms to specifications in the [exercism/
|
58
|
+
- Please make sure the new exercise conforms to specifications in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repo.
|
59
59
|
|
60
60
|
- Each exercise must stand on its own. Do not reference files outside the exercise directory. They will not be included when the user fetches the exercise.
|
61
61
|
|
62
62
|
- Exercises should use only the ClojureScript core libraries.
|
63
63
|
|
64
64
|
- Please do not add a README or README.md file to the exercise directory. The READMEs are constructed using shared metadata, which lives in the
|
65
|
-
[exercism/
|
65
|
+
[exercism/problem-specifications](https://github.com/exercism/problem-specifications) repository. Further explanation can be found in [fixing-exercise-readmes](https://github.com/exercism/docs/blob/master/language-tracks/exercises/anatomy/readmes.md).
|
66
66
|
|
67
67
|
- Each exercise should have a test suite, an example solution, a template file for the real implementation and ... (anything else that needs to go with each exercise for this track). The CI build expects files to be named using the following convention: (describe the ClojureScript convention for naming the various files that make up an exercise).
|
68
68
|
|
69
69
|
- Please do not commit any configuration files or directories inside the exercise other than ...
|
70
70
|
|
71
|
-
- Be sure to add it to the appropriate place in the `config.json` file. Also, please run `bin/fetch-configlet && bin/configlet
|
71
|
+
- Be sure to add it to the appropriate place in the `config.json` file. Also, please run `bin/fetch-configlet && bin/configlet lint .` to ensure the exercise is configured correctly.
|
72
72
|
|
File without changes
|
data/tracks/coq/.travis.yml
CHANGED
data/tracks/cpp/CMakeLists.txt
CHANGED
data/tracks/cpp/README.md
CHANGED
@@ -6,5 +6,5 @@ Exercism Exercises in C++
|
|
6
6
|
|
7
7
|
## Contributing Guide
|
8
8
|
|
9
|
-
Please see the [contributing guide](https://github.com/exercism/
|
9
|
+
Please see the [contributing guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md)
|
10
10
|
|
data/tracks/cpp/config.json
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Get the exercise name from the current directory
|
2
|
+
get_filename_component(exercise ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
3
|
+
|
4
|
+
# Basic CMake project
|
5
|
+
cmake_minimum_required(VERSION 2.8.11)
|
6
|
+
|
7
|
+
# Name the project after the exercise
|
8
|
+
project(${exercise} CXX)
|
9
|
+
|
10
|
+
# Locate Boost libraries: unit_test_framework, date_time and regex
|
11
|
+
set(Boost_USE_STATIC_LIBS ON)
|
12
|
+
set(Boost_USE_MULTITHREADED ON)
|
13
|
+
set(Boost_USE_STATIC_RUNTIME OFF)
|
14
|
+
find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework date_time regex)
|
15
|
+
|
16
|
+
# Enable C++11 features on gcc/clang
|
17
|
+
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
|
18
|
+
set(CMAKE_CXX_FLAGS "-std=c++11")
|
19
|
+
endif()
|
20
|
+
|
21
|
+
# Configure to run all the tests?
|
22
|
+
if(${EXERCISM_RUN_ALL_TESTS})
|
23
|
+
add_definitions(-DEXERCISM_RUN_ALL_TESTS)
|
24
|
+
endif()
|
25
|
+
|
26
|
+
# Get a source filename from the exercise name by replacing -'s with _'s
|
27
|
+
string(REPLACE "-" "_" file ${exercise})
|
28
|
+
|
29
|
+
# Implementation could be only a header
|
30
|
+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.cpp)
|
31
|
+
set(exercise_cpp ${file}.cpp)
|
32
|
+
else()
|
33
|
+
set(exercise_cpp "")
|
34
|
+
endif()
|
35
|
+
|
36
|
+
# Build executable from sources and headers
|
37
|
+
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
|
38
|
+
|
39
|
+
# We need boost includes
|
40
|
+
target_include_directories(${exercise} PRIVATE ${Boost_INCLUDE_DIRS})
|
41
|
+
|
42
|
+
# We need boost libraries
|
43
|
+
target_link_libraries(${exercise} ${Boost_LIBRARIES})
|
44
|
+
|
45
|
+
# Tell MSVC not to warn us about unchecked iterators in debug builds
|
46
|
+
if(${MSVC})
|
47
|
+
set_target_properties(${exercise} PROPERTIES
|
48
|
+
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS)
|
49
|
+
endif()
|
50
|
+
|
51
|
+
# Run the tests on every build
|
52
|
+
add_custom_command(TARGET ${exercise} POST_BUILD COMMAND ${exercise})
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#include "atbash_cipher.h"
|
2
|
+
#define BOOST_TEST_MAIN
|
3
|
+
#include <boost/test/unit_test.hpp>
|
4
|
+
|
5
|
+
BOOST_AUTO_TEST_CASE(encode_yes)
|
6
|
+
{
|
7
|
+
BOOST_REQUIRE_EQUAL("bvh", atbash::encode("yes"));
|
8
|
+
}
|
9
|
+
|
10
|
+
#if defined(EXERCISM_RUN_ALL_TESTS)
|
11
|
+
BOOST_AUTO_TEST_CASE(encode_no)
|
12
|
+
{
|
13
|
+
BOOST_REQUIRE_EQUAL("ml", atbash::encode("no"));
|
14
|
+
}
|
15
|
+
|
16
|
+
BOOST_AUTO_TEST_CASE(encode_OMG)
|
17
|
+
{
|
18
|
+
BOOST_REQUIRE_EQUAL("lnt", atbash::encode("OMG"));
|
19
|
+
}
|
20
|
+
|
21
|
+
BOOST_AUTO_TEST_CASE(encode_spaces)
|
22
|
+
{
|
23
|
+
BOOST_REQUIRE_EQUAL("lnt", atbash::encode("O M G"));
|
24
|
+
}
|
25
|
+
|
26
|
+
BOOST_AUTO_TEST_CASE(encode_mindblowingly)
|
27
|
+
{
|
28
|
+
BOOST_REQUIRE_EQUAL("nrmwy oldrm tob", atbash::encode("mindblowingly"));
|
29
|
+
}
|
30
|
+
|
31
|
+
BOOST_AUTO_TEST_CASE(encode_numbers)
|
32
|
+
{
|
33
|
+
BOOST_REQUIRE_EQUAL("gvhgr mt123 gvhgr mt", atbash::encode("Testing,1 2 3, testing."));
|
34
|
+
}
|
35
|
+
|
36
|
+
BOOST_AUTO_TEST_CASE(encode_deep_thought)
|
37
|
+
{
|
38
|
+
BOOST_REQUIRE_EQUAL("gifgs rhurx grlm", atbash::encode("Truth is fiction."));
|
39
|
+
}
|
40
|
+
|
41
|
+
BOOST_AUTO_TEST_CASE(encode_all_the_letters)
|
42
|
+
{
|
43
|
+
BOOST_REQUIRE_EQUAL("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt",
|
44
|
+
atbash::encode("The quick brown fox jumps over the lazy dog."));
|
45
|
+
}
|
46
|
+
|
47
|
+
BOOST_AUTO_TEST_CASE(decode_exercism)
|
48
|
+
{
|
49
|
+
BOOST_REQUIRE_EQUAL("exercism", atbash::decode("vcvix rhn"));
|
50
|
+
}
|
51
|
+
|
52
|
+
BOOST_AUTO_TEST_CASE(decode_a_sentence)
|
53
|
+
{
|
54
|
+
BOOST_REQUIRE_EQUAL("anobstacleisoftenasteppingstone",
|
55
|
+
atbash::decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"));
|
56
|
+
}
|
57
|
+
|
58
|
+
BOOST_AUTO_TEST_CASE(decode_numbers)
|
59
|
+
{
|
60
|
+
BOOST_REQUIRE_EQUAL("testing123testing", atbash::decode("gvhgr mt123 gvhgr mt"));
|
61
|
+
}
|
62
|
+
|
63
|
+
BOOST_AUTO_TEST_CASE(decode_all_the_letters)
|
64
|
+
{
|
65
|
+
BOOST_REQUIRE_EQUAL("thequickbrownfoxjumpsoverthelazydog",
|
66
|
+
atbash::decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"));
|
67
|
+
}
|
68
|
+
#endif
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#include <sstream>
|
2
|
+
#include <string>
|
3
|
+
|
4
|
+
#include "atbash_cipher.h"
|
5
|
+
|
6
|
+
namespace atbash {
|
7
|
+
|
8
|
+
const char ALPHA_START = 'a';
|
9
|
+
const char ALPHA_END = 'z';
|
10
|
+
|
11
|
+
char atbash_transform(char c)
|
12
|
+
{
|
13
|
+
return std::isalpha(c) ? ALPHA_END - std::tolower(c) + ALPHA_START : c;
|
14
|
+
}
|
15
|
+
|
16
|
+
std::string encode(std::string const& plaintext)
|
17
|
+
{
|
18
|
+
int chunkSize = 5;
|
19
|
+
int chunkCounter = 0;
|
20
|
+
std::ostringstream os;
|
21
|
+
|
22
|
+
for(int i = 0; i < plaintext.length(); i++) {
|
23
|
+
char currentChar = plaintext.at(i);
|
24
|
+
|
25
|
+
if (std::isalnum(currentChar)) {
|
26
|
+
if ((chunkCounter > 0) && ((chunkCounter) % chunkSize == 0)) {
|
27
|
+
os << " ";
|
28
|
+
}
|
29
|
+
|
30
|
+
os << atbash_transform(currentChar);
|
31
|
+
chunkCounter++;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
return os.str();
|
36
|
+
}
|
37
|
+
|
38
|
+
std::string decode(std::string const& ciphertext)
|
39
|
+
{
|
40
|
+
std::ostringstream os;
|
41
|
+
|
42
|
+
for(int i = 0; i < ciphertext.length(); i++) {
|
43
|
+
char currentChar = ciphertext.at(i);
|
44
|
+
|
45
|
+
if (std::isalnum(currentChar)) {
|
46
|
+
os << atbash_transform(currentChar);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
return os.str();
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|