trackler 2.2.1.125 → 2.2.1.126

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/isbn-verifier/canonical-data.json +2 -2
  4. data/tracks/erlang/README.md +5 -5
  5. data/tracks/erlang/config.json +10 -0
  6. data/tracks/erlang/docs/INSTALLATION.md +1 -1
  7. data/tracks/erlang/exercises/isbn-verifier/README.md +80 -0
  8. data/tracks/erlang/exercises/isbn-verifier/rebar.config +30 -0
  9. data/tracks/erlang/exercises/isbn-verifier/src/example.erl +13 -0
  10. data/tracks/erlang/exercises/isbn-verifier/src/isbn_verifier.app.src +9 -0
  11. data/tracks/erlang/exercises/isbn-verifier/src/isbn_verifier.erl +7 -0
  12. data/tracks/erlang/exercises/isbn-verifier/test/isbn_verifier_tests.erl +48 -0
  13. data/tracks/haskell/exercises/isbn-verifier/package.yaml +1 -1
  14. data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +1 -1
  15. data/tracks/javascript/.eslintignore +0 -1
  16. data/tracks/javascript/exercises/robot-simulator/example.js +70 -72
  17. data/tracks/typescript/config.json +34 -2
  18. data/tracks/typescript/exercises/all-your-base/README.md +60 -0
  19. data/tracks/typescript/exercises/all-your-base/all-your-base.example.ts +53 -0
  20. data/tracks/typescript/exercises/all-your-base/all-your-base.test.ts +119 -0
  21. data/tracks/typescript/exercises/all-your-base/all-your-base.ts +0 -0
  22. data/tracks/typescript/exercises/all-your-base/package.json +36 -0
  23. data/tracks/typescript/exercises/all-your-base/tsconfig.json +22 -0
  24. data/tracks/typescript/exercises/all-your-base/tslint.json +127 -0
  25. data/tracks/typescript/exercises/all-your-base/yarn.lock +2624 -0
  26. data/tracks/typescript/exercises/anagram/anagram.example.ts +3 -3
  27. data/tracks/typescript/exercises/anagram/anagram.test.ts +55 -57
  28. data/tracks/typescript/exercises/anagram/anagram.ts +0 -5
  29. data/tracks/typescript/exercises/crypto-square/README.md +102 -0
  30. data/tracks/typescript/exercises/crypto-square/crypto-square.example.ts +59 -0
  31. data/tracks/typescript/exercises/crypto-square/crypto-square.test.ts +53 -0
  32. data/tracks/typescript/exercises/crypto-square/crypto-square.ts +0 -0
  33. data/tracks/typescript/exercises/crypto-square/package.json +36 -0
  34. data/tracks/typescript/exercises/crypto-square/tsconfig.json +22 -0
  35. data/tracks/typescript/exercises/crypto-square/tslint.json +127 -0
  36. data/tracks/typescript/exercises/crypto-square/yarn.lock +2624 -0
  37. data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.example.ts +40 -40
  38. data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.test.ts +118 -118
  39. data/tracks/typescript/exercises/kindergarten-garden/kindergarten-garden.ts +0 -7
  40. metadata +24 -2
@@ -495,6 +495,21 @@
495
495
  "unlocked_by": null,
496
496
  "uuid": "32953258-d488-4761-9669-895a359a8b9a"
497
497
  },
498
+ {
499
+ "core": false,
500
+ "difficulty": 5,
501
+ "slug": "all-your-base",
502
+ "topics": [
503
+ "control_flow_conditionals",
504
+ "control_flow_loops",
505
+ "exception_handling",
506
+ "integers",
507
+ "mathematics",
508
+ "parsing"
509
+ ],
510
+ "unlocked_by": null,
511
+ "uuid": "0f4f98fe-245a-4842-b3cf-6581b89afd44"
512
+ },
498
513
  {
499
514
  "core": true,
500
515
  "difficulty": 6,
@@ -589,6 +604,23 @@
589
604
  "unlocked_by": "linked-list",
590
605
  "uuid": "3cc210e8-b3bb-11e7-abc4-cec278b6b50a"
591
606
  },
607
+ {
608
+ "core": false,
609
+ "difficulty": 9,
610
+ "slug": "crypto-square",
611
+ "topics": [
612
+ "algorithms",
613
+ "arrays",
614
+ "control_flow_conditionals",
615
+ "control_flow_loops",
616
+ "regular_expressions",
617
+ "sorting",
618
+ "text_formatting",
619
+ "transforming"
620
+ ],
621
+ "unlocked_by": "simple-cipher",
622
+ "uuid": "e92b7444-a5c3-4452-82fd-8c70cf14085a"
623
+ },
592
624
  {
593
625
  "core": false,
594
626
  "difficulty": 3,
@@ -713,7 +745,7 @@
713
745
  "strings"
714
746
  ],
