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.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/CONTRIBUTING.md +1 -1
  4. data/tracks/bash/.travis.yml +1 -1
  5. data/tracks/bash/config.json +30 -3
  6. data/tracks/c/README.md +1 -1
  7. data/tracks/c/config.json +131 -39
  8. data/tracks/ceylon/README.md +6 -6
  9. data/tracks/ceylon/config.json +21 -3
  10. data/tracks/chapel/.travis.yml +1 -1
  11. data/tracks/clojurescript/.travis.yml +1 -1
  12. data/tracks/clojurescript/README.md +6 -6
  13. data/tracks/clojurescript/exercises/.keep +0 -0
  14. data/tracks/coffeescript/.travis.yml +1 -1
  15. data/tracks/coldfusion/.travis.yml +1 -1
  16. data/tracks/coq/.travis.yml +1 -1
  17. data/tracks/cpp/CMakeLists.txt +1 -0
  18. data/tracks/cpp/README.md +1 -1
  19. data/tracks/cpp/config.json +8 -0
  20. data/tracks/cpp/exercises/atbash-cipher/CMakeLists.txt +52 -0
  21. data/tracks/cpp/exercises/atbash-cipher/atbash_cipher_test.cpp +68 -0
  22. data/tracks/cpp/exercises/atbash-cipher/example.cpp +54 -0
  23. data/tracks/cpp/exercises/atbash-cipher/example.h +13 -0
  24. data/tracks/csharp/config.json +315 -6
  25. data/tracks/d/.travis.yml +1 -1
  26. data/tracks/dart/README.md +2 -2
  27. data/tracks/dart/config.json +21 -3
  28. data/tracks/delphi/README.md +1 -1
  29. data/tracks/delphi/config.json +83 -1
  30. data/tracks/ecmascript/config.json +10 -0
  31. data/tracks/ecmascript/exercises/accumulate/accumulate.spec.js +3 -9
  32. data/tracks/ecmascript/exercises/acronym/acronym.spec.js +2 -2
  33. data/tracks/ecmascript/exercises/all-your-base/all-your-base.spec.js +131 -133
  34. data/tracks/ecmascript/exercises/all-your-base/example.js +1 -3
  35. data/tracks/ecmascript/exercises/allergies/allergies.spec.js +8 -10
  36. data/tracks/ecmascript/exercises/allergies/example.js +3 -5
  37. data/tracks/ecmascript/exercises/alphametics/alphametics.spec.js +61 -63
  38. data/tracks/ecmascript/exercises/alphametics/example.js +99 -99
  39. data/tracks/ecmascript/exercises/anagram/anagram.spec.js +35 -37
  40. data/tracks/ecmascript/exercises/anagram/example.js +1 -3
  41. data/tracks/ecmascript/exercises/atbash-cipher/atbash-cipher.spec.js +1 -3
  42. data/tracks/ecmascript/exercises/atbash-cipher/example.js +3 -3
  43. data/tracks/ecmascript/exercises/beer-song/beer-song.spec.js +0 -2
  44. data/tracks/ecmascript/exercises/beer-song/example.js +9 -9
  45. data/tracks/ecmascript/exercises/binary/binary.spec.js +1 -2
  46. data/tracks/ecmascript/exercises/binary/example.js +3 -3
  47. data/tracks/ecmascript/exercises/binary-search/binary-search.spec.js +1 -3
  48. data/tracks/ecmascript/exercises/binary-search-tree/binary-search-tree.spec.js +13 -15
  49. data/tracks/ecmascript/exercises/binary-search-tree/example.js +2 -2
  50. data/tracks/ecmascript/exercises/bob/bob.spec.js +1 -3
  51. data/tracks/ecmascript/exercises/bob/example.js +3 -3
  52. data/tracks/ecmascript/exercises/bracket-push/example.js +2 -2
  53. data/tracks/ecmascript/exercises/circular-buffer/circular-buffer.spec.js +10 -12
  54. data/tracks/ecmascript/exercises/circular-buffer/example.js +12 -11
  55. data/tracks/ecmascript/exercises/clock/clock.spec.js +0 -8
  56. data/tracks/ecmascript/exercises/clock/example.js +11 -11
  57. data/tracks/ecmascript/exercises/connect/connect.spec.js +75 -77
  58. data/tracks/ecmascript/exercises/connect/example.js +27 -29
  59. data/tracks/ecmascript/exercises/crypto-square/crypto-square.spec.js +11 -11
  60. data/tracks/ecmascript/exercises/crypto-square/example.js +11 -10
  61. data/tracks/ecmascript/exercises/custom-set/custom-set.spec.js +2 -4
  62. data/tracks/ecmascript/exercises/custom-set/example.js +1 -1
  63. data/tracks/ecmascript/exercises/diamond/diamond.spec.js +20 -21
  64. data/tracks/ecmascript/exercises/diamond/example.js +12 -13
  65. data/tracks/ecmascript/exercises/difference-of-squares/difference-of-squares.spec.js +0 -5
  66. data/tracks/ecmascript/exercises/diffie-hellman/diffie-hellman.spec.js +7 -28
  67. data/tracks/ecmascript/exercises/etl/etl.spec.js +36 -18
  68. data/tracks/ecmascript/exercises/etl/example.js +3 -3
  69. data/tracks/ecmascript/exercises/flatten-array/example.js +1 -1
  70. data/tracks/ecmascript/exercises/flatten-array/flatten-array.spec.js +2 -3
  71. data/tracks/ecmascript/exercises/food-chain/example.js +12 -12
  72. data/tracks/ecmascript/exercises/food-chain/food-chain.spec.js +0 -1
  73. data/tracks/ecmascript/exercises/gigasecond/example.js +1 -1
  74. data/tracks/ecmascript/exercises/gigasecond/gigasecond.spec.js +0 -1
  75. data/tracks/ecmascript/exercises/grade-school/grade-school.spec.js +18 -19
  76. data/tracks/ecmascript/exercises/grains/grains.spec.js +0 -1
  77. data/tracks/ecmascript/exercises/hamming/example.js +3 -3
  78. data/tracks/ecmascript/exercises/hamming/hamming.spec.js +5 -6
  79. data/tracks/ecmascript/exercises/hello-world/example.js +1 -1
  80. data/tracks/ecmascript/exercises/hello-world/hello-world.spec.js +1 -1
  81. data/tracks/ecmascript/exercises/hexadecimal/example.js +2 -2
  82. data/tracks/ecmascript/exercises/hexadecimal/hexadecimal.spec.js +9 -11
  83. data/tracks/ecmascript/exercises/isogram/isogram.spec.js +22 -23
  84. data/tracks/ecmascript/exercises/kindergarten-garden/example.js +7 -7
  85. data/tracks/ecmascript/exercises/kindergarten-garden/kindergarten-garden.spec.js +0 -5
  86. data/tracks/ecmascript/exercises/largest-series-product/example.js +4 -8
  87. data/tracks/ecmascript/exercises/largest-series-product/largest-series-product.spec.js +5 -7
  88. data/tracks/ecmascript/exercises/leap/leap.spec.js +4 -6
  89. data/tracks/ecmascript/exercises/linked-list/example.js +2 -2
  90. data/tracks/ecmascript/exercises/list-ops/example.js +19 -19
  91. data/tracks/ecmascript/exercises/list-ops/list-ops.spec.js +2 -18
  92. data/tracks/ecmascript/exercises/luhn/example.js +1 -1
  93. data/tracks/ecmascript/exercises/luhn/luhn.spec.js +1 -3
  94. data/tracks/ecmascript/exercises/matrix/example.js +2 -4
  95. data/tracks/ecmascript/exercises/matrix/matrix.spec.js +0 -2
  96. data/tracks/ecmascript/exercises/meetup/example.js +12 -15
  97. data/tracks/ecmascript/exercises/meetup/meetup.spec.js +0 -2
  98. data/tracks/ecmascript/exercises/minesweeper/example.js +60 -0
  99. data/tracks/ecmascript/exercises/minesweeper/minesweeper.spec.js +174 -0
  100. data/tracks/ecmascript/exercises/minesweeper/package.json +69 -0
  101. data/tracks/ecmascript/exercises/nth-prime/example.js +3 -2
  102. data/tracks/ecmascript/exercises/nth-prime/nth-prime.spec.js +0 -1
  103. data/tracks/ecmascript/exercises/ocr-numbers/example.js +3 -3
  104. data/tracks/ecmascript/exercises/ocr-numbers/ocr-numbers.spec.js +16 -18
  105. data/tracks/ecmascript/exercises/octal/example.js +1 -1
  106. data/tracks/ecmascript/exercises/octal/octal.spec.js +0 -2
  107. data/tracks/ecmascript/exercises/palindrome-products/example.js +14 -11
  108. data/tracks/ecmascript/exercises/palindrome-products/palindrome-products.spec.js +15 -18
  109. data/tracks/ecmascript/exercises/pangram/example.js +6 -5
  110. data/tracks/ecmascript/exercises/pangram/pangram.spec.js +10 -12
  111. data/tracks/ecmascript/exercises/pascals-triangle/example.js +2 -2
  112. data/tracks/ecmascript/exercises/pascals-triangle/pascals-triangle.spec.js +6 -8
  113. data/tracks/ecmascript/exercises/perfect-numbers/example.js +3 -5
  114. data/tracks/ecmascript/exercises/perfect-numbers/perfect-numbers.spec.js +0 -10
  115. data/tracks/ecmascript/exercises/phone-number/example.js +2 -2
  116. data/tracks/ecmascript/exercises/phone-number/phone-number.spec.js +0 -2
  117. data/tracks/ecmascript/exercises/pig-latin/example.js +4 -4
  118. data/tracks/ecmascript/exercises/pig-latin/pig-latin.spec.js +0 -1
  119. data/tracks/ecmascript/exercises/prime-factors/example.js +2 -2
  120. data/tracks/ecmascript/exercises/prime-factors/prime-factors.spec.js +0 -2
  121. data/tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js +3 -11
  122. data/tracks/ecmascript/exercises/queen-attack/example.js +17 -17
  123. data/tracks/ecmascript/exercises/queen-attack/queen-attack.spec.js +7 -8
  124. data/tracks/ecmascript/exercises/raindrops/example.js +1 -1
  125. data/tracks/ecmascript/exercises/raindrops/raindrops.spec.js +1 -2
  126. data/tracks/ecmascript/exercises/rna-transcription/example.js +5 -5
  127. data/tracks/ecmascript/exercises/rna-transcription/rna-transcription.spec.js +4 -5
  128. data/tracks/ecmascript/exercises/robot-name/example.js +6 -6
  129. data/tracks/ecmascript/exercises/robot-name/robot-name.spec.js +10 -11
  130. data/tracks/ecmascript/exercises/robot-simulator/example.js +1 -1
  131. data/tracks/ecmascript/exercises/robot-simulator/robot-simulator.spec.js +31 -32
  132. data/tracks/ecmascript/exercises/roman-numerals/example.js +16 -16
  133. data/tracks/ecmascript/exercises/saddle-points/saddle-points.spec.js +3 -3
  134. data/tracks/ecmascript/exercises/say/example.js +25 -25
  135. data/tracks/ecmascript/exercises/say/say.spec.js +2 -3
  136. data/tracks/ecmascript/exercises/scrabble-score/example.js +27 -9
  137. data/tracks/ecmascript/exercises/scrabble-score/scrabble-score.spec.js +6 -7
  138. data/tracks/ecmascript/exercises/secret-handshake/example.js +2 -3
  139. data/tracks/ecmascript/exercises/secret-handshake/secret-handshake.spec.js +3 -5
  140. data/tracks/ecmascript/exercises/series/series.spec.js +1 -3
  141. data/tracks/ecmascript/exercises/sieve/example.js +4 -3
  142. data/tracks/ecmascript/exercises/sieve/sieve.spec.js +0 -2
  143. data/tracks/ecmascript/exercises/simple-cipher/example.js +8 -9
  144. data/tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js +4 -4
  145. data/tracks/ecmascript/exercises/space-age/example.js +1 -1
  146. data/tracks/ecmascript/exercises/space-age/space-age.spec.js +9 -11
  147. data/tracks/ecmascript/exercises/strain/example.js +4 -4
  148. data/tracks/ecmascript/exercises/strain/strain.spec.js +14 -16
  149. data/tracks/ecmascript/exercises/sum-of-multiples/example.js +4 -4
  150. data/tracks/ecmascript/exercises/triangle/triangle.spec.js +2 -4
  151. data/tracks/ecmascript/exercises/trinary/example.js +3 -3
  152. data/tracks/ecmascript/exercises/trinary/trinary.spec.js +0 -2
  153. data/tracks/ecmascript/exercises/two-bucket/example.js +30 -27
  154. data/tracks/ecmascript/exercises/two-bucket/two-bucket.spec.js +4 -8
  155. data/tracks/ecmascript/exercises/word-count/example.js +2 -2
  156. data/tracks/ecmascript/exercises/word-count/word-count.spec.js +2 -3
  157. data/tracks/ecmascript/exercises/wordy/example.js +6 -6
  158. data/tracks/ecmascript/exercises/wordy/wordy.spec.js +2 -4
  159. data/tracks/factor/config.json +15 -6
  160. data/tracks/fortran/.travis.yml +1 -1
  161. data/tracks/fsharp/config.json +312 -10
  162. data/tracks/go/README.md +1 -1
  163. data/tracks/go/config.json +523 -155
  164. data/tracks/haskell/README.md +2 -2
  165. data/tracks/haskell/config.json +256 -7
  166. data/tracks/haxe/.travis.yml +1 -1
  167. data/tracks/haxe/Makefile +2 -2
  168. data/tracks/haxe/config.json +8 -5
  169. data/tracks/java/CONTRIBUTING.md +2 -2
  170. data/tracks/java/config.json +277 -17
  171. data/tracks/java/exercises/rotational-cipher/build.gradle +17 -0
  172. data/tracks/java/exercises/rotational-cipher/src/example/java/RotationalCipher.java +37 -0
  173. data/tracks/java/exercises/rotational-cipher/src/main/java/.keep +0 -0
  174. data/tracks/java/exercises/rotational-cipher/src/test/java/RotationalCipherTest.java +81 -0
  175. data/tracks/java/exercises/settings.gradle +1 -0
  176. data/tracks/java/exercises/twelve-days/src/main/java/TwelveDays.java +4 -0
  177. data/tracks/julia/.travis.yml +1 -1
  178. data/tracks/julia/README.md +1 -1
  179. data/tracks/kotlin/README.md +2 -2
  180. data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +3 -3
  181. data/tracks/lisp/config.json +97 -3
  182. data/tracks/lisp/exercises/pascals-triangle/example.lisp +21 -0
  183. data/tracks/lisp/exercises/pascals-triangle/pascal.lisp +7 -0
  184. data/tracks/lisp/exercises/pascals-triangle/pascals-triangle-test.lisp +34 -0
  185. data/tracks/lua/.travis.yml +1 -1
  186. data/tracks/lua/README.md +1 -1
  187. data/tracks/mips/.travis.yml +1 -1
  188. data/tracks/mips/config.json +56 -17
  189. data/tracks/nasm/.travis.yml +1 -1
  190. data/tracks/nim/.travis.yml +1 -1
  191. data/tracks/ocaml/README.md +3 -3
  192. data/tracks/ocaml/config.json +130 -4
  193. data/tracks/perl5/docs/TESTS.md +40 -26
  194. data/tracks/plsql/.travis.yml +1 -1
  195. data/tracks/plsql/config.json +40 -13
  196. data/tracks/pony/.travis.yml +1 -1
  197. data/tracks/pony/bin/install-deps +4 -3
  198. data/tracks/prolog/.travis.yml +1 -1
  199. data/tracks/r/README.md +5 -5
  200. data/tracks/r/config.json +102 -30
  201. data/tracks/rust/.travis.yml +1 -1
  202. data/tracks/rust/config.json +172 -4
  203. data/tracks/rust/docs/EXERCISE_README_INSERT.md +1 -1
  204. data/tracks/sml/config.json +26 -3
  205. data/tracks/vimscript/config.json +60 -3
  206. metadata +16 -1
