trackler 2.2.1.125 → 2.2.1.126
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/exercises/isbn-verifier/canonical-data.json +2 -2
- data/tracks/erlang/README.md +5 -5
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/docs/INSTALLATION.md +1 -1
- data/tracks/erlang/exercises/isbn-verifier/README.md +80 -0
- data/tracks/erlang/exercises/isbn-verifier/rebar.config +30 -0
- data/tracks/erlang/exercises/isbn-verifier/src/example.erl +13 -0
- data/tracks/erlang/exercises/isbn-verifier/src/isbn_verifier.app.src +9 -0
- data/tracks/erlang/exercises/isbn-verifier/src/isbn_verifier.erl +7 -0
- data/tracks/erlang/exercises/isbn-verifier/test/isbn_verifier_tests.erl +48 -0
- data/tracks/haskell/exercises/isbn-verifier/package.yaml +1 -1
- data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +1 -1
- data/tracks/javascript/.eslintignore +0 -1
- data/tracks/javascript/exercises/robot-simulator/example.js +70 -72
- data/tracks/typescript/config.json +34 -2
- data/tracks/typescript/exercises/all-your-base/README.md +60 -0
- data/tracks/typescript/exercises/all-your-base/all-your-base.example.ts +53 -0
- data/tracks/typescript/exercises/all-your-base/all-your-base.test.ts +119 -0
- data/tracks/typescript/exercises/all-your-base/all-your-base.ts +0 -0
- data/tracks/typescript/exercises/all-your-base/package.json +36 -0
- data/tracks/typescript/exercises/all-your-base/tsconfig.json +22 -0
- data/tracks/typescript/exercises/all-your-base/tslint.json +127 -0
- data/tracks/typescript/exercises/all-your-base/yarn.lock +2624 -0
- data/tracks/typescript/exercises/anagram/anagram.example.ts +3 -3
- data/tracks/typescript/exercises/anagram/anagram.test.ts +55 -57
- data/tracks/typescript/exercises/anagram/anagram.ts +0 -5
- data/tracks/typescript/exercises/crypto-square/README.md +102 -0
- data/tracks/typescript/exercises/crypto-square/crypto-square.example.ts +59 -0
- data/tracks/typescript/exercises/crypto-square/crypto-square.test.ts +53 -0
- data/tracks/typescript/exercises/crypto-square/crypto-square.ts +0 -0
- data/tracks/typescript/exercises/crypto-square/package.json +36 -0
- data/tracks/typescript/exercises/crypto-square/tsconfig.json +22 -0
- data/tracks/typescript/exercises/crypto-square/tslint.json +127 -0
- data/tracks/typescript/exercises/crypto-square/yarn.lock +2624 -0
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.example.ts +40 -40
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.test.ts +118 -118
- data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.ts +0 -7
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a98f4ad3ecc854d1aa0ee029e00a37de01bd3fe
|
4
|
+
data.tar.gz: 77e1b5792ebf0eac854dfd8fdcda337953d5b828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7d1a1af48906fc6224d95bf859375259a427871eff3cb5682fca86cffd1a4abf5528253bf698294ef81b9b6c764e3170cee6d6d88e7beedabbb1d3fce01cd28
|
7
|
+
data.tar.gz: 606efdfdc113047f900843d09c087bae2071f64d35a644aeb920b66a42acb89f6fdafee296d5f8d02763aea4de9781d9a6d04d37efb1bf4910ee266862040d6f
|
data/lib/trackler/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"exercise": "isbn-verifier",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0",
|
4
4
|
"comments": [
|
5
5
|
"An expected value of true indicates a valid ISBN-10, ",
|
6
6
|
"whereas false means the ISBN-10 is invalid."
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"description": "invalid character in isbn",
|
43
43
|
"property": "isValid",
|
44
44
|
"input": {
|
45
|
-
"isbn": "3-598-
|
45
|
+
"isbn": "3-598-P1581-X"
|
46
46
|
},
|
47
47
|
"expected": false
|
48
48
|
},
|
data/tracks/erlang/README.md
CHANGED
@@ -37,12 +37,12 @@ compatible with erlang syntax.
|
|
37
37
|
2. Set up folder structure (`include`, `src`, and `test`).
|
38
38
|
3. Copy `rebar.conf`, `src/*.app.src`, and `include/exercism.hrl` from
|
39
39
|
another exercise.
|
40
|
-
|
40
|
+
1. Find the line `{eunit_tests, [{application, <erlangified_slug_name>}]}`
|
41
41
|
in `rebar.conf` and alter it to match the current exercise.
|
42
|
-
|
43
|
-
3.
|
44
|
-
|
45
|
-
|
42
|
+
2. Rename `src/*.app.src` to `src/<erlangified_slug_name>`.
|
43
|
+
3. Change the old erlangified_slug_name on the first line to the new one.
|
44
|
+
4. Change the old slug-name on the second line to the new one.
|
45
|
+
5. Leave `include/exercism.hrl` untouched.
|
46
46
|
4. Create a testfile/-module in `test`-folder. It is preferred to name
|
47
47
|
it after the erlangified_slug_name and insert the boilerplate code
|
48
48
|
shown below.
|
data/tracks/erlang/config.json
CHANGED
@@ -202,6 +202,16 @@
|
|
202
202
|
|
203
203
|
]
|
204
204
|
},
|
205
|
+
{
|
206
|
+
"uuid": "ba4cd1e4-b5f0-4efc-a4c8-58c5252cae9e",
|
207
|
+
"slug": "isbn-verifier",
|
208
|
+
"core": false,
|
209
|
+
"unlocked_by": null,
|
210
|
+
"difficulty": 3,
|
211
|
+
"topics": [
|
212
|
+
|
213
|
+
]
|
214
|
+
},
|
205
215
|
{
|
206
216
|
"uuid": "24ae9a43-4e1c-418b-97f6-2c83dbc0e14a",
|
207
217
|
"slug": "gigasecond",
|
@@ -18,7 +18,7 @@ $ brew install erlang rebar@3
|
|
18
18
|
### On Linux
|
19
19
|
|
20
20
|
* Fedora 17+ and Fedora Rawhide: `sudo yum -y install erlang`
|
21
|
-
* Arch Linux:
|
21
|
+
* Arch Linux: `sudo pacman -S erlang`
|
22
22
|
* Ubuntu/Debian: `sudo apt-get install erlang`
|
23
23
|
|
24
24
|
It may happen that the packages above are dated. At least for ubuntu 16.04
|
@@ -0,0 +1,80 @@
|
|
1
|
+
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification
|
2
|
+
numbers. These normally contain dashes and look like: `3-598-21508-8`
|
3
|
+
|
4
|
+
## ISBN
|
5
|
+
|
6
|
+
The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula:
|
7
|
+
|
8
|
+
```
|
9
|
+
(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0
|
10
|
+
```
|
11
|
+
|
12
|
+
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid.
|
13
|
+
|
14
|
+
## Example
|
15
|
+
|
16
|
+
Let's take the ISBN-10 `3-598-21508-8`. We plug it in to the formula, and get:
|
17
|
+
```
|
18
|
+
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0
|
19
|
+
```
|
20
|
+
|
21
|
+
Since the result is 0, this proves that our ISBN is valid.
|
22
|
+
|
23
|
+
## Task
|
24
|
+
|
25
|
+
The program should be able to verify ISBN-10 both with and without separating dashes.
|
26
|
+
|
27
|
+
|
28
|
+
## Caveats
|
29
|
+
|
30
|
+
Converting from strings to numbers can be tricky in certain languages.
|
31
|
+
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). For instance `3-598-21507-X` is a valid ISBN-10.
|
32
|
+
|
33
|
+
## Bonus tasks
|
34
|
+
|
35
|
+
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier).
|
36
|
+
|
37
|
+
* Generate valid ISBN, maybe even from a given starting ISBN.
|
38
|
+
|
39
|
+
## Running tests
|
40
|
+
|
41
|
+
In order to run the tests, issue the following command from the exercise
|
42
|
+
directory:
|
43
|
+
|
44
|
+
For running the tests provided, `rebar3` is used as it is the official build and
|
45
|
+
dependency management tool for erlang now. Please refer to [the tracks installation
|
46
|
+
instructions](http://exercism.io/languages/erlang/installation) on how to do that.
|
47
|
+
|
48
|
+
In order to run the tests, you can issue the following command from the exercise
|
49
|
+
directory.
|
50
|
+
|
51
|
+
```bash
|
52
|
+
$ rebar3 eunit
|
53
|
+
```
|
54
|
+
|
55
|
+
### Test versioning
|
56
|
+
|
57
|
+
Each problem defines a macro `TEST_VERSION` in the test file and
|
58
|
+
verifies that the solution defines and exports a function `test_version`
|
59
|
+
returning that same value.
|
60
|
+
|
61
|
+
To make tests pass, add the following to your solution:
|
62
|
+
|
63
|
+
```erlang
|
64
|
+
-export([test_version/0]).
|
65
|
+
|
66
|
+
test_version() ->
|
67
|
+
1.
|
68
|
+
```
|
69
|
+
|
70
|
+
The benefit of this is that reviewers can see against which test version
|
71
|
+
an iteration was written if, for example, a previously posted solution
|
72
|
+
does not solve the current problem or passes current tests.
|
73
|
+
|
74
|
+
## Questions?
|
75
|
+
|
76
|
+
For detailed information about the Erlang track, please refer to the
|
77
|
+
[help page](http://exercism.io/languages/erlang) on the Exercism site.
|
78
|
+
This covers the basic information on setting up the development
|
79
|
+
environment expected by the exercises.
|
80
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
%% Erlang compiler options
|
2
|
+
{erl_opts, [debug_info]}.
|
3
|
+
|
4
|
+
{deps, [{erl_exercism, "0.1.1"}]}.
|
5
|
+
|
6
|
+
{dialyzer, [
|
7
|
+
{warnings, [underspecs, no_return]},
|
8
|
+
{get_warnings, true},
|
9
|
+
{plt_apps, top_level_deps}, % top_level_deps | all_deps
|
10
|
+
{plt_extra_apps, []},
|
11
|
+
{plt_location, local}, % local | "/my/file/name"
|
12
|
+
{plt_prefix, "rebar3"},
|
13
|
+
{base_plt_apps, [stdlib, kernel, crypto]},
|
14
|
+
{base_plt_location, global}, % global | "/my/file/name"
|
15
|
+
{base_plt_prefix, "rebar3"}
|
16
|
+
]}.
|
17
|
+
|
18
|
+
%% eunit:test(Tests)
|
19
|
+
{eunit_tests, []}.
|
20
|
+
%% Options for eunit:test(Tests, Opts)
|
21
|
+
{eunit_opts, [verbose]}.
|
22
|
+
|
23
|
+
%% == xref ==
|
24
|
+
|
25
|
+
{xref_warnings, true}.
|
26
|
+
|
27
|
+
%% xref checks to run
|
28
|
+
{xref_checks, [undefined_function_calls, undefined_functions,
|
29
|
+
locals_not_used, exports_not_used,
|
30
|
+
deprecated_function_calls, deprecated_functions]}.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
-module(isbn_verifier).
|
2
|
+
|
3
|
+
-export([is_valid/1, test_version/0]).
|
4
|
+
|
5
|
+
is_valid(Isbn) -> is_valid(Isbn, 10, 0).
|
6
|
+
|
7
|
+
is_valid([], 0, Acc) -> Acc rem 11=:=0;
|
8
|
+
is_valid([$-|More], N, Acc) -> is_valid(More, N, Acc);
|
9
|
+
is_valid([$X|More], 1, Acc) -> is_valid(More, 0, Acc+10);
|
10
|
+
is_valid([C|More], N, Acc) when C>=$0 andalso C=<$9 -> is_valid(More, N-1, Acc+N*(C-$0));
|
11
|
+
is_valid(_, _, _) -> false.
|
12
|
+
|
13
|
+
test_version() -> 1.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
-module(isbn_verifier_tests).
|
2
|
+
|
3
|
+
-include_lib("erl_exercism/include/exercism.hrl").
|
4
|
+
-include_lib("eunit/include/eunit.hrl").
|
5
|
+
|
6
|
+
valid_isbn_number_test() ->
|
7
|
+
?assert(isbn_verifier:is_valid("3-598-21508-8")).
|
8
|
+
|
9
|
+
invalid_isbn_check_digit_test() ->
|
10
|
+
?assertNot(isbn_verifier:is_valid("3-598-21508-9")).
|
11
|
+
|
12
|
+
valid_isbn_number_with_a_check_digit_of_10_test() ->
|
13
|
+
?assert(isbn_verifier:is_valid("3-598-21507-X")).
|
14
|
+
|
15
|
+
check_digit_is_a_character_other_than_x_test() ->
|
16
|
+
?assertNot(isbn_verifier:is_valid("3-598-21507-A")).
|
17
|
+
|
18
|
+
invalid_character_in_isbn_test() ->
|
19
|
+
?assertNot(isbn_verifier:is_valid("3-598-2K507-0")).
|
20
|
+
|
21
|
+
x_is_only_valid_as_a_check_digit_test() ->
|
22
|
+
?assertNot(isbn_verifier:is_valid("3-598-2X507-9")).
|
23
|
+
|
24
|
+
valid_isbn_without_separating_dashes_test() ->
|
25
|
+
?assert(isbn_verifier:is_valid("3598215088")).
|
26
|
+
|
27
|
+
isbn_without_separating_dashes_and_x_as_check_digit_test() ->
|
28
|
+
?assert(isbn_verifier:is_valid("359821507X")).
|
29
|
+
|
30
|
+
isbn_without_check_digit_and_dashes_test() ->
|
31
|
+
?assertNot(isbn_verifier:is_valid("359821507")).
|
32
|
+
|
33
|
+
too_long_isbn_and_no_dashes_test() ->
|
34
|
+
?assertNot(isbn_verifier:is_valid("3598215078X")).
|
35
|
+
|
36
|
+
isbn_without_check_digit_test() ->
|
37
|
+
?assertNot(isbn_verifier:is_valid("3-598-21507")).
|
38
|
+
|
39
|
+
too_long_isbn_test() ->
|
40
|
+
?assertNot(isbn_verifier:is_valid("3-598-21507-XX")).
|
41
|
+
|
42
|
+
check_digit_of_x_should_not_be_used_for_0_test() ->
|
43
|
+
?assertNot(isbn_verifier:is_valid("3-598-21515-X")).
|
44
|
+
|
45
|
+
empty_isbn_test() ->
|
46
|
+
?assertNot(isbn_verifier:is_valid("3-598-21515-X")).
|
47
|
+
|
48
|
+
version_test() -> ?assertMatch(1, isbn_verifier:test_version()).
|
@@ -40,7 +40,7 @@ cases = [ Case { description = "valid isbn number"
|
|
40
40
|
, expected = False
|
41
41
|
}
|
42
42
|
, Case { description = "invalid character in isbn"
|
43
|
-
, input = "3-598-
|
43
|
+
, input = "3-598-P1581-X"
|
44
44
|
, expected = False
|
45
45
|
}
|
46
46
|
, Case { description = "X is only valid as a check digit"
|
@@ -1,87 +1,85 @@
|
|
1
|
-
|
2
|
-
'use strict';
|
1
|
+
'use strict';
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
var VALID_DIRECTIONS = ['north', 'east', 'south', 'west'];
|
4
|
+
var INSTRUCTION_KEYS = {
|
5
|
+
A: 'advance',
|
6
|
+
L: 'turnLeft',
|
7
|
+
R: 'turnRight'
|
8
|
+
};
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Robot.prototype.at = function (x, y) {
|
17
|
-
this.coordinates = [x, y];
|
18
|
-
};
|
10
|
+
function Robot() {
|
11
|
+
this.coordinates = [0, 0];
|
12
|
+
this.bearing = 'north';
|
13
|
+
}
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
15
|
+
Robot.prototype.at = function (x, y) {
|
16
|
+
this.coordinates = [x, y];
|
17
|
+
};
|
24
18
|
|
25
|
-
|
26
|
-
|
19
|
+
Robot.prototype.orient = function (direction) {
|
20
|
+
if (VALID_DIRECTIONS.indexOf(direction) === -1) {
|
21
|
+
throw new Error('Invalid Robot Bearing');
|
22
|
+
}
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
case 'north':
|
31
|
-
this.coordinates[1]++;
|
32
|
-
break;
|
33
|
-
case 'east':
|
34
|
-
this.coordinates[0]++;
|
35
|
-
break;
|
36
|
-
case 'south':
|
37
|
-
this.coordinates[1]--;
|
38
|
-
break;
|
39
|
-
case 'west':
|
40
|
-
this.coordinates[0]--;
|
41
|
-
break;
|
42
|
-
}
|
43
|
-
};
|
24
|
+
this.bearing = direction;
|
25
|
+
};
|
44
26
|
|
45
|
-
|
46
|
-
|
27
|
+
Robot.prototype.advance = function () {
|
28
|
+
switch (this.bearing) {
|
29
|
+
case 'north':
|
30
|
+
this.coordinates[1]++;
|
31
|
+
break;
|
32
|
+
case 'east':
|
33
|
+
this.coordinates[0]++;
|
34
|
+
break;
|
35
|
+
case 'south':
|
36
|
+
this.coordinates[1]--;
|
37
|
+
break;
|
38
|
+
case 'west':
|
39
|
+
this.coordinates[0]--;
|
40
|
+
break;
|
41
|
+
default:
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
};
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
} else {
|
51
|
-
this.orient(VALID_DIRECTIONS[VALID_DIRECTIONS.length - 1]);
|
52
|
-
}
|
53
|
-
};
|
46
|
+
Robot.prototype.turnLeft = function () {
|
47
|
+
var directionPosition = VALID_DIRECTIONS.indexOf(this.bearing);
|
54
48
|
|
55
|
-
|
56
|
-
|
49
|
+
if (directionPosition > 0) {
|
50
|
+
this.orient(VALID_DIRECTIONS[--directionPosition]);
|
51
|
+
} else {
|
52
|
+
this.orient(VALID_DIRECTIONS[VALID_DIRECTIONS.length - 1]);
|
53
|
+
}
|
54
|
+
};
|
57
55
|
|
58
|
-
|
59
|
-
|
60
|
-
} else {
|
61
|
-
this.orient(VALID_DIRECTIONS[0]);
|
62
|
-
}
|
63
|
-
};
|
56
|
+
Robot.prototype.turnRight = function () {
|
57
|
+
var directionPosition = VALID_DIRECTIONS.indexOf(this.bearing);
|
64
58
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
59
|
+
if (directionPosition < (VALID_DIRECTIONS.length - 1)) {
|
60
|
+
this.orient(VALID_DIRECTIONS[++directionPosition]);
|
61
|
+
} else {
|
62
|
+
this.orient(VALID_DIRECTIONS[0]);
|
63
|
+
}
|
64
|
+
};
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
66
|
+
Robot.prototype.instructions = function (instructionKeys) {
|
67
|
+
return instructionKeys.split('')
|
68
|
+
.map(function (key) {
|
69
|
+
return INSTRUCTION_KEYS[key];
|
70
|
+
});
|
71
|
+
};
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}, this);
|
82
|
-
};
|
73
|
+
Robot.prototype.place = function (args) {
|
74
|
+
this.coordinates = [args.x, args.y];
|
75
|
+
this.bearing = args.direction;
|
76
|
+
};
|
83
77
|
|
84
|
-
|
85
|
-
|
78
|
+
Robot.prototype.evaluate = function (instructionKeys) {
|
79
|
+
this.instructions(instructionKeys)
|
80
|
+
.forEach(function (instruction) {
|
81
|
+
this[instruction]();
|
82
|
+
}, this);
|
83
|
+
};
|
86
84
|
|
87
85
|
module.exports = Robot;
|