trackler 2.2.1.49 → 2.2.1.50
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/bin/verify-configs +1 -1
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/kindergarten-garden/canonical-data.json +0 -37
- data/tracks/c/exercises/allergies/test/test_allergies.c +41 -41
- data/tracks/common-lisp/config.json +266 -252
- data/tracks/common-lisp/config/maintainers.json +23 -23
- data/tracks/common-lisp/exercises/allergies/README.md +0 -1
- data/tracks/common-lisp/exercises/atbash-cipher/README.md +2 -1
- data/tracks/common-lisp/exercises/beer-song/README.md +1 -1
- data/tracks/common-lisp/exercises/binary/README.md +2 -0
- data/tracks/common-lisp/exercises/collatz-conjecture/README.md +4 -8
- data/tracks/common-lisp/exercises/crypto-square/README.md +4 -4
- data/tracks/common-lisp/exercises/etl/README.md +2 -0
- data/tracks/common-lisp/exercises/grade-school/README.md +0 -1
- data/tracks/common-lisp/exercises/grains/README.md +0 -1
- data/tracks/common-lisp/exercises/leap/README.md +1 -1
- data/tracks/common-lisp/exercises/meetup/README.md +1 -2
- data/tracks/common-lisp/exercises/nucleotide-count/README.md +8 -22
- data/tracks/common-lisp/exercises/pascals-triangle/README.md +1 -1
- data/tracks/common-lisp/exercises/perfect-numbers/README.md +3 -4
- data/tracks/common-lisp/exercises/phone-number/README.md +3 -2
- data/tracks/common-lisp/exercises/roman-numerals/README.md +1 -1
- data/tracks/common-lisp/exercises/scrabble-score/README.md +3 -1
- data/tracks/common-lisp/exercises/space-age/README.md +2 -1
- data/tracks/common-lisp/exercises/sublist/README.md +65 -0
- data/tracks/common-lisp/exercises/sublist/example.lisp +24 -0
- data/tracks/common-lisp/exercises/sublist/sublist-test.lisp +87 -0
- data/tracks/common-lisp/exercises/sublist/sublist.lisp +8 -0
- data/tracks/common-lisp/exercises/triangle/README.md +9 -6
- data/tracks/common-lisp/exercises/trinary/README.md +1 -1
- data/tracks/common-lisp/exercises/word-count/README.md +1 -2
- data/tracks/ecmascript/config.json +30 -0
- data/tracks/ecmascript/exercises/bowling/README.md +80 -0
- data/tracks/ecmascript/exercises/bowling/bowling.spec.js +159 -0
- data/tracks/ecmascript/exercises/bowling/example.js +67 -0
- data/tracks/ecmascript/exercises/bowling/package.json +71 -0
- data/tracks/ecmascript/exercises/two-fer/README.md +47 -0
- data/tracks/ecmascript/exercises/two-fer/example.js +4 -0
- data/tracks/ecmascript/exercises/two-fer/package.json +69 -0
- data/tracks/ecmascript/exercises/two-fer/two-fer.spec.js +18 -0
- data/tracks/fsharp/exercises/pascals-triangle/Example.fs +12 -8
- data/tracks/fsharp/exercises/pascals-triangle/PascalsTriangle.fs +2 -2
- data/tracks/fsharp/exercises/pascals-triangle/PascalsTriangleTest.fs +15 -12
- data/tracks/fsharp/generators/Generators.fs +19 -0
- data/tracks/fsharp/generators/Templates/_AssertThrows.liquid +1 -0
- data/tracks/java/docs/ABOUT.md +13 -31
- data/tracks/java/exercises/bracket-push/.meta/version +1 -1
- data/tracks/java/exercises/bracket-push/src/test/java/BracketCheckerTest.java +7 -1
- data/tracks/java/exercises/collatz-conjecture/.meta/version +1 -1
- data/tracks/java/exercises/etl/README.md +1 -1
- data/tracks/java/exercises/ocr-numbers/README.md +1 -1
- data/tracks/java/exercises/pascals-triangle/README.md +1 -1
- data/tracks/java/exercises/perfect-numbers/.meta/version +1 -1
- data/tracks/java/exercises/rna-transcription/README.md +1 -1
- data/tracks/java/exercises/secret-handshake/.meta/version +1 -1
- data/tracks/java/exercises/secret-handshake/src/test/java/HandshakeCalculatorTest.java +1 -9
- data/tracks/java/scripts/canonical_data_check.sh +104 -0
- data/tracks/javascript/exercises/twelve-days/example.js +23 -25
- data/tracks/julia/.travis.yml +1 -0
- data/tracks/kotlin/exercises/all-your-base/.meta/version +1 -0
- data/tracks/kotlin/exercises/all-your-base/src/test/kotlin/BaseConverterTest.kt +0 -3
- data/tracks/kotlin/exercises/change/.meta/version +1 -0
- data/tracks/kotlin/exercises/change/src/test/kotlin/ChangeCalculatorTest.kt +0 -3
- data/tracks/kotlin/exercises/clock/.meta/version +1 -0
- data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockAddTest.kt +1 -4
- data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockCreationTest.kt +1 -4
- data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockEqualTest.kt +1 -4
- data/tracks/kotlin/exercises/collatz-conjecture/.meta/version +1 -0
- data/tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt +0 -3
- data/tracks/kotlin/exercises/complex-numbers/.meta/version +1 -0
- data/tracks/kotlin/exercises/complex-numbers/src/test/kotlin/ComplexNumberTest.kt +0 -3
- data/tracks/kotlin/exercises/diamond/.meta/version +1 -0
- data/tracks/kotlin/exercises/diamond/src/test/kotlin/DiamondPrinterTest.kt +0 -3
- data/tracks/kotlin/exercises/etl/README.md +1 -1
- data/tracks/kotlin/exercises/forth/.meta/version +1 -0
- data/tracks/kotlin/exercises/forth/src/test/kotlin/ForthEvaluatorTest.kt +0 -3
- data/tracks/kotlin/exercises/grains/.meta/version +1 -0
- data/tracks/kotlin/exercises/grains/src/test/kotlin/BoardTest.kt +0 -3
- data/tracks/kotlin/exercises/hamming/.meta/version +1 -0
- data/tracks/kotlin/exercises/hamming/src/test/kotlin/HammingTest.kt +0 -3
- data/tracks/kotlin/exercises/list-ops/.meta/version +1 -0
- data/tracks/kotlin/exercises/list-ops/src/test/kotlin/ListExtensionsTest.kt +0 -3
- data/tracks/kotlin/exercises/meetup/.meta/version +1 -0
- data/tracks/kotlin/exercises/meetup/src/test/kotlin/MeetupTest.kt +0 -3
- data/tracks/kotlin/exercises/minesweeper/.meta/version +1 -0
- data/tracks/kotlin/exercises/minesweeper/src/test/kotlin/MinesweeperBoardTest.kt +0 -3
- data/tracks/kotlin/exercises/pangram/.meta/version +1 -0
- data/tracks/kotlin/exercises/pangram/src/test/kotlin/PangramTest.kt +0 -3
- data/tracks/kotlin/exercises/pascals-triangle/README.md +1 -1
- data/tracks/kotlin/exercises/prime-factors/.meta/version +1 -0
- data/tracks/kotlin/exercises/prime-factors/src/test/kotlin/PrimeFactorCalculatorTest.kt +0 -3
- data/tracks/kotlin/exercises/rna-transcription/.meta/version +1 -0
- data/tracks/kotlin/exercises/rna-transcription/README.md +1 -1
- data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +0 -3
- data/tracks/kotlin/exercises/robot-simulator/.meta/version +1 -0
- data/tracks/kotlin/exercises/robot-simulator/src/test/kotlin/RobotTest.kt +0 -3
- data/tracks/kotlin/exercises/rotational-cipher/.meta/version +1 -0
- data/tracks/kotlin/exercises/rotational-cipher/src/test/kotlin/RotationalCipherTest.kt +0 -3
- data/tracks/kotlin/exercises/saddle-points/.meta/version +1 -0
- data/tracks/kotlin/exercises/saddle-points/src/test/kotlin/MatrixTest.kt +0 -3
- data/tracks/kotlin/exercises/say/.meta/version +1 -0
- data/tracks/kotlin/exercises/say/src/test/kotlin/NumberSpellerTest.kt +0 -3
- data/tracks/kotlin/exercises/secret-handshake/.meta/version +1 -0
- data/tracks/kotlin/exercises/secret-handshake/src/test/kotlin/HandshakeCalculatorTest.kt +0 -3
- data/tracks/kotlin/exercises/spiral-matrix/.meta/version +1 -0
- data/tracks/kotlin/exercises/spiral-matrix/src/test/kotlin/SpiralMatrixTest.kt +0 -3
- data/tracks/kotlin/exercises/sublist/.meta/version +1 -0
- data/tracks/kotlin/exercises/sublist/src/test/kotlin/SublistTest.kt +0 -3
- data/tracks/kotlin/scripts/canonical_data_check.sh +104 -0
- data/tracks/perl6/exercises/accumulate/accumulate.t +2 -3
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +17 -18
- data/tracks/perl6/exercises/allergies/allergies.t +17 -18
- data/tracks/perl6/exercises/anagram/anagram.t +17 -18
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +17 -18
- data/tracks/perl6/exercises/bob/bob.t +20 -22
- data/tracks/perl6/exercises/bob/example.yaml +1 -2
- data/tracks/perl6/exercises/clock/clock.t +17 -18
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +17 -18
- data/tracks/perl6/exercises/grade-school/grade-school.t +2 -3
- data/tracks/perl6/exercises/grains/grains.t +17 -18
- data/tracks/perl6/exercises/hello-world/example.yaml +1 -2
- data/tracks/perl6/exercises/hello-world/hello-world.t +20 -22
- data/tracks/perl6/exercises/leap/leap.t +17 -18
- data/tracks/perl6/exercises/linked-list/linked-list.t +2 -3
- data/tracks/perl6/exercises/luhn/luhn.t +17 -18
- data/tracks/perl6/exercises/phone-number/phone-number.t +17 -18
- data/tracks/perl6/exercises/raindrops/raindrops.t +17 -18
- data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +17 -18
- data/tracks/perl6/exercises/robot-name/robot-name.t +2 -3
- data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +17 -18
- data/tracks/perl6/exercises/space-age/space-age.t +17 -18
- data/tracks/perl6/exercises/word-count/word-count.t +17 -18
- data/tracks/perl6/exercises/wordy/wordy.t +17 -18
- data/tracks/perl6/templates/test.mustache +9 -10
- data/tracks/purescript/config.json +11 -0
- data/tracks/purescript/exercises/rna-transcription/README.md +25 -0
- data/tracks/purescript/exercises/rna-transcription/bower.json +26 -0
- data/tracks/purescript/exercises/rna-transcription/examples/src/RNATranscription.purs +18 -0
- data/tracks/purescript/exercises/rna-transcription/src/RNATranscription.purs +3 -0
- data/tracks/purescript/exercises/rna-transcription/test/Main.purs +48 -0
- data/tracks/python/exercises/variable-length-quantity/example.py +6 -6
- data/tracks/python/exercises/variable-length-quantity/variable_length_quantity.py +2 -2
- data/tracks/ruby/config.json +6 -0
- data/tracks/ruby/exercises/complex-numbers/.meta/.version +1 -0
- data/tracks/ruby/exercises/complex-numbers/.meta/generator/complex_numbers_case.rb +44 -0
- data/tracks/ruby/exercises/complex-numbers/.meta/solutions/complex_numbers.rb +49 -0
- data/tracks/ruby/exercises/complex-numbers/README.md +64 -0
- data/tracks/ruby/exercises/complex-numbers/complex_numbers_test.rb +207 -0
- data/tracks/ruby/exercises/crypto-square/.meta/.version +1 -0
- data/tracks/ruby/exercises/crypto-square/.meta/generator/crypto_square_case.rb +19 -0
- data/tracks/ruby/exercises/crypto-square/.meta/solutions/crypto_square.rb +20 -15
- data/tracks/ruby/exercises/crypto-square/README.md +10 -8
- data/tracks/ruby/exercises/crypto-square/crypto_square_test.rb +45 -81
- data/tracks/ruby/exercises/flatten-array/.meta/.version +1 -0
- data/tracks/ruby/exercises/flatten-array/.meta/generator/flatten_array_case.rb +11 -0
- data/tracks/ruby/exercises/flatten-array/.meta/solutions/flatten_array.rb +5 -2
- data/tracks/ruby/exercises/flatten-array/flatten_array_test.rb +32 -7
- data/tracks/ruby/exercises/hamming/hamming_test.rb +3 -3
- data/tracks/ruby/exercises/isogram/isogram_test.rb +4 -4
- data/tracks/ruby/exercises/leap/leap_test.rb +2 -2
- data/tracks/ruby/exercises/pig-latin/.meta/.version +1 -1
- data/tracks/ruby/exercises/pig-latin/.meta/solutions/pig_latin.rb +2 -2
- data/tracks/ruby/exercises/pig-latin/pig_latin_test.rb +17 -7
- data/tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb +1 -1
- data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +7 -7
- data/tracks/ruby/exercises/sum-of-multiples/.meta/.version +1 -1
- data/tracks/ruby/exercises/sum-of-multiples/.meta/solutions/sum_of_multiples.rb +1 -1
- data/tracks/ruby/exercises/sum-of-multiples/sum_of_multiples_test.rb +7 -2
- metadata +53 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export default class Bowling {
|
|
2
|
+
constructor(rolls) {
|
|
3
|
+
this.rolls = rolls;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
score() {
|
|
7
|
+
const initialState = {
|
|
8
|
+
frameNumber: 1,
|
|
9
|
+
rollNumber: 1,
|
|
10
|
+
pinsRemaining: 10,
|
|
11
|
+
spareLastFrame: false,
|
|
12
|
+
strikeLastFrame: false,
|
|
13
|
+
twoStrikesInARow: false,
|
|
14
|
+
fillBall: false,
|
|
15
|
+
score: 0,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const finalState = this.rolls.reduce((state, roll) => {
|
|
19
|
+
if (roll < 0 || roll > 10) {
|
|
20
|
+
throw new Error('Pins must have a value from 0 to 10');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (roll > state.pinsRemaining) {
|
|
24
|
+
throw new Error('Pin count exceeds pins on the lane');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (state.frameNumber > 10) {
|
|
28
|
+
throw new Error('Should not be able to roll after game is over');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const finalFrame = state.frameNumber === 10;
|
|
32
|
+
const strike = state.rollNumber === 1 && roll === 10;
|
|
33
|
+
const spare = state.rollNumber === 2 && roll === state.pinsRemaining;
|
|
34
|
+
const frameOver = finalFrame
|
|
35
|
+
? (!state.fillBall && !spare && state.rollNumber === 2) || state.rollNumber === 3
|
|
36
|
+
: strike || spare || state.rollNumber === 2;
|
|
37
|
+
|
|
38
|
+
let score = state.score + roll;
|
|
39
|
+
|
|
40
|
+
if (state.strikeLastFrame && state.rollNumber < 3) { score += roll; }
|
|
41
|
+
if (state.spareLastFrame && state.rollNumber === 1) { score += roll; }
|
|
42
|
+
if (state.twoStrikesInARow && state.rollNumber === 1) { score += roll; }
|
|
43
|
+
|
|
44
|
+
const next = {};
|
|
45
|
+
|
|
46
|
+
next.frameNumber = frameOver ? state.frameNumber + 1 : state.frameNumber;
|
|
47
|
+
next.rollNumber = frameOver ? 1 : state.rollNumber + 1;
|
|
48
|
+
next.pinsRemaining = finalFrame
|
|
49
|
+
? ((strike || spare) ? 10 : state.pinsRemaining - roll)
|
|
50
|
+
: (frameOver ? 10 : state.pinsRemaining - roll);
|
|
51
|
+
next.spareLastFrame = frameOver ? spare : state.spareLastFrame;
|
|
52
|
+
next.strikeLastFrame = frameOver ? strike : state.strikeLastFrame;
|
|
53
|
+
next.twoStrikesInARow = frameOver ? strike && state.strikeLastFrame : state.twoStrikesInARow;
|
|
54
|
+
next.fillBall = next.fillBall || (finalFrame && (strike || spare));
|
|
55
|
+
next.score = score;
|
|
56
|
+
|
|
57
|
+
return next;
|
|
58
|
+
}, initialState);
|
|
59
|
+
|
|
60
|
+
if (finalState.frameNumber !== 11) {
|
|
61
|
+
throw new Error('Score cannot be taken until the end of the game');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return finalState.score;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xecmascript",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Exercism exercises in ECMAScript 6.",
|
|
5
|
+
"author": "Katrina Owen",
|
|
6
|
+
"private": true,
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/exercism/xecmascript"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"babel-jest": "^20.0.3",
|
|
13
|
+
"babel-plugin-transform-builtin-extend": "^1.1.2",
|
|
14
|
+
"babel-preset-env": "^1.4.0",
|
|
15
|
+
"eslint": "^3.19.0",
|
|
16
|
+
"eslint-config-airbnb": "^15.0.1",
|
|
17
|
+
"eslint-plugin-import": "^2.2.0",
|
|
18
|
+
"eslint-plugin-jsx-a11y": "^5.0.1",
|
|
19
|
+
"eslint-plugin-react": "^7.0.1",
|
|
20
|
+
"jest": "^20.0.4"
|
|
21
|
+
},
|
|
22
|
+
"jest": {
|
|
23
|
+
"modulePathIgnorePatterns": [
|
|
24
|
+
"package.json"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"babel": {
|
|
28
|
+
"presets": [
|
|
29
|
+
"env"
|
|
30
|
+
],
|
|
31
|
+
"plugins": [
|
|
32
|
+
[
|
|
33
|
+
"babel-plugin-transform-builtin-extend",
|
|
34
|
+
{
|
|
35
|
+
"globals": [
|
|
36
|
+
"Error"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
"transform-regenerator"
|
|
42
|
+
]
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "jest --no-cache ./*",
|
|
47
|
+
"watch": "jest --no-cache --watch ./*",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"lint-test": "eslint . && jest --no-cache ./* "
|
|
50
|
+
},
|
|
51
|
+
"eslintConfig": {
|
|
52
|
+
"parserOptions": {
|
|
53
|
+
"ecmaVersion": 6,
|
|
54
|
+
"sourceType": "module"
|
|
55
|
+
},
|
|
56
|
+
"env": {
|
|
57
|
+
"es6": true,
|
|
58
|
+
"node": true,
|
|
59
|
+
"jest": true
|
|
60
|
+
},
|
|
61
|
+
"extends": "airbnb",
|
|
62
|
+
"rules": {
|
|
63
|
+
"import/no-unresolved": "off",
|
|
64
|
+
"import/extensions": "off"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"licenses": [
|
|
68
|
+
"MIT"
|
|
69
|
+
],
|
|
70
|
+
"dependencies": {}
|
|
71
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Two Fer
|
|
2
|
+
|
|
3
|
+
Create a sentence of the form "One for X, one for me."
|
|
4
|
+
|
|
5
|
+
`Two-fer` or `2-fer` is short for two for one. One for you and one for me.
|
|
6
|
+
|
|
7
|
+
```plain
|
|
8
|
+
"One for X, one for me."
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
When X is a name or "you".
|
|
12
|
+
|
|
13
|
+
If the given name is "Alice", the result should be "One for Alice, one for me." If no name is given, the result should be "One for you, one for me."
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
Go through the setup instructions for ECMAScript to
|
|
18
|
+
install the necessary dependencies:
|
|
19
|
+
|
|
20
|
+
http://exercism.io/languages/ecmascript
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
Install assignment dependencies:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
$ npm install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Making the test suite pass
|
|
31
|
+
|
|
32
|
+
Execute the tests with:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
$ npm test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In the test suites all tests but the first have been skipped.
|
|
39
|
+
|
|
40
|
+
Once you get a test passing, you can enable the next one by
|
|
41
|
+
changing `xtest` to `test`.
|
|
42
|
+
|
|
43
|
+
## Source
|
|
44
|
+
This is an exercise to introduce users to basic programming constructs, just after Hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
|
|
45
|
+
|
|
46
|
+
## Submitting Incomplete Solutions
|
|
47
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xecmascript",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Exercism exercises in ECMAScript 6.",
|
|
5
|
+
"author": "Katrina Owen",
|
|
6
|
+
"private": true,
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/exercism/xecmascript"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"babel-jest": "^20.0.3",
|
|
13
|
+
"babel-plugin-transform-builtin-extend": "^1.1.2",
|
|
14
|
+
"babel-preset-env": "^1.4.0",
|
|
15
|
+
"eslint": "^3.19.0",
|
|
16
|
+
"eslint-config-airbnb": "^15.0.1",
|
|
17
|
+
"eslint-plugin-import": "^2.2.0",
|
|
18
|
+
"eslint-plugin-jsx-a11y": "^5.0.1",
|
|
19
|
+
"eslint-plugin-react": "^7.0.1",
|
|
20
|
+
"jest": "^20.0.4"
|
|
21
|
+
},
|
|
22
|
+
"jest": {
|
|
23
|
+
"modulePathIgnorePatterns": [
|
|
24
|
+
"package.json"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"babel": {
|
|
28
|
+
"presets": [
|
|
29
|
+
"env"
|
|
30
|
+
],
|
|
31
|
+
"plugins": [
|
|
32
|
+
[
|
|
33
|
+
"babel-plugin-transform-builtin-extend",
|
|
34
|
+
{
|
|
35
|
+
"globals": [
|
|
36
|
+
"Error"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
["transform-regenerator"]
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "jest --no-cache ./*",
|
|
45
|
+
"watch": "jest --no-cache --watch ./*",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"lint-test": "eslint . && jest --no-cache ./* "
|
|
48
|
+
},
|
|
49
|
+
"eslintConfig": {
|
|
50
|
+
"parserOptions": {
|
|
51
|
+
"ecmaVersion": 6,
|
|
52
|
+
"sourceType": "module"
|
|
53
|
+
},
|
|
54
|
+
"env": {
|
|
55
|
+
"es6": true,
|
|
56
|
+
"node": true,
|
|
57
|
+
"jest": true
|
|
58
|
+
},
|
|
59
|
+
"extends": "airbnb",
|
|
60
|
+
"rules": {
|
|
61
|
+
"import/no-unresolved": "off",
|
|
62
|
+
"import/extensions": "off"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"licenses": [
|
|
66
|
+
"MIT"
|
|
67
|
+
],
|
|
68
|
+
"dependencies": {}
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import twoFer from './two-fer';
|
|
2
|
+
|
|
3
|
+
describe('twoFer()', () => {
|
|
4
|
+
test('no name given', () => {
|
|
5
|
+
const name = '';
|
|
6
|
+
expect(twoFer(name)).toEqual('One for you, one for me.');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
xtest('a name given', () => {
|
|
10
|
+
const name = 'Alice';
|
|
11
|
+
expect(twoFer(name)).toEqual('One for Alice, one for me.');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
xtest('another name given', () => {
|
|
15
|
+
const name = 'Bob';
|
|
16
|
+
expect(twoFer(name)).toEqual('One for Bob, one for me.');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
module PascalsTriangle
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
let rows numberOfRows : int list list option =
|
|
4
|
+
match numberOfRows with
|
|
5
|
+
| r when r < 0 -> None
|
|
6
|
+
| _ ->
|
|
7
|
+
let row i =
|
|
8
|
+
[1 .. i - 1]
|
|
9
|
+
|> List.scan (fun acc j -> acc * (i - j) / j) 1
|
|
10
|
+
|
|
11
|
+
[1..numberOfRows]
|
|
12
|
+
|> List.map row
|
|
13
|
+
|> Some
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module PascalsTriangle
|
|
2
|
-
|
|
3
|
-
let
|
|
2
|
+
|
|
3
|
+
let rows numberOfRows : int list list option = failwith "You need to implement this function."
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
+
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
|
2
|
+
|
|
1
3
|
module PascalsTriangleTest
|
|
2
4
|
|
|
3
|
-
open Xunit
|
|
4
5
|
open FsUnit.Xunit
|
|
6
|
+
open Xunit
|
|
5
7
|
|
|
6
8
|
open PascalsTriangle
|
|
7
9
|
|
|
8
10
|
[<Fact>]
|
|
9
|
-
let ``
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
let ``Zero rows`` () =
|
|
12
|
+
rows 0 |> should equal (Some ([]: int list list))
|
|
13
|
+
|
|
14
|
+
[<Fact(Skip = "Remove to run test")>]
|
|
15
|
+
let ``Single row`` () =
|
|
16
|
+
rows 1 |> should equal (Some [[1]])
|
|
17
|
+
|
|
12
18
|
[<Fact(Skip = "Remove to run test")>]
|
|
13
19
|
let ``Two rows`` () =
|
|
14
|
-
|
|
20
|
+
rows 2 |> should equal (Some [[1]; [1; 1]])
|
|
15
21
|
|
|
16
22
|
[<Fact(Skip = "Remove to run test")>]
|
|
17
23
|
let ``Three rows`` () =
|
|
18
|
-
|
|
24
|
+
rows 3 |> should equal (Some [[1]; [1; 1]; [1; 2; 1]])
|
|
19
25
|
|
|
20
26
|
[<Fact(Skip = "Remove to run test")>]
|
|
21
27
|
let ``Four rows`` () =
|
|
22
|
-
|
|
28
|
+
rows 4 |> should equal (Some [[1]; [1; 1]; [1; 2; 1]; [1; 3; 3; 1]])
|
|
23
29
|
|
|
24
30
|
[<Fact(Skip = "Remove to run test")>]
|
|
25
|
-
let ``
|
|
26
|
-
|
|
31
|
+
let ``Negative rows`` () =
|
|
32
|
+
rows -1 |> should equal None
|
|
27
33
|
|
|
28
|
-
[<Fact(Skip = "Remove to run test")>]
|
|
29
|
-
let ``Twenty rows`` () =
|
|
30
|
-
triangle 20 |> List.last |> should equal [1; 19; 171; 969; 3876; 11628; 27132; 50388; 75582; 92378; 92378; 75582; 50388; 27132; 11628; 3876; 969; 171; 19; 1]
|
|
@@ -207,6 +207,25 @@ type PerfectNumbers() =
|
|
|
207
207
|
| "deficient" -> "(Some Deficient)"
|
|
208
208
|
| _ -> "None"
|
|
209
209
|
|
|
210
|
+
type PascalsTriangle() =
|
|
211
|
+
inherit Exercise()
|
|
212
|
+
|
|
213
|
+
override this.RenderExpected (canonicalDataCase, key, value) =
|
|
214
|
+
match value with
|
|
215
|
+
| :? JArray ->
|
|
216
|
+
match value :?> JArray |> Seq.isEmpty with
|
|
217
|
+
| true -> "(Some ([]: int list list))"
|
|
218
|
+
| false ->
|
|
219
|
+
value :?> JArray
|
|
220
|
+
|> normalizeJArray
|
|
221
|
+
|> Seq.map formatValue
|
|
222
|
+
|> formatList
|
|
223
|
+
|> sprintf "(Some %s)"
|
|
224
|
+
|
|
225
|
+
| _ -> "None"
|
|
226
|
+
|
|
227
|
+
override this.ToTestMethodBodyAssertTemplate canonicalDataCase = "AssertEqual"
|
|
228
|
+
|
|
210
229
|
type PhoneNumber() =
|
|
211
230
|
inherit Exercise()
|
|
212
231
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(fun () -> {{ Sut }} |> ignore) |> should throw typeof<{{ Expected }}>
|
data/tracks/java/docs/ABOUT.md
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
|
+
[Java](https://go.java/index.html) is among the most popular available programming languages, thanks to its versatility and compatibility.
|
|
2
|
+
It is widely used for software development, mobile applications and developing larger systems.
|
|
1
3
|
|
|
2
|
-
[
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Java was born in 1995 and is maintained by [Oracle](https://www.oracle.com/index.html).
|
|
5
|
+
Despite the fact that it isn't as young as some of the fresh languages out there, Java is still really popular.
|
|
6
|
+
It was designed to be fast, secure, reliable, beginner-friendly and highly portable.
|
|
7
|
+
This portability perk exists because Java is executed on a cross-platform compatible [Java Virtual Machine - JVM](https://en.wikipedia.org/wiki/Java_virtual_machine).
|
|
8
|
+
Android apps are also developed using Java, since the [Android Operating System](https://en.wikipedia.org/wiki/Android_(operating_system)) runs on a Java language environment.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
The Java community is huge!
|
|
11
|
+
GitHub for example has over 1.5 million Java projects.
|
|
12
|
+
It's also worth mentioning that Java has the second largest community in [StackOverflow](https://stackoverflow.com/questions/tagged/java)!
|
|
13
|
+
This is important because the larger a programming language community is, the more support you'd be likely to get.
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
Java also has a powerful and well-designed set of built-in [APIs - Application Programming Interfaces](https://docs.oracle.com/javase/8/docs/api/), which can be used for various activities like Database connection, networking, I/O, XML parsing, utilities, and much more.
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
- It must be robust and secure.
|
|
13
|
-
- It must be architecture-neutral and portable.
|
|
14
|
-
- It must execute with high performance.
|
|
15
|
-
- It must be interpreted, threaded, and dynamic.
|
|
16
|
-
|
|
17
|
-
The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.
|
|
18
|
-
|
|
19
|
-
## Why Learn Java?
|
|
20
|
-
|
|
21
|
-
- JAVA IS EVERYWHERE.
|
|
22
|
-
It is one of the most sought after programming languages.
|
|
23
|
-
It is a standard for enterprise software, web-based content, games and mobile apps, as well as the [Android operating system](https://developer.android.com/index.html).
|
|
24
|
-
|
|
25
|
-
- [Write once, run anywhere](https://en.wikipedia.org/wiki/Write_once,_run_anywhere) policy: Programs written in Java are compiled into machine-independent bytecodes, so it can run on any Java platform.
|
|
26
|
-
Basically, Java is [Platform Independent](https://en.wikipedia.org/wiki/Cross-platform#Platform-independent_software)
|
|
27
|
-
|
|
28
|
-
- Java has rich APIs:
|
|
29
|
-
Java has built-in [application programming interfaces](https://en.wikipedia.org/wiki/Application_programming_interface) (APIs) for I/O, networking, data structures, concurrency, and many other functions.
|
|
30
|
-
Standard libraries can be supplemented by open source libraries like Apache Commons, Google Guava, Netty and others.
|
|
31
|
-
|
|
32
|
-
- Standardization:
|
|
33
|
-
If you need to write a web/enterprise app, or you need data persistence or you need to do cryptography, no problem!
|
|
34
|
-
Java is all you require.
|
|
35
|
-
There are many standard tools/practices that extend the Java ecosystem, thanks to the [Java Community Process](https://www.jcp.org/en/introduction/overview) (JCP)!
|
|
17
|
+
From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, [Java is everywhere](https://en.wikipedia.org/wiki/Write_once,_run_anywhere)!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.1.0
|