715
747
  "unlocked_by": "pangram",
716
- "uuid": "2ceec21e-fb9d-4145-8788-826c3941eb01"
748
+ "uuid": "d3c93056-07b9-4d06-a681-1bb25db68c01"
717
749
  },
718
750
  {
719
751
  "core": false,
@@ -879,7 +911,7 @@
879
911
  "Text formatting"
880
912
  ],
881
913
  "unlocked_by": "wordy",
882
- "uuid": "b1ab1795-3f8e-43f6-86b4-88be4967e934"
914
+ "uuid": "d70d3579-999c-452c-9243-98908e24b47e"
883
915
  },
884
916
  {
885
917
  "core": false,
@@ -0,0 +1,60 @@
1
+ # All Your Base
2
+
3
+ Convert a number, represented as a sequence of digits in one base, to any other base.
4
+
5
+ Implement general base conversion. Given a number in base **a**,
6
+ represented as a sequence of digits, convert it to base **b**.
7
+
8
+ ## Note
9
+
10
+ - Try to implement the conversion yourself.
11
+ Do not use something else to perform the conversion for you.
12
+
13
+ ## About [Positional Notation](https://en.wikipedia.org/wiki/Positional_notation)
14
+
15
+ In positional notation, a number in base **b** can be understood as a linear
16
+ combination of powers of **b**.
17
+
18
+ The number 42, *in base 10*, means:
19
+
20
+ (4 * 10^1) + (2 * 10^0)
21
+
22
+ The number 101010, *in base 2*, means:
23
+
24
+ (1 * 2^5) + (0 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0)
25
+
26
+ The number 1120, *in base 3*, means:
27
+
28
+ (1 * 3^3) + (1 * 3^2) + (2 * 3^1) + (0 * 3^0)
29
+
30
+ I think you got the idea!
31
+
32
+ *Yes. Those three numbers above are exactly the same. Congratulations!*
33
+
34
+ ## Setup
35
+
36
+ Go through the setup instructions for TypeScript to
37
+ install the necessary dependencies:
38
+
39
+ http://exercism.io/languages/typescript
40
+
41
+ ## Requirements
42
+
43
+ Install assignment dependencies:
44
+
45
+ ```bash
46
+ $ yarn install
47
+ ```
48
+
49
+ ## Making the test suite pass
50
+
51
+ Execute the tests with:
52
+
53
+ ```bash
54
+ $ yarn test
55
+ ```
56
+
57
+
58
+
59
+ ## Submitting Incomplete Solutions
60
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,53 @@
1
+ const isValidBase = (base: number) => {
2
+ return !base || base < 2 || Math.floor(base) !== base
3
+ }
4
+
5
+ const isInputValid = (array: number[], base: number) => {
6
+ if (!array || !array.length) {
7
+ return false
8
+ }
9
+ const val = base - 1
10
+ for (let i = 0, n = array.length; i < n; i++) {
11
+ const tmp = array[i]
12
+ if (tmp > val || tmp < 0) {
13
+ return false
14
+ }
15
+ }
16
+ return true
17
+ }
18
+
19
+ const convertFromDecimalToBase = (num: number, outputBase: number) => {
20
+ let tmp = num
21
+ const result = []
22
+ while (tmp) {
23
+ result.unshift(tmp % outputBase)
24
+ tmp = Math.floor(tmp / outputBase)
25
+ }
26
+ return result
27
+ }
28
+
29
+ export default class Converter {
30
+ convert(array: number[], inputBase: number, outputBase: number) {
31
+ if (isValidBase(inputBase)) {
32
+ throw new Error('Wrong input base')
33
+ }
34
+ if (isValidBase(outputBase)) {
35
+ throw new Error('Wrong output base')
36
+ }
37
+ const regexp = new RegExp('^0.', 'g')
38
+ const str = array.join('')
39
+ if (str.match(regexp)
40
+ || !isInputValid(array, inputBase)) {
41
+ throw new Error('Input has wrong format')
42
+ }
43
+ if (str === '0') {
44
+ return [0]
45
+ }
46
+ if (str === '1') {
47
+ return [1]
48
+ }
49
+ const decimalValue = array
50
+ .reduce((accumulator, value) => accumulator * inputBase + value, 0)
51
+ return convertFromDecimalToBase(decimalValue, outputBase)
52
+ }
53
+ }
@@ -0,0 +1,119 @@
1
+ import Converter from './all-your-base'
2
+
3
+ const converter = new Converter()
4
+
5
+ describe('Converter', () => {
6
+ it('single bit one to decimal', () => {
7
+ expect(converter.convert([1], 2, 10)).toEqual([1])
8
+ })
9
+
10
+ xit('binary to single decimal', () => {
11
+ expect(converter.convert([1, 0, 1], 2, 10)).toEqual([5])
12
+ })
13
+
14
+ xit('single decimal to binary', () => {
15
+ expect(converter.convert([5], 10, 2)).toEqual([1, 0, 1])
16
+ })
17
+
18
+ xit('binary to multiple decimal', () => {
19
+ expect(converter.convert([1, 0, 1, 0, 1, 0], 2, 10)).toEqual([4, 2])
20
+ })
21
+
22
+ xit('decimal to binary', () => {
23
+ expect(converter.convert([4, 2], 10, 2)).toEqual([1, 0, 1, 0, 1, 0])
24
+ })
25
+
26
+ xit('trinary to hexadecimal', () => {
27
+ expect(converter.convert([1, 1, 2, 0], 3, 16)).toEqual([2, 10])
28
+ })
29
+
30
+ xit('hexadecimal to trinary', () => {
31
+ expect(converter.convert([2, 10], 16, 3)).toEqual([1, 1, 2, 0])
32
+ })
33
+
34
+ xit('15-bit integer', () => {
35
+ expect(converter.convert([3, 46, 60], 97, 73)).toEqual([6, 10, 45])
36
+ })
37
+
38
+ xit('empty list', () => {
39
+ expect(() => {
40
+ converter.convert([], 2, 10)
41
+ }).toThrowError('Input has wrong format')
42
+ })
43
+
44
+ xit('single zero', () => {
45
+ expect(converter.convert([0], 10, 2)).toEqual([0])
46
+ })
47
+
48
+ xit('multiple zeros', () => {
49
+ expect(() => {
50
+ converter.convert([0, 0, 0], 10, 2)
51
+ }).toThrowError('Input has wrong format')
52
+ })
53
+
54
+ xit('leading zeros', () => {
55
+ expect(() => {
56
+ converter.convert([0, 6, 0], 7, 10)
57
+ }).toThrowError('Input has wrong format')
58
+ })
59
+
60
+ xit('negative digit', () => {
61
+ expect(() => {
62
+ converter.convert([1, -1, 1, 0, 1, 0], 2, 10)
63
+ }).toThrowError('Input has wrong format')
64
+ })
65
+
66
+ xit('invalid positive digit', () => {
67
+ expect(() => {
68
+ converter.convert([1, 2, 1, 0, 1, 0], 2, 10)
69
+ }).toThrowError('Input has wrong format')
70
+ })
71
+
72
+ xit('first base is one', () => {
73
+ expect(() => {
74
+ converter.convert([], 1, 10)
75
+ }).toThrowError('Wrong input base')
76
+ })
77
+
78
+ xit('second base is one', () => {
79
+ expect(() => {
80
+ converter.convert([1, 0, 1, 0, 1, 0], 2, 1)
81
+ }).toThrowError('Wrong output base')
82
+ })
83
+
84
+ xit('first base is zero', () => {
85
+ expect(() => {
86
+ converter.convert([], 0, 10)
87
+ }).toThrowError('Wrong input base')
88
+ })
89
+
90
+ xit('second base is zero', () => {
91
+ expect(() => {
92
+ converter.convert([7], 10, 0)
93
+ }).toThrowError('Wrong output base')
94
+ })
95
+
96
+ xit('first base is negative', () => {
97
+ expect(() => {
98
+ converter.convert([1], -2, 10)
99
+ }).toThrowError('Wrong input base')
100
+ })
101
+
102
+ xit('second base is negative', () => {
103
+ expect(() => {
104
+ converter.convert([1], 2, -7)
105
+ }).toThrowError('Wrong output base')
106
+ })
107
+
108
+ xit('both bases are negative', () => {
109
+ expect(() => {
110
+ converter.convert([1], -2, -7)
111
+ }).toThrowError('Wrong input base')
112
+ })
113
+
114
+ xit('wrong output_base base not integer', () => {
115
+ expect(() => {
116
+ converter.convert([0], 3, 2.5)
117
+ }).toThrowError('Wrong output base')
118
+ })
119
+ })
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "xtypescript",
3
+ "version": "1.0.0",
4
+ "description": "Exercism exercises in Typescript.",
5
+ "author": "",
6
+ "private": true,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/exercism/xtypescript"
10
+ },
11
+ "devDependencies": {},
12
+ "scripts": {
13
+ "test": "tsc --noEmit -p . && jest --no-cache",
14
+ "lint": "tsc --noEmit -p . && tslint \"*.ts?(x)\"",
15
+ "lintci": "tslint \"*.ts?(x)\" --force"
16
+ },
17
+ "dependencies": {
18
+ "@types/jest": "^21.1.5",
19
+ "@types/node": "^8.0.47",
20
+ "jest": "^21.2.1",
21
+ "ts-jest": "^21.1.3",
22
+ "tslint": "^5.8.0",
23
+ "typescript": "^2.5.3"
24
+ },
25
+ "jest": {
26
+ "transform": {
27
+ ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
28
+ },
29
+ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
30
+ "moduleFileExtensions": [
31
+ "ts",
32
+ "tsx",
33
+ "js"
34
+ ]
35
+ }
36
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "commonjs",
5
+ "alwaysStrict": true,
6
+ "noUnusedLocals": true,
7
+ "noUnusedParameters": true,
8
+ "noImplicitAny": true,
9
+ "strictNullChecks": true,
10
+ "preserveConstEnums": true,
11
+ "noFallthroughCasesInSwitch":true,
12
+ "noImplicitThis":true,
13
+ "noImplicitReturns":true,
14
+ "sourceMap": true,
15
+ "noEmitOnError": true,
16
+ "outDir": "./build"
17
+ },
18
+ "compileOnSave": true,
19
+ "exclude": [
20
+ "node_modules"
21
+ ]
22
+ }
@@ -0,0 +1,127 @@
1
+ {
2
+ "jsRules": {
3
+ "class-name": true,
4
+ "comment-format": [
5
+ true,
6
+ "check-space"
7
+ ],
8
+ "indent": [
9
+ true,
10
+ "spaces"
11
+ ],
12
+ "no-duplicate-variable": true,
13
+ "no-eval": true,
14
+ "no-trailing-whitespace": true,
15
+ "no-unsafe-finally": true,
16
+ "one-line": [
17
+ true,
18
+ "check-open-brace",
19
+ "check-whitespace"
20
+ ],
21
+ "quotemark": [
22
+ false,
23
+ "double"
24
+ ],
25
+ "semicolon": [
26
+ true,
27
+ "never"
28
+ ],
29
+ "triple-equals": [
30
+ true,
31
+ "allow-null-check"
32
+ ],
33
+ "variable-name": [
34
+ true,
35
+ "ban-keywords"
36
+ ],
37
+ "whitespace": [
38
+ true,
39
+ "check-branch",
40
+ "check-decl",
41
+ "check-operator",
42
+ "check-separator",
43
+ "check-type"
44
+ ]
45
+ },
46
+ "rules": {
47
+ "class-name": true,
48
+ "comment-format": [
49
+ true,
50
+ "check-space"
51
+ ],
52
+ "indent": [
53
+ true,
54
+ "spaces"
55
+ ],
56
+ "no-eval": true,
57
+ "no-internal-module": true,
58
+ "no-trailing-whitespace": true,
59
+ "no-unsafe-finally": true,
60
+ "no-var-keyword": true,
61
+ "one-line": [
62
+ true,
63
+ "check-open-brace",
64
+ "check-whitespace"
65
+ ],
66
+ "semicolon": [
67
+ true,
68
+ "never"
69
+ ],
70
+ "triple-equals": [
71
+ true,
72
+ "allow-null-check"
73
+ ],
74
+ "typedef-whitespace": [
75
+ true,
76
+ {
77
+ "call-signature": "nospace",
78
+ "index-signature": "nospace",
79
+ "parameter": "nospace",
80
+ "property-declaration": "nospace",
81
+ "variable-declaration": "nospace"
82
+ }
83
+ ],
84
+ "variable-name": [
85
+ true,
86
+ "ban-keywords"
87
+ ],
88
+ "whitespace": [
89
+ true,
90
+ "check-branch",
91
+ "check-decl",
92
+ "check-operator",
93
+ "check-separator",
94
+ "check-type"
95
+ ],
96
+ "no-namespace": true,
97
+ "prefer-for-of": true,
98
+ "only-arrow-functions": [true, "allow-declarations"],
99
+ "no-var-requires": true,
100
+ "no-any": true,
101
+ "curly": true,
102
+ "forin": true,
103
+ "no-arg": true,
104
+ "label-position": true,
105
+ "no-conditional-assignment": true,
106
+ "no-console": [true, "log", "error"],
107
+ "no-construct": true,
108
+ "no-duplicate-variable": true,
109
+ "no-empty": true,
110
+ "no-invalid-this": [true, "check-function-in-method"],
111
+ "no-misused-new": true,
112
+ "no-null-keyword": true,
113
+ "no-string-literal": true,
114
+ "radix": true,
115
+ "typeof-compare": true,
116
+ "use-isnan": true,
117
+ "prefer-const": true,
118
+ "array-type": [true, "array-simple"],
119
+ "arrow-parens": true,
120
+ "new-parens": true,
121
+ "no-consecutive-blank-lines": [true,1],
122
+ "no-parameter-properties": true,
123
+ "no-unnecessary-initializer": true,
124
+ "object-literal-shorthand": true,
125
+ "object-literal-key-quotes": [true, "as-needed"]
126
+ }
127
+ }