@@ -1,50 +1,48 @@
1
1
  import Pangram from './pangram';
2
2
 
3
3
  describe('Pangram()', () => {
4
-
5
4
  test('empty sentence', () => {
6
5
  const pangram = new Pangram('');
7
6
  expect(pangram.isPangram()).toBe(false);
8
7
  });
9
8
 
10
9
  xtest('pangram with only lower case', () => {
11
- const pangram = new Pangram("the quick brown fox jumps over the lazy dog");
10
+ const pangram = new Pangram('the quick brown fox jumps over the lazy dog');
12
11
  expect(pangram.isPangram()).toBe(true);
13
12
  });
14
13
 
15
14
  xtest("missing character 'x'", () => {
16
- const pangram = new Pangram("a quick movement of the enemy will jeopardize five gunboats");
15
+ const pangram = new Pangram('a quick movement of the enemy will jeopardize five gunboats');
17
16
  expect(pangram.isPangram()).toBe(false);
18
17
  });
19
18
 
20
19
  xtest("another missing character 'x'", () => {
21
- const pangram = new Pangram("the quick brown fish jumps over the lazy dog");
20
+ const pangram = new Pangram('the quick brown fish jumps over the lazy dog');
22
21
  expect(pangram.isPangram()).toBe(false);
23
22
  });
24
23
 
25
- xtest("pangram with underscores", () => {
26
- const pangram = new Pangram("the_quick_brown_fox_jumps_over_the_lazy_dog");
24
+ xtest('pangram with underscores', () => {
25
+ const pangram = new Pangram('the_quick_brown_fox_jumps_over_the_lazy_dog');
27
26
  expect(pangram.isPangram()).toBe(true);
28
27
  });
29
28
 
30
- xtest("pangram with numbers", () => {
31
- const pangram = new Pangram("the 1 quick brown fox jumps over the 2 lazy dogs");
29
+ xtest('pangram with numbers', () => {
30
+ const pangram = new Pangram('the 1 quick brown fox jumps over the 2 lazy dogs');
32
31
  expect(pangram.isPangram()).toBe(true);
33
32
  });
34
33
 
35
34
  xtest('missing letters replaced by numbers', () => {
36
- const pangram = new Pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog");
35
+ const pangram = new Pangram('7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog');
37
36
  expect(pangram.isPangram()).toBe(false);
38
37
  });
39
38
 
40
39
  xtest('pangram with mixed case and punctuation', () => {
41
- const pangram = new Pangram("\"Five quacking Zephyrs jolt my wax bed.\"");
40
+ const pangram = new Pangram('"Five quacking Zephyrs jolt my wax bed."');
42
41
  expect(pangram.isPangram()).toBe(true);
43
42
  });
44
43
 
45
44
  xtest('pangram with non-ascii characters', () => {
46
- const pangram = new Pangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.");
45
+ const pangram = new Pangram('Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.');
47
46
  expect(pangram.isPangram()).toBe(true);
48
47
  });
49
-
50
48
  });
@@ -9,9 +9,9 @@ class Triangle {
9
9
  }
10
10
 
11
11
  fillRows(rows) {
12
- let result = [[ 1 ]];
12
+ const result = [[1]];
13
13
  for (let x = 1; x < rows; x++) {
14
- let newRow = [ 1 ];
14
+ const newRow = [1];
15
15
  result[x - 1].forEach(this.sumElements, newRow);
16
16
  result.push(newRow);
17
17
  }
@@ -1,30 +1,28 @@
1
1
  import Triangle from './pascals-triangle';
2
2
 
3
3
  describe('Triangle', () => {
4
-
5
4
  test('with one row', () => {
6
- expect(new Triangle(1).rows).toEqual([[ 1 ]]);
5
+ expect(new Triangle(1).rows).toEqual([[1]]);
7
6
  });
8
7
 
9
8
  xtest('with two rows', () => {
10
- expect(new Triangle(2).rows).toEqual([ [ 1 ], [ 1, 1 ] ]);
9
+ expect(new Triangle(2).rows).toEqual([[1], [1, 1]]);
11
10
  });
12
11
 
13
12
  xtest('with three rows', () => {
14
- expect(new Triangle(3).rows).toEqual([ [ 1 ], [ 1, 1 ], [ 1, 2, 1 ] ]);
13
+ expect(new Triangle(3).rows).toEqual([[1], [1, 1], [1, 2, 1]]);
15
14
  });
16
15
 
17
16
  xtest('last row', () => {
18
- expect(new Triangle(4).lastRow).toEqual([ 1, 3, 3, 1 ]);
17
+ expect(new Triangle(4).lastRow).toEqual([1, 3, 3, 1]);
19
18
  });
20
19
 
21
20
  xtest('fifth row', () => {
22
- expect(new Triangle(5).lastRow).toEqual([ 1, 4, 6, 4, 1 ]);
21
+ expect(new Triangle(5).lastRow).toEqual([1, 4, 6, 4, 1]);
23
22
  });
24
23
 
25
24
  xtest('twentieth row', () => {
26
- const twentieth = [ 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 ];
25
+ const twentieth = [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1];
27
26
  expect(new Triangle(20).lastRow).toEqual(twentieth);
28
27
  });
29
-
30
28
  });
@@ -7,9 +7,8 @@ export default class PerfectNumbers {
7
7
  * @returns {array} array that contains the divisors for a given number NOT including the number itself.
8
8
  */
9
9
  getDivisors(number) {
10
-
11
10
  let i;
12
- let divs = new Array();
11
+ const divs = new Array();
13
12
 
14
13
  // Accepts only natural numbers greater than 1.
15
14
  if (number <= 1) {
@@ -21,7 +20,6 @@ export default class PerfectNumbers {
21
20
 
22
21
  // Calculate the divisors up the the half of the number + 1
23
22
  for (i = 2; i <= number / 2; i++) {
24
-
25
23
  if (number % i === 0) {
26
24
  divs.push(i);
27
25
  }
@@ -37,8 +35,8 @@ export default class PerfectNumbers {
37
35
  * @returns {string} - string that contains the number classification (perfect, abundant or deficient).
38
36
  */
39
37
  classify(number) {
40
-
41
- let sum, result;
38
+ let sum,
39
+ result;
42
40
 
43
41
  // Check if the input is valid
44
42
  if (number <= 0) {
@@ -1,11 +1,9 @@
1
1
  import PerfectNumbers from './perfect-numbers';
2
2
 
3
3
  describe('Exercise - Perfect Numbers', () => {
4
-
5
4
  const perfectNumbers = new PerfectNumbers();
6
5
 
7
6
  describe('Perfect Numbers', () => {
8
-
9
7
  test('Smallest perfect number is classified correctly', () => {
10
8
  expect(perfectNumbers.classify(6)).toEqual('perfect');
11
9
  });
@@ -17,11 +15,9 @@ describe('Exercise - Perfect Numbers', () => {
17
15
  xtest('Large perfect number is classified correctly', () => {
18
16
  expect(perfectNumbers.classify(33550336)).toEqual('perfect');
19
17
  });
20
-
21
18
  });
22
19
 
23
20
  describe('Abundant Numbers', () => {
24
-
25
21
  xtest('Smallest abundant number is classified correctly', () => {
26
22
  expect(perfectNumbers.classify(12)).toEqual('abundant');
27
23
  });
@@ -33,11 +29,9 @@ describe('Exercise - Perfect Numbers', () => {
33
29
  xtest('Large abundant number is classified correctly', () => {
34
30
  expect(perfectNumbers.classify(33550335)).toEqual('abundant');
35
31
  });
36
-
37
32
  });
38
33
 
39
34
  describe('Deficient Numbers', () => {
40
-
41
35
  xtest('Smallest prime deficient number is classified correctly', () => {
42
36
  expect(perfectNumbers.classify(2)).toEqual('deficient');
43
37
  });
@@ -57,11 +51,9 @@ describe('Exercise - Perfect Numbers', () => {
57
51
  xtest('Edge case (no factors other than itself) is classified correctly', () => {
58
52
  expect(perfectNumbers.classify(1)).toEqual('deficient');
59
53
  });
60
-
61
54
  });
62
55
 
63
56
  describe('Invalid Inputs', () => {
64
-
65
57
  xtest('Zero is rejected (not a natural number)', () => {
66
58
  expect(() => perfectNumbers.classify(0))
67
59
  .toThrow('Classification is only possible for natural numbers.');
@@ -71,7 +63,5 @@ describe('Exercise - Perfect Numbers', () => {
71
63
  expect(() => perfectNumbers.classify(-1))
72
64
  .toThrow('Classification is only possible for natural numbers.');
73
65
  });
74
-
75
66
  });
76
-
77
67
  });
@@ -5,7 +5,7 @@ export default class PhoneNumber {
5
5
  }
6
6
 
7
7
  number() {
8
- if(/[a-zA-Z]/.test(this.rawNumber)) {
8
+ if (/[a-zA-Z]/.test(this.rawNumber)) {
9
9
  return null;
10
10
  }
11
11
 
@@ -13,7 +13,7 @@ export default class PhoneNumber {
13
13
  }
14
14
 
15
15
  _cleanedNumber() {
16
- let num = this.rawNumber.replace(/\D/g,'');
16
+ const num = this.rawNumber.replace(/\D/g, '');
17
17
 
18
18
  if (num.length === 10) {
19
19
  return num;
@@ -1,7 +1,6 @@
1
1
  import PhoneNumber from './phone-number';
2
2
 
3
3
  describe('PhoneNumber()', () => {
4
-
5
4
  test('cleans the number', () => {
6
5
  const phone = new PhoneNumber('(123) 456-7890');
7
6
  expect(phone.number()).toEqual('1234567890');
@@ -51,5 +50,4 @@ describe('PhoneNumber()', () => {
51
50
  const phone = new PhoneNumber('1a2b3c4d5e6f7g8h9i0j');
52
51
  expect(phone.number()).toEqual(null);
53
52
  });
54
-
55
53
  });
@@ -1,16 +1,16 @@
1
1
  const LANGUAGE_RULES_REGEXP = /^([^aeiou]?qu|[^aeiou]*)(.+)/;
2
2
 
3
3
  function translateWord(word) {
4
- const [ , beginning, ending ] = word.match(LANGUAGE_RULES_REGEXP);
4
+ const [, beginning, ending] = word.match(LANGUAGE_RULES_REGEXP);
5
5
 
6
6
  if (beginning.length === 0) {
7
- return word + 'ay';
7
+ return `${word}ay`;
8
8
  }
9
- return ending + beginning + 'ay';
9
+ return `${ending + beginning}ay`;
10
10
  }
11
11
 
12
12
  class PigLatin {
13
- translate (english) {
13
+ translate(english) {
14
14
  return english
15
15
  .split(' ')
16
16
  .map(translateWord)
@@ -47,5 +47,4 @@ describe('Pig Latin', () => {
47
47
  expect(translator.translate('quick fast run'))
48
48
  .toEqual('ickquay astfay unray');
49
49
  });
50
-
51
50
  });
@@ -1,6 +1,6 @@
1
1
  class PrimeFactors {
2
- for (num) {
3
- const factors=[];
2
+ for(num) {
3
+ const factors = [];
4
4
  let currentFactor = 2;
5
5
 
6
6
  while (num !== 1) {
@@ -2,7 +2,6 @@ import PrimeFactors from './prime-factors';
2
2
  const primeFactors = new PrimeFactors();
3
3
 
4
4
  describe('primeFactors', () => {
5
-
6
5
  test('returns an empty array for 1', () => expect(primeFactors.for(1)).toEqual([]));
7
6
 
8
7
  xtest('factors 2', () => expect(primeFactors.for(2)).toEqual([2]));
@@ -24,5 +23,4 @@ describe('primeFactors', () => {
24
23
  xtest('factors 901255', () => expect(primeFactors.for(901255)).toEqual([5, 17, 23, 461]));
25
24
 
26
25
  xtest('factors 93819012551', () => expect(primeFactors.for(93819012551)).toEqual([11, 9539, 894119]));
27
-
28
26
  });
@@ -1,7 +1,6 @@
1
1
  import Triplet from './pythagorean-triplet';
2
2
 
3
3
  describe('Triplet', () => {
4
-
5
4
  test('calculates the sum', () => {
6
5
  expect(new Triplet(3, 4, 5).sum()).toBe(12);
7
6
  });
@@ -20,26 +19,19 @@ describe('Triplet', () => {
20
19
 
21
20
  xtest('can make triplets up to 10', () => {
22
21
  const triplets = Triplet.where({ maxFactor: 10 });
23
- const products = triplets.sort().map(triplet => {
24
- return triplet.product();
25
- });
22
+ const products = triplets.sort().map(triplet => triplet.product());
26
23
  expect(products).toEqual([60, 480]);
27
24
  });
28
25
 
29
26
  xtest('can make triplets 11 through 20', () => {
30
27
  const triplets = Triplet.where({ minFactor: 11, maxFactor: 20 });
31
- const products = triplets.sort().map(triplet => {
32
- return triplet.product();
33
- });
28
+ const products = triplets.sort().map(triplet => triplet.product());
34
29
  expect(products).toEqual([3840]);
35
30
  });
36
31
 
37
32
  xtest('can filter on sum', () => {
38
33
  const triplets = Triplet.where({ sum: 180, maxFactor: 100 });
39
- const products = triplets.sort().map(triplet => {
40
- return triplet.product();
41
- });
34
+ const products = triplets.sort().map(triplet => triplet.product());
42
35
  expect(products).toEqual([118080, 168480, 202500]);
43
36
  });
44
-
45
37
  });
@@ -1,23 +1,23 @@
1
1
  const W = 8,
2
2
  H = 8,
3
- STARTING = { black : [7,3], white: [0,3] };
3
+ STARTING = { black: [7, 3], white: [0, 3] };
4
4
 
5
- const QueenAttack = ( params = STARTING ) => {
5
+ const QueenAttack = (params = STARTING) => {
6
6
  const self = this instanceof QueenAttack ? this : Object.getPrototypeOf(QueenAttack);
7
- if (params && params.white === params.black){
8
- throw new Error("Queens cannot share the same space");
7
+ if (params && params.white === params.black) {
8
+ throw new Error('Queens cannot share the same space');
9
9
  }
10
10
 
11
- self.black=params.black;
12
- self.white=params.white;
11
+ self.black = params.black;
12
+ self.white = params.white;
13
13
  self.board = constructBoard();
14
14
  placePieces(self);
15
15
 
16
16
  self.canAttack = () => {
17
- if (self.black[0] === self.white[0] || self.black[1] === self.white[1]){
17
+ if (self.black[0] === self.white[0] || self.black[1] === self.white[1]) {
18
18
  return true;
19
19
  }
20
- return Math.abs(self.black[0]-self.white[0]) === Math.abs(self.black[1]-self.white[1]);
20
+ return Math.abs(self.black[0] - self.white[0]) === Math.abs(self.black[1] - self.white[1]);
21
21
  };
22
22
 
23
23
  self.toString = () => self.board.join('');
@@ -25,22 +25,22 @@ const QueenAttack = ( params = STARTING ) => {
25
25
  return self;
26
26
  };
27
27
 
28
- function constructBoard(){
29
- let row = buildRow("_ ", W).join('');
30
- row = row.substring(0, row.length-1)+"\n";
28
+ function constructBoard() {
29
+ let row = buildRow('_ ', W).join('');
30
+ row = `${row.substring(0, row.length - 1)}\n`;
31
31
  return concatRows(row, H);
32
32
  }
33
33
 
34
- function placePieces(self){
35
- self.board[self.black[0]*W*2+self.black[1]*2]='B';
36
- self.board[self.white[0]*W*2+self.white[1]*2]='W';
34
+ function placePieces(self) {
35
+ self.board[self.black[0] * W * 2 + self.black[1] * 2] = 'B';
36
+ self.board[self.white[0] * W * 2 + self.white[1] * 2] = 'W';
37
37
  }
38
38
 
39
- function buildRow(cell, colCount){
40
- return Array.apply(null, Array(colCount)).map(() => cell);
39
+ function buildRow(cell, colCount) {
40
+ return Array(...Array(colCount)).map(() => cell);
41
41
  }
42
42
 
43
- function concatRows(row, rowCount){
43
+ function concatRows(row, rowCount) {
44
44
  return [...Array.prototype.concat.apply(buildRow(row, rowCount)).join('')];
45
45
  }
46
46
 
@@ -8,23 +8,23 @@ describe('Queens', () => {
8
8
  });
9
9
 
10
10
  xtest('initialized with specific placement', () => {
11
- const queens = new Queens({white: [3,7], black: [6,1]});
11
+ const queens = new Queens({ white: [3, 7], black: [6, 1] });
12
12
  expect(queens.white).toEqual([3, 7]);
13
13
  expect(queens.black).toEqual([6, 1]);
14
14
  });
15
15
 
16
16
  xtest('cannot occupy the same space', () => {
17
- const positioning = {white: [2,4], black: [2,4]};
17
+ const positioning = { white: [2, 4], black: [2, 4] };
18
18
 
19
19
  try {
20
20
  new Queens(positioning);
21
- } catch(error) {
21
+ } catch (error) {
22
22
  expect(error).toEqual('Queens cannot share the same space');
23
23
  }
24
24
  });
25
25
 
26
26
  xtest('toString representation', () => {
27
- const positioning = {white: [2, 4], black: [6, 6]};
27
+ const positioning = { white: [2, 4], black: [6, 6] };
28
28
  const queens = new Queens(positioning);
29
29
  const board = '_ _ _ _ _ _ _ _\n\
30
30
  _ _ _ _ _ _ _ _\n\
@@ -39,17 +39,17 @@ _ _ _ _ _ _ _ _\n\
39
39
  });
40
40
 
41
41
  xtest('queens cannot attack', () => {
42
- const queens = new Queens({ white: [2,3], black: [4,7] });
42
+ const queens = new Queens({ white: [2, 3], black: [4, 7] });
43
43
  expect(queens.canAttack()).toEqual(false);
44
44
  });
45
45
 
46
46
  xtest('queens can attack when they are on the same row', () => {
47
- const queens = new Queens({ white: [2,4], black: [2,7] });
47
+ const queens = new Queens({ white: [2, 4], black: [2, 7] });
48
48
  expect(queens.canAttack()).toEqual(true);
49
49
  });
50
50
 
51
51
  xtest('queens can attack when they are on the same column', () => {
52
- const queens = new Queens({ white: [5,4], black: [2,4] });
52
+ const queens = new Queens({ white: [5, 4], black: [2, 4] });
53
53
  expect(queens.canAttack()).toEqual(true);
54
54
  });
55
55
 
@@ -77,5 +77,4 @@ _ _ _ _ _ _ _ _\n\
77
77
  const queens = new Queens({ white: [2, 6], black: [5, 3] });
78
78
  expect(queens.canAttack()).toEqual(true);
79
79
  });
80
-
81
80
  });
@@ -11,7 +11,7 @@ const Raindrops = () => ({
11
11
  result += 'Plong';
12
12
  }
13
13
  return result === '' ? n.toString() : result;
14
- }
14
+ },
15
15
  });
16
16
 
17
17
  export default Raindrops;
@@ -1,6 +1,6 @@
1
1
  import Raindrops from './raindrops';
2
2
 
3
- describe('Raindrops', () => {
3
+ describe('Raindrops', () => {
4
4
  const drops = new Raindrops();
5
5
 
6
6
  test('converts 1', () => expect(drops.convert(1)).toEqual('1'));
@@ -34,5 +34,4 @@ describe('Raindrops', () => {
34
34
  xtest('converts 105', () => expect(drops.convert(105)).toEqual('PlingPlangPlong'));
35
35
 
36
36
  xtest('converts 12121', () => expect(drops.convert(12121)).toEqual('12121'));
37
-
38
37
  });
@@ -1,13 +1,13 @@
1
1
  const DNA_TO_RNA = {
2
- G: "C",
3
- C: "G",
4
- T: "A",
5
- A: "U"
2
+ G: 'C',
3
+ C: 'G',
4
+ T: 'A',
5
+ A: 'U',
6
6
  };
7
7
 
8
8
  export default class Transcriptor {
9
9
  toRna(dna) {
10
- let rna = dna.replace(/./g, nucleotide => DNA_TO_RNA[nucleotide])
10
+ const rna = dna.replace(/./g, nucleotide => DNA_TO_RNA[nucleotide]);
11
11
 
12
12
  if (rna.length !== dna.length) {
13
13
  // invalid characters in the strand
@@ -1,7 +1,7 @@
1
1
  import Transcriptor from './rna-transcription';
2
2
 
3
3
  describe('Transcriptor', () => {
4
- let transcriptor = new Transcriptor();
4
+ const transcriptor = new Transcriptor();
5
5
 
6
6
  test('transcribes cytosine to guanine', () => {
7
7
  expect(transcriptor.toRna('C')).toEqual('G');
@@ -26,20 +26,19 @@ describe('Transcriptor', () => {
26
26
 
27
27
  xtest('correctly handles invalid input', () => {
28
28
  expect(() => transcriptor.toRna('U')).toThrow(
29
- new Error('Invalid input DNA.')
29
+ new Error('Invalid input DNA.'),
30
30
  );
31
31
  });
32
32
 
33
33
  xtest('correctly handles completely invalid input', () => {
34
34
  expect(() => transcriptor.toRna('XXX')).toThrow(
35
- new Error('Invalid input DNA.')
35
+ new Error('Invalid input DNA.'),
36
36
  );
37
37
  });
38
38
 
39
39
  xtest('correctly handles partially invalid input', () => {
40
40
  expect(() => transcriptor.toRna('ACGTXXXCTTAA')).toThrow(
41
- new Error('Invalid input DNA.')
41
+ new Error('Invalid input DNA.'),
42
42
  );
43
43
  });
44
-
45
44
  });
@@ -1,19 +1,19 @@
1
1
  const ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
2
- BASE = 10,
3
- usedNames ={};
2
+ BASE = 10,
3
+ usedNames = {};
4
4
 
5
- const random = (max) => Math.floor(Math.random()*max);
5
+ const random = max => Math.floor(Math.random() * max);
6
6
 
7
7
  const generateName = () => {
8
8
  let name = ALPHA.charAt(random(ALPHA.length))
9
- +ALPHA.charAt(random(ALPHA.length))
10
- +random(BASE)+random(BASE)+random(BASE);
9
+ + ALPHA.charAt(random(ALPHA.length))
10
+ + random(BASE) + random(BASE) + random(BASE);
11
11
  usedNames[name] ? name = generateName() : usedNames[name] = true;
12
12
  return name;
13
13
  };
14
14
 
15
15
  export default class Robot {
16
- constructor(){
16
+ constructor() {
17
17
  this.robotName = generateName();
18
18
  }
19
19
 
@@ -44,7 +44,7 @@ describe('Robot', () => {
44
44
  });
45
45
 
46
46
  xtest('internal name cannot be modified', () => {
47
- const modifyInternal = () => robot.name += "a modification";
47
+ const modifyInternal = () => robot.name += 'a modification';
48
48
  expect(modifyInternal).toThrow();
49
49
  });
50
50
 
@@ -69,7 +69,7 @@ describe('Robot', () => {
69
69
  expect(areSequential(name3, name3)).toBe(true);
70
70
  });
71
71
 
72
- //This test is optional.
72
+ // This test is optional.
73
73
  xtest('there can be lots of robots with different names each', () => {
74
74
  const NUMBER_OF_ROBOTS = 10000;
75
75
  const usedNames = new Set();
@@ -81,20 +81,19 @@ describe('Robot', () => {
81
81
 
82
82
  expect(usedNames.size).toEqual(NUMBER_OF_ROBOTS);
83
83
  });
84
-
85
84
  });
86
85
 
87
86
  const areSequential = (name1, name2) => {
88
- const alpha1 = name1.substr(0,2);
89
- const alpha2 = name2.substr(0,2);
90
- const num1 = +name1.substr(2,3);
91
- const num2 = +name2.substr(2,3);
87
+ const alpha1 = name1.substr(0, 2);
88
+ const alpha2 = name2.substr(0, 2);
89
+ const num1 = +name1.substr(2, 3);
90
+ const num2 = +name2.substr(2, 3);
92
91
 
93
- const numDiff = num2-num1;
94
- const alphaDiff = (alpha2.charCodeAt(0)-alpha1.charCodeAt(0))*26
95
- + (alpha2.charCodeAt(1)-alpha1.charCodeAt(1));
92
+ const numDiff = num2 - num1;
93
+ const alphaDiff = (alpha2.charCodeAt(0) - alpha1.charCodeAt(0)) * 26
94
+ + (alpha2.charCodeAt(1) - alpha1.charCodeAt(1));
96
95
 
97
- const totalDiff = alphaDiff*1000 + numDiff;
96
+ const totalDiff = alphaDiff * 1000 + numDiff;
98
97
 
99
98
  return Math.abs(totalDiff) <= 1;
100
99
  };
@@ -10,7 +10,7 @@ class Robot {
10
10
 
11
11
  orient(direction) {
12
12
  this.bearing = direction;
13
- return 'The robot is pointed ' + direction;
13
+ return `The robot is pointed ${direction}`;
14
14
  }
15
15
 
16
16
  advance() {