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
@@ -1,38 +1,37 @@
|
|
1
1
|
import Hexadecimal from './hexadecimal';
|
2
2
|
|
3
3
|
describe('Hexadecimal', () => {
|
4
|
-
|
5
|
-
test('hex 1 is decimal 1', () => {
|
4
|
+
test('hex 1 is decimal 1', () => {
|
6
5
|
const hex = new Hexadecimal('1');
|
7
6
|
expect(hex.toDecimal()).toEqual(1);
|
8
7
|
});
|
9
8
|
|
10
|
-
|
9
|
+
xtest('hex c is decimal 12', () => {
|
11
10
|
const hex = new Hexadecimal('c');
|
12
11
|
expect(hex.toDecimal()).toEqual(12);
|
13
12
|
});
|
14
13
|
|
15
|
-
|
14
|
+
xtest('hex 10 is decimal 16', () => {
|
16
15
|
const hex = new Hexadecimal('10');
|
17
16
|
expect(hex.toDecimal()).toEqual(16);
|
18
17
|
});
|
19
18
|
|
20
|
-
|
19
|
+
xtest('hex af is decimal 175', () => {
|
21
20
|
const hex = new Hexadecimal('af');
|
22
21
|
expect(hex.toDecimal()).toEqual(175);
|
23
22
|
});
|
24
23
|
|
25
|
-
|
24
|
+
xtest('hex 100 is decimal 256', () => {
|
26
25
|
const hex = new Hexadecimal('100');
|
27
26
|
expect(hex.toDecimal()).toEqual(256);
|
28
27
|
});
|
29
28
|
|
30
|
-
|
29
|
+
xtest('hex 19ace is decimal 105166', () => {
|
31
30
|
const hex = new Hexadecimal('19ace');
|
32
31
|
expect(hex.toDecimal()).toEqual(105166);
|
33
32
|
});
|
34
33
|
|
35
|
-
|
34
|
+
xtest('invalid hex is decimal 0', () => {
|
36
35
|
const hex = new Hexadecimal('carrot');
|
37
36
|
expect(hex.toDecimal()).toEqual(0);
|
38
37
|
});
|
@@ -42,14 +41,13 @@ describe('Hexadecimal', () => {
|
|
42
41
|
expect(hex.toDecimal()).toEqual(0);
|
43
42
|
});
|
44
43
|
|
45
|
-
|
44
|
+
xtest('hexadecimal value for HTML/CSS white color', () => {
|
46
45
|
const hex = new Hexadecimal('ffffff');
|
47
46
|
expect(hex.toDecimal()).toEqual(16777215);
|
48
47
|
});
|
49
48
|
|
50
|
-
|
49
|
+
xtest('hexadecimal value for HTML/CSS yellow color', () => {
|
51
50
|
const hex = new Hexadecimal('ffff00');
|
52
51
|
expect(hex.toDecimal()).toEqual(16776960);
|
53
52
|
});
|
54
|
-
|
55
53
|
});
|
@@ -1,64 +1,63 @@
|
|
1
|
-
import Isogram from './isogram.js'
|
1
|
+
import Isogram from './isogram.js';
|
2
2
|
|
3
|
-
describe('Isogram Test Suite',
|
4
|
-
test('duplicates',
|
5
|
-
|
3
|
+
describe('Isogram Test Suite', () => {
|
4
|
+
test('duplicates', () => {
|
5
|
+
const word = new Isogram('duplicates');
|
6
6
|
|
7
7
|
expect(word.isIsogram()).toEqual(true);
|
8
8
|
});
|
9
9
|
|
10
|
-
xtest('eleven',
|
11
|
-
|
10
|
+
xtest('eleven', () => {
|
11
|
+
const word = new Isogram('eleven');
|
12
12
|
|
13
13
|
expect(word.isIsogram()).toEqual(false);
|
14
14
|
});
|
15
15
|
|
16
|
-
xtest('subdermatoglyphic',
|
17
|
-
|
16
|
+
xtest('subdermatoglyphic', () => {
|
17
|
+
const word = new Isogram('subdermatoglyphic');
|
18
18
|
|
19
19
|
expect(word.isIsogram()).toEqual(true);
|
20
20
|
});
|
21
21
|
|
22
|
-
xtest('Alphabet',
|
23
|
-
|
22
|
+
xtest('Alphabet', () => {
|
23
|
+
const word = new Isogram('Alphabet');
|
24
24
|
|
25
25
|
expect(word.isIsogram()).toEqual(false);
|
26
26
|
});
|
27
27
|
|
28
|
-
xtest('thumbscrew-japingly',
|
29
|
-
|
28
|
+
xtest('thumbscrew-japingly', () => {
|
29
|
+
const word = new Isogram('thumbscrew-japingly');
|
30
30
|
|
31
31
|
expect(word.isIsogram()).toEqual(true);
|
32
32
|
});
|
33
33
|
|
34
|
-
xtest('Hjelmqvist-Gryb-Zock-Pfund-Wax',
|
35
|
-
|
34
|
+
xtest('Hjelmqvist-Gryb-Zock-Pfund-Wax', () => {
|
35
|
+
const word = new Isogram('Hjelmqvist-Gryb-Zock-Pfund-Wax');
|
36
36
|
|
37
37
|
expect(word.isIsogram()).toEqual(true);
|
38
38
|
});
|
39
39
|
|
40
|
-
xtest('Heizölrückstoßabdämpfung',
|
41
|
-
|
40
|
+
xtest('Heizölrückstoßabdämpfung', () => {
|
41
|
+
const word = new Isogram('Heizölrückstoßabdämpfung');
|
42
42
|
|
43
43
|
expect(word.isIsogram()).toEqual(true);
|
44
44
|
});
|
45
45
|
|
46
|
-
xtest('the quick brown fox',
|
47
|
-
|
46
|
+
xtest('the quick brown fox', () => {
|
47
|
+
const word = new Isogram('the quick brown fox');
|
48
48
|
|
49
49
|
expect(word.isIsogram()).toEqual(false);
|
50
50
|
});
|
51
51
|
|
52
|
-
xtest('Emily Jung Schwartzkopf',
|
53
|
-
|
52
|
+
xtest('Emily Jung Schwartzkopf', () => {
|
53
|
+
const word = new Isogram('Emily Jung Schwartzkopf');
|
54
54
|
|
55
55
|
expect(word.isIsogram()).toEqual(true);
|
56
56
|
});
|
57
57
|
|
58
|
-
xtest('éléphant',
|
59
|
-
|
58
|
+
xtest('éléphant', () => {
|
59
|
+
const word = new Isogram('éléphant');
|
60
60
|
|
61
61
|
expect(word.isIsogram()).toEqual(false);
|
62
62
|
});
|
63
|
-
|
64
63
|
});
|
@@ -10,28 +10,28 @@ const defaultChildren = [
|
|
10
10
|
'Ileana',
|
11
11
|
'Joseph',
|
12
12
|
'Kincaid',
|
13
|
-
'Larry'
|
13
|
+
'Larry',
|
14
14
|
];
|
15
15
|
|
16
16
|
const plants = {
|
17
17
|
G: 'grass',
|
18
18
|
V: 'violets',
|
19
19
|
R: 'radishes',
|
20
|
-
C: 'clover'
|
20
|
+
C: 'clover',
|
21
21
|
};
|
22
22
|
|
23
23
|
function getPlants(pots, index) {
|
24
|
-
|
25
|
-
const position = 2*index;
|
24
|
+
const plants = [];
|
25
|
+
const position = 2 * index;
|
26
26
|
plants.push(pots[0][position]);
|
27
|
-
plants.push(pots[0][position+1]);
|
27
|
+
plants.push(pots[0][position + 1]);
|
28
28
|
plants.push(pots[1][position]);
|
29
|
-
plants.push(pots[1][position+1]);
|
29
|
+
plants.push(pots[1][position + 1]);
|
30
30
|
return plants;
|
31
31
|
}
|
32
32
|
|
33
33
|
function parse(diagram) {
|
34
|
-
return diagram.split('\n').map(
|
34
|
+
return diagram.split('\n').map(row => [...row].map(sign => plants[sign]));
|
35
35
|
}
|
36
36
|
|
37
37
|
class Garden {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Garden from './kindergarten-garden';
|
2
2
|
|
3
3
|
describe('Garden', () => {
|
4
|
-
|
5
4
|
test('for Alice', () => {
|
6
5
|
expect(new Garden('RC\nGG').alice)
|
7
6
|
.toEqual(['radishes', 'clover', 'grass', 'grass']);
|
@@ -22,7 +21,6 @@ describe('Garden', () => {
|
|
22
21
|
expect(garden.bob).toEqual(['clover', 'clover', 'clover', 'clover']);
|
23
22
|
expect(garden.charlie).toEqual(['grass', 'grass', 'grass', 'grass']);
|
24
23
|
});
|
25
|
-
|
26
24
|
});
|
27
25
|
|
28
26
|
describe('Full garden', () => {
|
@@ -88,7 +86,6 @@ describe('Full garden', () => {
|
|
88
86
|
expect(garden.larry)
|
89
87
|
.toEqual(['grass', 'violets', 'clover', 'violets']);
|
90
88
|
});
|
91
|
-
|
92
89
|
});
|
93
90
|
|
94
91
|
describe('Disordered class', () => {
|
@@ -115,7 +112,6 @@ describe('Disordered class', () => {
|
|
115
112
|
expect(garden.xander)
|
116
113
|
.toEqual(['radishes', 'grass', 'clover', 'violets']);
|
117
114
|
});
|
118
|
-
|
119
115
|
});
|
120
116
|
|
121
117
|
describe('Two gardens, different students', () => {
|
@@ -133,5 +129,4 @@ describe('Two gardens, different students', () => {
|
|
133
129
|
expect(garden2.charlie)
|
134
130
|
.toEqual(['radishes', 'radishes', 'grass', 'clover']);
|
135
131
|
});
|
136
|
-
|
137
132
|
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
export default class Series {
|
2
2
|
|
3
3
|
constructor(numberString) {
|
4
|
-
if(numberString.match('[^0-9]')) {
|
4
|
+
if (numberString.match('[^0-9]')) {
|
5
5
|
throw new Error('Invalid input.');
|
6
6
|
}
|
7
7
|
|
@@ -10,9 +10,7 @@ export default class Series {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
getDigits() {
|
13
|
-
return [...this.numberString].map(
|
14
|
-
return parseInt(digit, 10);
|
15
|
-
});
|
13
|
+
return [...this.numberString].map(digit => parseInt(digit, 10));
|
16
14
|
}
|
17
15
|
|
18
16
|
largestProduct(size) {
|
@@ -22,10 +20,8 @@ export default class Series {
|
|
22
20
|
|
23
21
|
let product,
|
24
22
|
max = 0;
|
25
|
-
this.slices(size).forEach(
|
26
|
-
product = slice.reduce(
|
27
|
-
return a * b;
|
28
|
-
}, 1);
|
23
|
+
this.slices(size).forEach((slice) => {
|
24
|
+
product = slice.reduce((a, b) => a * b, 1);
|
29
25
|
if (product > max) {
|
30
26
|
max = product;
|
31
27
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Series from './largest-series-product';
|
2
2
|
|
3
3
|
describe('Series', () => {
|
4
|
-
|
5
4
|
test('can get the largest product of 2', () => {
|
6
5
|
expect(new Series('0123456789').largestProduct(2)).toBe(72);
|
7
6
|
});
|
@@ -35,15 +34,15 @@ describe('Series', () => {
|
|
35
34
|
expect(new Series('99099').largestProduct(3)).toBe(0);
|
36
35
|
});
|
37
36
|
|
38
|
-
xtest('rejects invalid character in input', ()=> {
|
39
|
-
expect(()=> {
|
40
|
-
new Series('1234a5').largestProduct('2')
|
37
|
+
xtest('rejects invalid character in input', () => {
|
38
|
+
expect(() => {
|
39
|
+
new Series('1234a5').largestProduct('2');
|
41
40
|
}).toThrow(new Error('Invalid input.'));
|
42
41
|
});
|
43
42
|
|
44
|
-
xtest('rejects negative span', ()=> {
|
43
|
+
xtest('rejects negative span', () => {
|
45
44
|
expect(() => {
|
46
|
-
new Series('12345').largestProduct(-1)
|
45
|
+
new Series('12345').largestProduct(-1);
|
47
46
|
}).toThrow(new Error('Invalid input.'));
|
48
47
|
});
|
49
48
|
|
@@ -66,5 +65,4 @@ describe('Series', () => {
|
|
66
65
|
new Series('').largestProduct(1);
|
67
66
|
}).toThrow(new Error('Slice size is too big.'));
|
68
67
|
});
|
69
|
-
|
70
68
|
});
|
@@ -1,25 +1,23 @@
|
|
1
1
|
import Year from './leap';
|
2
2
|
|
3
3
|
describe('A leap year', () => {
|
4
|
-
|
5
4
|
test('year not divisible by 4: common year', () => {
|
6
|
-
|
5
|
+
const year = new Year(2015);
|
7
6
|
expect(year.isLeap()).toBeFalsy();
|
8
7
|
});
|
9
8
|
|
10
9
|
xtest('year divisible by 4, not divisible by 100: leap year', () => {
|
11
|
-
|
10
|
+
const year = new Year(2016);
|
12
11
|
expect(year.isLeap()).toBeTruthy();
|
13
12
|
});
|
14
13
|
|
15
14
|
xtest('year divisible by 100, not divisible by 400: common year', () => {
|
16
|
-
|
15
|
+
const year = new Year(2100);
|
17
16
|
expect(year.isLeap()).toBeFalsy();
|
18
17
|
});
|
19
18
|
|
20
19
|
xtest('year divisible by 400: leap year', () => {
|
21
|
-
|
20
|
+
const year = new Year(2000);
|
22
21
|
expect(year.isLeap()).toBeTruthy();
|
23
22
|
});
|
24
|
-
|
25
23
|
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
function Element(value) {
|
2
|
-
return {
|
2
|
+
return { value, next: null, prev: null };
|
3
3
|
}
|
4
4
|
|
5
5
|
export default class Deque {
|
@@ -67,7 +67,7 @@ export default class Deque {
|
|
67
67
|
|
68
68
|
count() {
|
69
69
|
let count = 0,
|
70
|
-
|
70
|
+
element = this.head;
|
71
71
|
|
72
72
|
while (this.head && element) {
|
73
73
|
count++;
|
@@ -1,24 +1,24 @@
|
|
1
1
|
class List {
|
2
2
|
|
3
|
-
constructor(arr){
|
3
|
+
constructor(arr) {
|
4
4
|
this.values = arr || [];
|
5
5
|
}
|
6
6
|
|
7
|
-
append(otherList){
|
8
|
-
for (
|
7
|
+
append(otherList) {
|
8
|
+
for (const el of otherList.values) {
|
9
9
|
this.values.push(el);
|
10
10
|
}
|
11
11
|
return this;
|
12
12
|
}
|
13
13
|
|
14
|
-
concat(otherList){
|
14
|
+
concat(otherList) {
|
15
15
|
return this.append(otherList);
|
16
16
|
}
|
17
17
|
|
18
|
-
filter(operation){
|
18
|
+
filter(operation) {
|
19
19
|
const filteredValues = [];
|
20
|
-
for (
|
21
|
-
if (operation(el)){
|
20
|
+
for (const el of this.values) {
|
21
|
+
if (operation(el)) {
|
22
22
|
filteredValues.push(el);
|
23
23
|
}
|
24
24
|
}
|
@@ -26,45 +26,45 @@ class List {
|
|
26
26
|
return this;
|
27
27
|
}
|
28
28
|
|
29
|
-
length(){
|
29
|
+
length() {
|
30
30
|
let length = 0;
|
31
|
-
for (
|
31
|
+
for (const el of this.values) {
|
32
32
|
length++;
|
33
33
|
}
|
34
34
|
return length;
|
35
35
|
}
|
36
36
|
|
37
|
-
map(operation){
|
37
|
+
map(operation) {
|
38
38
|
const mappedValues = [];
|
39
|
-
for (
|
39
|
+
for (const el of this.values) {
|
40
40
|
mappedValues.push(operation(el));
|
41
41
|
}
|
42
42
|
this.values = mappedValues;
|
43
43
|
return this;
|
44
44
|
}
|
45
45
|
|
46
|
-
foldl(operation, initialValue){
|
46
|
+
foldl(operation, initialValue) {
|
47
47
|
let acc = initialValue;
|
48
|
-
for (
|
48
|
+
for (const el of this.values) {
|
49
49
|
acc = operation(acc, el);
|
50
50
|
}
|
51
51
|
return acc;
|
52
52
|
}
|
53
53
|
|
54
|
-
foldr(operation, initialValue){
|
54
|
+
foldr(operation, initialValue) {
|
55
55
|
let acc = initialValue;
|
56
|
-
let index = this.length() -1;
|
57
|
-
while (index >= 0){
|
58
|
-
|
56
|
+
let index = this.length() - 1;
|
57
|
+
while (index >= 0) {
|
58
|
+
const el = this.values[index--];
|
59
59
|
acc = operation(acc, el);
|
60
60
|
}
|
61
61
|
return acc;
|
62
62
|
}
|
63
63
|
|
64
|
-
reverse(){
|
64
|
+
reverse() {
|
65
65
|
const numElements = this.length();
|
66
66
|
let finalIndex = numElements - 1;
|
67
|
-
for (let index = 0; index < numElements/2; index++){
|
67
|
+
for (let index = 0; index < numElements / 2; index++) {
|
68
68
|
const temp = this.values[index];
|
69
69
|
this.values[index] = this.values[finalIndex];
|
70
70
|
this.values[finalIndex--] = temp;
|
@@ -2,7 +2,6 @@ import List from './list-ops';
|
|
2
2
|
|
3
3
|
|
4
4
|
describe('append entries to a list and return the new list', () => {
|
5
|
-
|
6
5
|
test('empty lists', () => {
|
7
6
|
const list1 = new List();
|
8
7
|
const list2 = new List();
|
@@ -20,12 +19,10 @@ describe('append entries to a list and return the new list', () => {
|
|
20
19
|
const list2 = new List([2, 3, 4, 5]);
|
21
20
|
expect(list1.append(list2).values).toEqual([1, 2, 2, 3, 4, 5]);
|
22
21
|
});
|
23
|
-
|
24
22
|
});
|
25
23
|
|
26
24
|
|
27
25
|
describe('concat lists and lists of lists into new list', () => {
|
28
|
-
|
29
26
|
xtest('empty list', () => {
|
30
27
|
const list1 = new List();
|
31
28
|
const list2 = new List();
|
@@ -39,27 +36,23 @@ describe('concat lists and lists of lists into new list', () => {
|
|
39
36
|
const list4 = new List([4, 5, 6]);
|
40
37
|
expect(list1.concat(list2).concat(list3).concat(list4).values).toEqual([1, 2, 3, 4, 5, 6]);
|
41
38
|
});
|
42
|
-
|
43
39
|
});
|
44
40
|
|
45
41
|
|
46
42
|
describe('filter list returning only values that satisfy the filter function', () => {
|
47
|
-
|
48
43
|
xtest('empty list', () => {
|
49
44
|
const list1 = new List([]);
|
50
|
-
expect(list1.filter(
|
45
|
+
expect(list1.filter(el => el % 2 === 1).values).toEqual([]);
|
51
46
|
});
|
52
47
|
|
53
48
|
xtest('non empty list', () => {
|
54
49
|
const list1 = new List([1, 2, 3, 5]);
|
55
|
-
expect(list1.filter(
|
50
|
+
expect(list1.filter(el => el % 2 === 1).values).toEqual([1, 3, 5]);
|
56
51
|
});
|
57
|
-
|
58
52
|
});
|
59
53
|
|
60
54
|
|
61
55
|
describe('returns the length of a list', () => {
|
62
|
-
|
63
56
|
xtest('empty list', () => {
|
64
57
|
const list1 = new List();
|
65
58
|
expect(list1.length()).toEqual(0);
|
@@ -69,12 +62,10 @@ describe('returns the length of a list', () => {
|
|
69
62
|
const list1 = new List([1, 2, 3, 4]);
|
70
63
|
expect(list1.length()).toEqual(4);
|
71
64
|
});
|
72
|
-
|
73
65
|
});
|
74
66
|
|
75
67
|
|
76
68
|
describe('returns a list of elements whose values equal the list value transformed by the mapping function', () => {
|
77
|
-
|
78
69
|
xtest('empty list', () => {
|
79
70
|
const list1 = new List();
|
80
71
|
expect(list1.map(el => ++el).values).toEqual([]);
|
@@ -84,12 +75,10 @@ describe('returns a list of elements whose values equal the list value transform
|
|
84
75
|
const list1 = new List([1, 3, 5, 7]);
|
85
76
|
expect(list1.map(el => ++el).values).toEqual([2, 4, 6, 8]);
|
86
77
|
});
|
87
|
-
|
88
78
|
});
|
89
79
|
|
90
80
|
|
91
81
|
describe('folds (reduces) the given list from the left with a function', () => {
|
92
|
-
|
93
82
|
xtest('empty list', () => {
|
94
83
|
const list1 = new List();
|
95
84
|
expect(list1.foldl((acc, el) => el / acc, 2)).toEqual(2);
|
@@ -99,12 +88,10 @@ describe('folds (reduces) the given list from the left with a function', () => {
|
|
99
88
|
const list1 = new List([1, 2, 3, 4]);
|
100
89
|
expect(list1.foldl((acc, el) => el / acc, 24)).toEqual(64);
|
101
90
|
});
|
102
|
-
|
103
91
|
});
|
104
92
|
|
105
93
|
|
106
94
|
describe('folds (reduces) the given list from the right with a function', () => {
|
107
|
-
|
108
95
|
xtest('empty list', () => {
|
109
96
|
const list1 = new List();
|
110
97
|
expect(list1.foldr((acc, el) => el / acc, 2)).toEqual(2);
|
@@ -114,12 +101,10 @@ describe('folds (reduces) the given list from the right with a function', () =>
|
|
114
101
|
const list1 = new List([1, 2, 3, 4]);
|
115
102
|
expect(list1.foldr((acc, el) => el / acc, 24)).toEqual(9);
|
116
103
|
});
|
117
|
-
|
118
104
|
});
|
119
105
|
|
120
106
|
|
121
107
|
describe('reverse the elements of a list', () => {
|
122
|
-
|
123
108
|
xtest('empty list', () => {
|
124
109
|
const list1 = new List();
|
125
110
|
expect(list1.reverse().values).toEqual([]);
|
@@ -129,5 +114,4 @@ describe('reverse the elements of a list', () => {
|
|
129
114
|
const list1 = new List([1, 3, 5, 7]);
|
130
115
|
expect(list1.reverse().values).toEqual([7, 5, 3, 1]);
|
131
116
|
});
|
132
|
-
|
133
117
|
});
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Luhn from './luhn';
|
2
2
|
|
3
|
-
describe('Luhn',() => {
|
4
|
-
|
3
|
+
describe('Luhn', () => {
|
5
4
|
test('single digit strings can not be valid', () => {
|
6
5
|
const luhn = new Luhn('1');
|
7
6
|
expect(luhn.valid).toEqual(false);
|
@@ -31,5 +30,4 @@ describe('Luhn',() => {
|
|
31
30
|
const luhn = new Luhn('046a 454 286');
|
32
31
|
expect(luhn.valid).toEqual(false);
|
33
32
|
});
|
34
|
-
|
35
33
|
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
function columnsFromRows(rows) {
|
2
|
-
|
2
|
+
const columns = [];
|
3
3
|
|
4
4
|
rows.forEach((row) => {
|
5
5
|
row.forEach((n, index) => {
|
@@ -12,9 +12,7 @@ function columnsFromRows(rows) {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
function parseRows(description) {
|
15
|
-
return description.split('\n').map((
|
16
|
-
return row.split(' ').map((char) => parseInt(char, 10));
|
17
|
-
});
|
15
|
+
return description.split('\n').map(row => row.split(' ').map(char => parseInt(char, 10)));
|
18
16
|
}
|
19
17
|
|
20
18
|
class Matrix {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Matrix from './matrix';
|
2
2
|
|
3
3
|
describe('Matrix', () => {
|
4
|
-
|
5
4
|
test('can extract a row', () => {
|
6
5
|
expect(new Matrix('1 2\n10 20').rows[0]).toEqual([1, 2]);
|
7
6
|
});
|
@@ -14,5 +13,4 @@ describe('Matrix', () => {
|
|
14
13
|
expect(new Matrix('89 1903 3\n18 3 1\n9 4 800').columns[1])
|
15
14
|
.toEqual([1903, 3, 4]);
|
16
15
|
});
|
17
|
-
|
18
16
|
});
|
@@ -1,14 +1,11 @@
|
|
1
|
-
export default function meetupDay
|
2
|
-
|
3
|
-
let candidates = getCandidates(year, month, dayOfWeek);
|
1
|
+
export default function meetupDay(year, month, dayOfWeek, which) {
|
2
|
+
const candidates = getCandidates(year, month, dayOfWeek);
|
4
3
|
let res;
|
5
4
|
|
6
5
|
which = which.toLowerCase();
|
7
6
|
|
8
7
|
if (which === 'teenth') {
|
9
|
-
res = find(candidates, d =>
|
10
|
-
return 13 <= d.getDate() && d.getDate() <= 19;
|
11
|
-
});
|
8
|
+
res = find(candidates, d => d.getDate() >= 13 && d.getDate() <= 19);
|
12
9
|
} else if (which === 'last') {
|
13
10
|
res = candidates.pop();
|
14
11
|
} else {
|
@@ -21,7 +18,7 @@ export default function meetupDay (year, month, dayOfWeek, which) {
|
|
21
18
|
return res;
|
22
19
|
}
|
23
20
|
|
24
|
-
function getCandidates
|
21
|
+
function getCandidates(year, month, dayOfWeek) {
|
25
22
|
let d,
|
26
23
|
i,
|
27
24
|
numDaysInMonth = new Date(year, month + 1, 0).getDate(),
|
@@ -38,15 +35,15 @@ function getCandidates (year, month, dayOfWeek) {
|
|
38
35
|
return res;
|
39
36
|
}
|
40
37
|
|
41
|
-
function getDayIndex
|
38
|
+
function getDayIndex(day) {
|
42
39
|
const daysInd = {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
sunday: 0,
|
41
|
+
monday: 1,
|
42
|
+
tuesday: 2,
|
43
|
+
wednesday: 3,
|
44
|
+
thursday: 4,
|
45
|
+
friday: 5,
|
46
|
+
saturday: 6,
|
50
47
|
};
|
51
48
|
|
52
49
|
day = day.toLowerCase();
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import meetupDay from './meetup';
|
2
2
|
|
3
3
|
describe('meetupDay()', () => {
|
4
|
-
|
5
4
|
test('test monteenth of may 2013', () => {
|
6
5
|
expect(meetupDay(2013, 4, 'Monday', 'teenth')).toEqual(new Date(2013, 4, 13));
|
7
6
|
});
|
@@ -55,5 +54,4 @@ describe('meetupDay()', () => {
|
|
55
54
|
meetupDay(2015, 1, 'Monday', '5th');
|
56
55
|
}).toThrow();
|
57
56
|
});
|
58
|
-
|
59
57
|
});
|