trackler 2.2.0.0 → 2.2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,58 +1,56 @@
|
|
|
1
1
|
import SpaceAge from './space-age';
|
|
2
2
|
|
|
3
3
|
describe('Space Age', () => {
|
|
4
|
-
|
|
5
4
|
test('age in seconds', () => {
|
|
6
|
-
|
|
5
|
+
const age = new SpaceAge(1000000);
|
|
7
6
|
expect(age.seconds).toEqual(1000000);
|
|
8
7
|
});
|
|
9
8
|
|
|
10
9
|
xtest('age in earth years', () => {
|
|
11
|
-
|
|
10
|
+
const age = new SpaceAge(1000000000);
|
|
12
11
|
expect(age.onEarth()).toEqual(31.69);
|
|
13
12
|
});
|
|
14
13
|
|
|
15
14
|
xtest('age in mercury years', () => {
|
|
16
|
-
|
|
15
|
+
const age = new SpaceAge(2134835688);
|
|
17
16
|
expect(age.onEarth()).toEqual(67.65);
|
|
18
17
|
expect(age.onMercury()).toEqual(280.88);
|
|
19
18
|
});
|
|
20
19
|
|
|
21
20
|
xtest('age in venus years', () => {
|
|
22
|
-
|
|
21
|
+
const age = new SpaceAge(189839836);
|
|
23
22
|
expect(age.onEarth()).toEqual(6.02);
|
|
24
23
|
expect(age.onVenus()).toEqual(9.78);
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
xtest('age in mars years', () => {
|
|
28
|
-
|
|
27
|
+
const age = new SpaceAge(2329871239);
|
|
29
28
|
expect(age.onEarth()).toEqual(73.83);
|
|
30
29
|
expect(age.onMars()).toEqual(39.25);
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
xtest('age in jupiter years', () => {
|
|
34
|
-
|
|
33
|
+
const age = new SpaceAge(901876382);
|
|
35
34
|
expect(age.onEarth()).toEqual(28.58);
|
|
36
35
|
expect(age.onJupiter()).toEqual(2.41);
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
xtest('age in saturn years', () => {
|
|
40
|
-
|
|
39
|
+
const age = new SpaceAge(3000000000);
|
|
41
40
|
expect(age.onEarth()).toEqual(95.06);
|
|
42
41
|
expect(age.onSaturn()).toEqual(3.23);
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
xtest('age in uranus years', () => {
|
|
46
|
-
|
|
45
|
+
const age = new SpaceAge(3210123456);
|
|
47
46
|
expect(age.onEarth()).toEqual(101.72);
|
|
48
47
|
expect(age.onUranus()).toEqual(1.21);
|
|
49
48
|
});
|
|
50
49
|
|
|
51
50
|
xtest('age in neptune year', () => {
|
|
52
|
-
|
|
51
|
+
const age = new SpaceAge(8210123456);
|
|
53
52
|
expect(age.onEarth()).toEqual(260.16);
|
|
54
53
|
expect(age.onNeptune()).toEqual(1.58);
|
|
55
54
|
});
|
|
56
|
-
|
|
57
55
|
});
|
|
58
56
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Strain = {
|
|
2
|
-
strain
|
|
2
|
+
strain: (array, filter, keepMatches) => {
|
|
3
3
|
const results = [];
|
|
4
4
|
for (let i = 0; i < array.length; i++) {
|
|
5
5
|
const item = array[i];
|
|
@@ -10,9 +10,9 @@ const Strain = {
|
|
|
10
10
|
return results;
|
|
11
11
|
},
|
|
12
12
|
|
|
13
|
-
keep:
|
|
14
|
-
discard:
|
|
13
|
+
keep: (array, filter) => Strain.strain(array, filter, true),
|
|
14
|
+
discard: (array, filter) => Strain.strain(array, filter, false),
|
|
15
15
|
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
export default Strain;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import strain from './strain';
|
|
2
2
|
|
|
3
3
|
describe('strain', () => {
|
|
4
|
-
|
|
5
4
|
test('keeps on empty array returns empty array', () => {
|
|
6
|
-
expect(strain.keep([],
|
|
5
|
+
expect(strain.keep([], e => e < 10)).toEqual([]);
|
|
7
6
|
});
|
|
8
7
|
|
|
9
8
|
xtest('keeps everything ', () => {
|
|
10
|
-
expect(strain.keep([1, 2, 3],
|
|
9
|
+
expect(strain.keep([1, 2, 3], e => e < 10)).toEqual([1, 2, 3]);
|
|
11
10
|
});
|
|
12
11
|
|
|
13
12
|
xtest('keeps first and last', () => {
|
|
14
|
-
expect(strain.keep([1, 2, 3],
|
|
13
|
+
expect(strain.keep([1, 2, 3], e => e % 2 === 1)).toEqual([1, 3]);
|
|
15
14
|
});
|
|
16
15
|
|
|
17
16
|
xtest('keeps neither first nor last', () => {
|
|
18
|
-
expect(strain.keep([1, 2, 3, 4, 5],
|
|
17
|
+
expect(strain.keep([1, 2, 3, 4, 5], e => e % 2 === 0)).toEqual([2, 4]);
|
|
19
18
|
});
|
|
20
19
|
|
|
21
20
|
xtest('keeps strings', () => {
|
|
22
21
|
const words = 'apple zebra banana zombies cherimoya zelot'.split(' ');
|
|
23
|
-
const result = strain.keep(words, word => word.indexOf('z') === 0
|
|
22
|
+
const result = strain.keep(words, word => word.indexOf('z') === 0);
|
|
24
23
|
expect(result).toEqual('zebra zombies zelot'.split(' '));
|
|
25
24
|
});
|
|
26
25
|
|
|
@@ -32,32 +31,32 @@ describe('strain', () => {
|
|
|
32
31
|
[2, 1, 2],
|
|
33
32
|
[1, 5, 2],
|
|
34
33
|
[2, 2, 1],
|
|
35
|
-
[1, 2, 5]
|
|
34
|
+
[1, 2, 5],
|
|
36
35
|
];
|
|
37
|
-
const result = strain.keep(rows, row => row.indexOf(5) > -1
|
|
36
|
+
const result = strain.keep(rows, row => row.indexOf(5) > -1);
|
|
38
37
|
expect(result).toEqual([[5, 5, 5], [5, 1, 2], [1, 5, 2], [1, 2, 5]]);
|
|
39
38
|
});
|
|
40
39
|
|
|
41
40
|
xtest('empty discard', () => {
|
|
42
|
-
expect(strain.discard([],
|
|
41
|
+
expect(strain.discard([], e => e < 10)).toEqual([]);
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
xtest('discards nothing', () => {
|
|
46
|
-
expect(strain.discard([1, 2, 3],
|
|
45
|
+
expect(strain.discard([1, 2, 3], e => e > 10)).toEqual([1, 2, 3]);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
xtest('discards first and last', () => {
|
|
50
|
-
expect(strain.discard([1, 2, 3],
|
|
49
|
+
expect(strain.discard([1, 2, 3], e => e % 2 === 1)).toEqual([2]);
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
xtest('discards neither first nor last', () => {
|
|
54
|
-
const result = strain.discard([1, 2, 3, 4, 5],
|
|
53
|
+
const result = strain.discard([1, 2, 3, 4, 5], e => e % 2 === 0);
|
|
55
54
|
expect(result).toEqual([1, 3, 5]);
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
xtest('discards strings', () => {
|
|
59
58
|
const words = 'apple zebra banana zombies cherimoya zelot'.split(' ');
|
|
60
|
-
const result = strain.discard(words, word => word.indexOf('z') === 0
|
|
59
|
+
const result = strain.discard(words, word => word.indexOf('z') === 0);
|
|
61
60
|
expect(result).toEqual('apple banana cherimoya'.split(' '));
|
|
62
61
|
});
|
|
63
62
|
|
|
@@ -69,11 +68,10 @@ describe('strain', () => {
|
|
|
69
68
|
[2, 1, 2],
|
|
70
69
|
[1, 5, 2],
|
|
71
70
|
[2, 2, 1],
|
|
72
|
-
[1, 2, 5]
|
|
71
|
+
[1, 2, 5],
|
|
73
72
|
];
|
|
74
|
-
const result = strain.discard(rows, row => row.indexOf(5) > -1
|
|
73
|
+
const result = strain.discard(rows, row => row.indexOf(5) > -1);
|
|
75
74
|
expect(result).toEqual([[1, 2, 3], [2, 1, 2], [2, 2, 1]]);
|
|
76
75
|
});
|
|
77
|
-
|
|
78
76
|
});
|
|
79
77
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const Sum = (factors) => {
|
|
2
|
-
|
|
2
|
+
const self = this instanceof Sum ? this : Object.getPrototypeOf(Sum);
|
|
3
3
|
self.factors = factors;
|
|
4
4
|
|
|
5
|
-
self.to = limit => {
|
|
6
|
-
|
|
7
|
-
self.factors.forEach(factor => {
|
|
5
|
+
self.to = (limit) => {
|
|
6
|
+
const multiples = {};
|
|
7
|
+
self.factors.forEach((factor) => {
|
|
8
8
|
for (let ii = factor; ii < limit; ii += factor) {
|
|
9
9
|
multiples[ii] = ii;
|
|
10
10
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Triangle from './triangle';
|
|
2
2
|
|
|
3
3
|
describe('Triangle', () => {
|
|
4
|
-
|
|
5
4
|
test('equilateral triangles have equal sides', () => {
|
|
6
5
|
const triangle = new Triangle(2, 2, 2);
|
|
7
6
|
expect(triangle.kind()).toEqual('equilateral');
|
|
@@ -72,9 +71,8 @@ describe('Triangle', () => {
|
|
|
72
71
|
expect(triangle.kind.bind(triangle)).toThrow();
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
xtest('triangles violating triangle inequality are illegal 3', ()=> {
|
|
76
|
-
const triangle = new Triangle(10,1,3);
|
|
74
|
+
xtest('triangles violating triangle inequality are illegal 3', () => {
|
|
75
|
+
const triangle = new Triangle(10, 1, 3);
|
|
77
76
|
expect(triangle.kind.bind(triangle)).toThrow();
|
|
78
77
|
});
|
|
79
|
-
|
|
80
78
|
});
|
|
@@ -2,11 +2,11 @@ const BASE = 3;
|
|
|
2
2
|
|
|
3
3
|
export default class Trinary {
|
|
4
4
|
|
|
5
|
-
constructor
|
|
5
|
+
constructor(decimal) {
|
|
6
6
|
this.digits = [...decimal].reverse().map(Number);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
toDecimal
|
|
9
|
+
toDecimal() {
|
|
10
10
|
if (this.someDigitIsInvalid()) {
|
|
11
11
|
return 0;
|
|
12
12
|
}
|
|
@@ -20,7 +20,7 @@ export default class Trinary {
|
|
|
20
20
|
return greaterThanBase || notANumber;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
accumulator
|
|
23
|
+
accumulator(decimal, digit, index) {
|
|
24
24
|
return decimal += digit * Math.pow(BASE, index);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Trinary from './trinary';
|
|
2
2
|
|
|
3
3
|
describe('Trinary', () => {
|
|
4
|
-
|
|
5
4
|
test('1 is decimal 1', () => {
|
|
6
5
|
expect(1).toEqual(new Trinary('1').toDecimal());
|
|
7
6
|
});
|
|
@@ -41,5 +40,4 @@ describe('Trinary', () => {
|
|
|
41
40
|
xtest('digits from 3 to 9 are invalid', () => {
|
|
42
41
|
expect(0).toEqual(new Trinary('123').toDecimal());
|
|
43
42
|
});
|
|
44
|
-
|
|
45
43
|
});
|
|
@@ -7,8 +7,8 @@ class TwoBucket {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
reachedGoal(measurements) {
|
|
10
|
-
if(measurements[0] === this.z || measurements[1] === this.z) {
|
|
11
|
-
if(measurements[0] === this.z) {
|
|
10
|
+
if (measurements[0] === this.z || measurements[1] === this.z) {
|
|
11
|
+
if (measurements[0] === this.z) {
|
|
12
12
|
this.goalBucket = 'one';
|
|
13
13
|
this.otherBucket = measurements[1];
|
|
14
14
|
} else {
|
|
@@ -23,23 +23,24 @@ class TwoBucket {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
bigFirst(measurements, moveCount, prBool) {
|
|
26
|
-
let j = measurements[0],
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
let j = measurements[0],
|
|
27
|
+
k = measurements[1];
|
|
28
|
+
while (!this.reachedGoal(measurements)) {
|
|
29
|
+
if (k > this.x && j === 0 && moveCount === 0) {
|
|
29
30
|
j = this.x;
|
|
30
31
|
k = this.y - j;
|
|
31
|
-
} else if(j == this.x) {
|
|
32
|
+
} else if (j == this.x) {
|
|
32
33
|
j = 0;
|
|
33
|
-
} else if(k > this.x && j !== 0 || k > this.x && prBool) {
|
|
34
|
-
k
|
|
34
|
+
} else if (k > this.x && j !== 0 || k > this.x && prBool) {
|
|
35
|
+
k -= (this.x - j);
|
|
35
36
|
j = this.x;
|
|
36
|
-
} else if(k > this.x || j == 0) {
|
|
37
|
+
} else if (k > this.x || j == 0) {
|
|
37
38
|
j = k;
|
|
38
|
-
k
|
|
39
|
-
} else if(k == 0) {
|
|
39
|
+
k -= j;
|
|
40
|
+
} else if (k == 0) {
|
|
40
41
|
k = this.y;
|
|
41
42
|
}
|
|
42
|
-
measurements = [j,k];
|
|
43
|
+
measurements = [j, k];
|
|
43
44
|
moveCount++;
|
|
44
45
|
prBool = !prBool;
|
|
45
46
|
}
|
|
@@ -48,24 +49,25 @@ class TwoBucket {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
smallFirst(measurements, moveCount, prBool) {
|
|
51
|
-
let j = measurements[0],
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
let j = measurements[0],
|
|
53
|
+
k = measurements[1];
|
|
54
|
+
while (!this.reachedGoal(measurements)) {
|
|
55
|
+
if (j === this.x && moveCount === 0) {
|
|
54
56
|
j = 0;
|
|
55
57
|
k = this.x;
|
|
56
|
-
} else if(j == 0) {
|
|
58
|
+
} else if (j == 0) {
|
|
57
59
|
j = this.x;
|
|
58
|
-
} else if(j == this.x && k < this.y) {
|
|
59
|
-
|
|
60
|
+
} else if (j == this.x && k < this.y) {
|
|
61
|
+
const tempK = k;
|
|
60
62
|
k + j > this.y ? k = this.y : k = tempK + j;
|
|
61
|
-
tempK + j > this.y ? j
|
|
62
|
-
} else if(k === this.y) {
|
|
63
|
+
tempK + j > this.y ? j -= (this.y - tempK) : j = 0;
|
|
64
|
+
} else if (k === this.y) {
|
|
63
65
|
k = 0;
|
|
64
|
-
} else if(k === 0 && j < this.x) {
|
|
66
|
+
} else if (k === 0 && j < this.x) {
|
|
65
67
|
k = j;
|
|
66
68
|
j = 0;
|
|
67
69
|
}
|
|
68
|
-
measurements = [j,k];
|
|
70
|
+
measurements = [j, k];
|
|
69
71
|
moveCount++;
|
|
70
72
|
prBool = !prBool;
|
|
71
73
|
}
|
|
@@ -74,19 +76,20 @@ class TwoBucket {
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
moves() {
|
|
77
|
-
let j = 0,
|
|
79
|
+
let j = 0,
|
|
80
|
+
k = 0; // j will be running val of bucket one, k = running val of bucket two
|
|
78
81
|
this.starter === 'one' ? j = this.x : k = this.y;
|
|
79
|
-
|
|
82
|
+
const measurements = [j, k];
|
|
80
83
|
let moveCount = 0;
|
|
81
|
-
|
|
84
|
+
const prBool = true; // pour / receive boolean - need to pour or receive every other turn
|
|
82
85
|
|
|
83
|
-
if(this.starter === 'one') {
|
|
86
|
+
if (this.starter === 'one') {
|
|
84
87
|
moveCount = this.smallFirst(measurements, moveCount, prBool);
|
|
85
88
|
} else {
|
|
86
89
|
moveCount = this.bigFirst(measurements, moveCount, prBool);
|
|
87
90
|
}
|
|
88
91
|
|
|
89
|
-
return moveCount + 1; //accounts for first move made before loop (and moveCount starts at zero before loop)
|
|
92
|
+
return moveCount + 1; // accounts for first move made before loop (and moveCount starts at zero before loop)
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import TwoBucket from './two-bucket';
|
|
2
2
|
|
|
3
3
|
describe('TwoBucket', () => {
|
|
4
|
-
|
|
5
4
|
describe('works for input of 3, 5, 1', () => {
|
|
6
5
|
const buckOne = 3;
|
|
7
6
|
const buckTwo = 5;
|
|
8
7
|
const goal = 1;
|
|
9
8
|
|
|
10
9
|
test('starting with bucket one', () => {
|
|
11
|
-
const starterBuck = 'one'; //indicates which bucket to fill first
|
|
10
|
+
const starterBuck = 'one'; // indicates which bucket to fill first
|
|
12
11
|
const twoBucket = new TwoBucket(buckOne, buckTwo, goal, starterBuck);
|
|
13
|
-
expect(twoBucket.moves()).toEqual(4); //includes the first fill
|
|
14
|
-
expect(twoBucket.goalBucket).toEqual('one'); //which bucket should end up with the desired # of liters
|
|
15
|
-
expect(twoBucket.otherBucket).toEqual(5); //leftover value in the "other" bucket once the goal has been reached
|
|
12
|
+
expect(twoBucket.moves()).toEqual(4); // includes the first fill
|
|
13
|
+
expect(twoBucket.goalBucket).toEqual('one'); // which bucket should end up with the desired # of liters
|
|
14
|
+
expect(twoBucket.otherBucket).toEqual(5); // leftover value in the "other" bucket once the goal has been reached
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
xtest('starting with bucket two', () => {
|
|
@@ -22,7 +21,6 @@ describe('TwoBucket', () => {
|
|
|
22
21
|
expect(twoBucket.goalBucket).toEqual('two');
|
|
23
22
|
expect(twoBucket.otherBucket).toEqual(3);
|
|
24
23
|
});
|
|
25
|
-
|
|
26
24
|
});
|
|
27
25
|
|
|
28
26
|
describe('works for input of 7, 11, 2', () => {
|
|
@@ -45,7 +43,5 @@ describe('TwoBucket', () => {
|
|
|
45
43
|
expect(twoBucket.goalBucket).toEqual('two');
|
|
46
44
|
expect(twoBucket.otherBucket).toEqual(7);
|
|
47
45
|
});
|
|
48
|
-
|
|
49
46
|
});
|
|
50
|
-
|
|
51
47
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Words from './word-count';
|
|
2
2
|
|
|
3
3
|
describe('words()', () => {
|
|
4
|
-
|
|
4
|
+
const words = new Words();
|
|
5
5
|
|
|
6
6
|
test('counts one word', () => {
|
|
7
7
|
const expectedCounts = { word: 1 };
|
|
@@ -59,8 +59,7 @@ describe('words()', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
xtest('handles properties that exist on Object’s prototype', () => {
|
|
62
|
-
const expectedCounts = { reserved: 1, words
|
|
62
|
+
const expectedCounts = { reserved: 1, words: 1, like: 1, constructor: 1, and: 1, tostring: 1, 'ok?': 1 };
|
|
63
63
|
expect(words.count('reserved words like constructor and toString ok?')).toEqual(expectedCounts);
|
|
64
64
|
});
|
|
65
|
-
|
|
66
65
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const ArgumentError = () => ({
|
|
2
|
-
name:
|
|
3
|
-
message:
|
|
2
|
+
name: 'argument error',
|
|
3
|
+
message: 'oops',
|
|
4
4
|
});
|
|
5
5
|
|
|
6
6
|
const re = new RegExp(/(plus|minus|divided by|multiplied by)+/g);
|
|
@@ -17,12 +17,12 @@ class Wordy {
|
|
|
17
17
|
throw new ArgumentError();
|
|
18
18
|
}
|
|
19
19
|
let ii = 1,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
jj = 0,
|
|
21
|
+
result = +this.numbers[0];
|
|
22
22
|
|
|
23
23
|
while (ii < this.numbers.length + 1) {
|
|
24
24
|
const op = this.operands[jj++],
|
|
25
|
-
|
|
25
|
+
b = +this.numbers[ii++] || null;
|
|
26
26
|
switch (op) {
|
|
27
27
|
case 'plus' :
|
|
28
28
|
result += b;
|
|
@@ -42,4 +42,4 @@ class Wordy {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export { Wordy as WordProblem, ArgumentError
|
|
45
|
+
export { Wordy as WordProblem, ArgumentError };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WordProblem, ArgumentError } from './wordy';
|
|
2
2
|
|
|
3
3
|
describe('Word Problem', () => {
|
|
4
|
-
|
|
5
4
|
test('add 1', () => {
|
|
6
5
|
const question = 'What is 1 plus 1?';
|
|
7
6
|
expect(new WordProblem(question).answer()).toEqual(2);
|
|
@@ -74,16 +73,15 @@ describe('Word Problem', () => {
|
|
|
74
73
|
|
|
75
74
|
xtest('too advanced', () => {
|
|
76
75
|
const question = 'What is 53 cubed?';
|
|
77
|
-
const problem
|
|
76
|
+
const problem = new WordProblem(question);
|
|
78
77
|
|
|
79
78
|
expect(problem.answer.bind(problem)).toThrow(new ArgumentError());
|
|
80
79
|
});
|
|
81
80
|
|
|
82
81
|
xtest('irrelevant', () => {
|
|
83
82
|
const question = 'Who is the president of the United States?';
|
|
84
|
-
const problem
|
|
83
|
+
const problem = new WordProblem(question);
|
|
85
84
|
|
|
86
85
|
expect(problem.answer.bind(problem)).toThrow(new ArgumentError());
|
|
87
86
|
});
|
|
88
|
-
|
|
89
87
|
});
|
data/tracks/factor/config.json
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
"test_pattern": "TODO",
|
|
7
7
|
"exercises": [
|
|
8
8
|
{
|
|
9
|
+
"uuid": "c81c4175-f06b-404d-8c01-c4a6dba661d3",
|
|
9
10
|
"slug": "hello-world",
|
|
11
|
+
"core": false,
|
|
12
|
+
"unlocked_by": null,
|
|
10
13
|
"difficulty": 1,
|
|
11
14
|
"topics": [
|
|
12
15
|
"word definition",
|
|
@@ -14,7 +17,10 @@
|
|
|
14
17
|
]
|
|
15
18
|
},
|
|
16
19
|
{
|
|
20
|
+
"uuid": "17fb2814-2164-4933-8f72-adeb9b2b5ccf",
|
|
17
21
|
"slug": "leap",
|
|
22
|
+
"core": false,
|
|
23
|
+
"unlocked_by": null,
|
|
18
24
|
"difficulty": 3,
|
|
19
25
|
"topics": [
|
|
20
26
|
"quotations",
|
|
@@ -24,7 +30,10 @@
|
|
|
24
30
|
]
|
|
25
31
|
},
|
|
26
32
|
{
|
|
33
|
+
"uuid": "22c5c529-07bb-4df2-8d2f-e470d1ed48da",
|
|
27
34
|
"slug": "two-fer",
|
|
35
|
+
"core": false,
|
|
36
|
+
"unlocked_by": null,
|
|
28
37
|
"difficulty": 2,
|
|
29
38
|
"topics": [
|
|
30
39
|
"word definition",
|
|
@@ -34,17 +43,17 @@
|
|
|
34
43
|
]
|
|
35
44
|
},
|
|
36
45
|
{
|
|
46
|
+
"uuid": "d3afeeb3-8c4e-4a31-81a2-fb039ab3c5af",
|
|
37
47
|
"slug": "isogram",
|
|
48
|
+
"core": false,
|
|
49
|
+
"unlocked_by": null,
|
|
38
50
|
"difficulty": 1,
|
|
39
51
|
"topics": [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
"word definition",
|
|
53
|
+
"stack effect",
|
|
54
|
+
"strings"
|
|
43
55
|
]
|
|
44
56
|
}
|
|
45
|
-
],
|
|
46
|
-
"deprecated": [
|
|
47
|
-
|
|
48
57
|
],
|
|
49
58
|
"foregone": [
|
|
50
59
|
|