trackler 2.0.5.5 → 2.0.5.6

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/config.json +15 -0
  4. data/tracks/csharp/exercises/list-ops/Example.cs +77 -0
  5. data/tracks/csharp/exercises/list-ops/HINTS.md +2 -0
  6. data/tracks/csharp/exercises/list-ops/ListOpsTest.cs +195 -0
  7. data/tracks/csharp/exercises/two-bucket/Example.cs +109 -0
  8. data/tracks/csharp/exercises/two-bucket/TwoBucketTest.cs +71 -0
  9. data/tracks/ecmascript/config.json +13 -30
  10. data/tracks/ecmascript/exercises/all-your-base/all-your-base.spec.js +139 -0
  11. data/tracks/ecmascript/exercises/all-your-base/example.js +55 -0
  12. data/tracks/ecmascript/exercises/all-your-base/gulpfile.js +89 -0
  13. data/tracks/ecmascript/exercises/all-your-base/package.json +28 -0
  14. data/tracks/fsharp/exercises/diffie-hellman/HINTS.md +3 -0
  15. data/tracks/fsharp/exercises/gigasecond/HINTS.md +2 -0
  16. data/tracks/fsharp/exercises/palindrome-products/HINTS.md +2 -0
  17. data/tracks/java/config.json +6 -0
  18. data/tracks/java/docs/INSTALLATION.md +1 -0
  19. data/tracks/java/exercises/custom-set/build.gradle +18 -0
  20. data/tracks/java/exercises/custom-set/src/example/java/CustomSet.java +74 -0
  21. data/tracks/java/exercises/custom-set/src/main/java/.keep +0 -0
  22. data/tracks/java/exercises/custom-set/src/test/java/CustomSetTest.java +505 -0
  23. data/tracks/java/exercises/settings.gradle +1 -0
  24. data/tracks/purescript/config.json +25 -0
  25. data/tracks/purescript/exercises/accumulate/bower.json +16 -0
  26. data/tracks/purescript/exercises/accumulate/examples/src/Accumulate.purs +15 -0
  27. data/tracks/purescript/exercises/accumulate/src/Accumulate.purs +3 -0
  28. data/tracks/purescript/exercises/accumulate/test/Main.purs +41 -0
  29. data/tracks/purescript/exercises/acronym/bower.json +1 -1
  30. data/tracks/purescript/exercises/bob/bower.json +1 -1
  31. data/tracks/purescript/exercises/pangram/bower.json +1 -1
  32. data/tracks/purescript/exercises/raindrops/bower.json +1 -1
  33. data/tracks/purescript/exercises/scrabble-score/bower.json +16 -0
  34. data/tracks/purescript/exercises/scrabble-score/examples/src/ScrabbleScore.purs +47 -0
  35. data/tracks/purescript/exercises/scrabble-score/src/ScrabbleScore.purs +3 -0
  36. data/tracks/purescript/exercises/scrabble-score/test/Main.purs +45 -0
  37. data/tracks/purescript/exercises/triangle/bower.json +19 -0
  38. data/tracks/purescript/exercises/triangle/examples/src/Triangle.purs +40 -0
  39. data/tracks/purescript/exercises/triangle/src/Triangle.purs +4 -0
  40. data/tracks/purescript/exercises/triangle/test/Main.purs +66 -0
  41. data/tracks/ruby/.rubocop.yml +3 -0
  42. data/tracks/ruby/README.md +1 -1
  43. metadata +30 -2
@@ -28,7 +28,6 @@
28
28
  "scrabble-score",
29
29
  "roman-numerals",
30
30
  "circular-buffer",
31
- "binary",
32
31
  "prime-factors",
33
32
  "raindrops",
34
33
  "allergies",
@@ -36,10 +35,8 @@
36
35
  "atbash-cipher",
37
36
  "accumulate",
38
37
  "crypto-square",
39
- "trinary",
40
38
  "sieve",
41
39
  "simple-cipher",
42
- "octal",
43
40
  "luhn",
44
41
  "pig-latin",
45
42
  "pythagorean-triplet",
@@ -48,7 +45,6 @@
48
45
  "secret-handshake",
49
46
  "linked-list",
50
47
  "wordy",
51
- "hexadecimal",
52
48
  "largest-series-product",
53
49
  "kindergarten-garden",
54
50
  "binary-search",
@@ -68,7 +64,8 @@
68
64
  "bracket-push",
69
65
  "two-bucket",
70
66
  "diamond",
71
- "isogram"
67
+ "isogram",
68
+ "all-your-base"
72
69
  ],
73
70
  "exercises": [
74
71
  {
@@ -209,12 +206,6 @@
209
206
  "topics": [
210
207
  ]
211
208
  },
212
- {
213
- "slug": "binary",
214
- "difficulty": 1,
215
- "topics": [
216
- ]
217
- },
218
209
  {
219
210
  "slug": "prime-factors",
220
211
  "difficulty": 1,
@@ -257,12 +248,6 @@
257
248
  "topics": [
258
249
  ]
259
250
  },
260
- {
261
- "slug": "trinary",
262
- "difficulty": 1,
263
- "topics": [
264
- ]
265
- },
266
251
  {
267
252
  "slug": "sieve",
268
253
  "difficulty": 1,
@@ -275,12 +260,6 @@
275
260
  "topics": [
276
261
  ]
277
262
  },
278
- {
279
- "slug": "octal",
280
- "difficulty": 1,
281
- "topics": [
282
- ]
283
- },
284
263
  {
285
264
  "slug": "luhn",
286
265
  "difficulty": 1,
@@ -329,12 +308,6 @@
329
308
  "topics": [
330
309
  ]
331
310
  },
332
- {
333
- "slug": "hexadecimal",
334
- "difficulty": 1,
335
- "topics": [
336
- ]
337
- },
338
311
  {
339
312
  "slug": "largest-series-product",
340
313
  "difficulty": 1,
@@ -454,11 +427,21 @@
454
427
  "difficulty": 1,
455
428
  "topics": [
456
429
  ]
430
+ },
431
+ {
432
+ "slug": "all-your-base",
433
+ "difficulty": 1,
434
+ "topics": [
435
+ ]
457
436
  }
458
437
  ],
459
438
  "deprecated": [
460
439
  "nucleotide-count",
461
- "point-mutations"
440
+ "point-mutations",
441
+ "binary",
442
+ "trinary",
443
+ "hexadecimal",
444
+ "octal"
462
445
  ],
463
446
  "ignored": [
464
447
  "node_modules",
@@ -0,0 +1,139 @@
1
+ import Converter from './all-your-base';
2
+
3
+ const converter = new Converter();
4
+
5
+ describe('Converter', () => {
6
+
7
+ it('single bit one to decimal', () => {
8
+ expect(converter.convert([1], 2, 10)).toEqual([1]);
9
+ });
10
+
11
+ xit('binary to single decimal', () => {
12
+ expect(converter.convert([1, 0, 1], 2, 10)).toEqual([5]);
13
+ });
14
+
15
+ xit('single decimal to binary', () => {
16
+ expect(converter.convert([5], 10, 2)).toEqual([1, 0, 1]);
17
+ });
18
+
19
+ xit('binary to multiple decimal', () => {
20
+ expect(converter.convert([1, 0, 1, 0, 1, 0], 2, 10)).toEqual([4, 2]);
21
+ });
22
+
23
+ xit('decimal to binary', () => {
24
+ expect(converter.convert([4, 2], 10, 2)).toEqual([1, 0, 1, 0, 1, 0]);
25
+ });
26
+
27
+ xit('trinary to hexadecimal', () => {
28
+ expect(converter.convert([1, 1, 2, 0], 3, 16)).toEqual([2, 10]);
29
+ });
30
+
31
+ xit('hexadecimal to trinary', () => {
32
+ expect(converter.convert([2, 10], 16, 3)).toEqual([1, 1, 2, 0]);
33
+ });
34
+
35
+ xit('15-bit integer', () => {
36
+ expect(converter.convert([3, 46, 60], 97, 73)).toEqual([6, 10, 45]);
37
+ });
38
+
39
+ xit('empty list', () => {
40
+ expect(() => {
41
+ converter.convert([], 2, 10);
42
+ }).toThrow(new Error('Input has wrong format'));
43
+ });
44
+
45
+ xit('single zero', () => {
46
+ expect(converter.convert([0], 10, 2)).toEqual([0]);
47
+ });
48
+
49
+ xit('multiple zeros', () => {
50
+ expect(() => {
51
+ converter.convert([0, 0, 0], 10, 2);
52
+ }).toThrow(new Error('Input has wrong format'));
53
+ });
54
+
55
+ xit('leading zeros', () => {
56
+ expect(() => {
57
+ converter.convert([0, 6, 0], 7, 10);
58
+ }).toThrow(new Error('Input has wrong format'));
59
+ });
60
+
61
+ xit('negative digit', () => {
62
+ expect(() => {
63
+ converter.convert([1, -1, 1, 0, 1, 0], 2, 10);
64
+ }).toThrow(new Error('Input has wrong format'));
65
+ });
66
+
67
+ xit('invalid positive digit', () => {
68
+ expect(() => {
69
+ converter.convert([1, 2, 1, 0, 1, 0], 2, 10);
70
+ }).toThrow(new Error('Input has wrong format'));
71
+ });
72
+
73
+ xit('first base is one', () => {
74
+ expect(() => {
75
+ converter.convert([], 1, 10);
76
+ }).toThrow(new Error('Wrong input base'));
77
+ });
78
+
79
+ xit('second base is one', () => {
80
+ expect(() => {
81
+ converter.convert([1, 0, 1, 0, 1, 0], 2, 1);
82
+ }).toThrow(new Error('Wrong output base'));
83
+ });
84
+
85
+ xit('first base is zero', () => {
86
+ expect(() => {
87
+ converter.convert([], 0, 10);
88
+ }).toThrow(new Error('Wrong input base'));
89
+ });
90
+
91
+ xit('second base is zero', () => {
92
+ expect(() => {
93
+ converter.convert([7], 10, 0);
94
+ }).toThrow(new Error('Wrong output base'));
95
+ });
96
+
97
+ xit('first base is negative', () => {
98
+ expect(() => {
99
+ converter.convert([1], -2, 10);
100
+ }).toThrow(new Error('Wrong input base'));
101
+ });
102
+
103
+ xit('second base is negative', () => {
104
+ expect(() => {
105
+ converter.convert([1], 2, -7);
106
+ }).toThrow(new Error('Wrong output base'));
107
+ });
108
+
109
+ xit('both bases are negative', () => {
110
+ expect(() => {
111
+ converter.convert([1], -2, -7);
112
+ }).toThrow(new Error('Wrong input base'));
113
+ });
114
+
115
+ xit('missing input base throws an error', () => {
116
+ expect(() => {
117
+ converter.convert([0]);
118
+ }).toThrow(new Error('Wrong input base'));
119
+ });
120
+
121
+ xit('wrong input_base base not integer', () => {
122
+ expect(() => {
123
+ converter.convert([0], 2.5);
124
+ }).toThrow(new Error('Wrong input base'));
125
+ });
126
+
127
+ xit('missing output base throws an error', () => {
128
+ expect(() => {
129
+ converter.convert([0], 2);
130
+ }).toThrow(new Error('Wrong output base'));
131
+ });
132
+
133
+ xit('wrong output_base base not integer', () => {
134
+ expect(() => {
135
+ converter.convert([0], 3, 2.5);
136
+ }).toThrow(new Error('Wrong output base'));
137
+ });
138
+
139
+ });
@@ -0,0 +1,55 @@
1
+ const isValidBase = function (base) {
2
+ return !base || base < 2 || Math.floor(base) !== base;
3
+ };
4
+
5
+ const isInputValid = function (array, base) {
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 = function (num, outputBase) {
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, inputBase, outputBase) {
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) => {
51
+ return accumulator * inputBase + value;
52
+ }, 0);
53
+ return convertFromDecimalToBase(decimalValue, outputBase);
54
+ }
55
+ }
@@ -0,0 +1,89 @@
1
+ function getInputDirectory(argv) {
2
+ if (argv.input) {
3
+ return argv.input;
4
+ }
5
+ return '.';
6
+ }
7
+
8
+ function getOutputDirectory(argv) {
9
+ if (argv.output) {
10
+ return argv.output;
11
+ }
12
+ return 'babel-output';
13
+ }
14
+
15
+ const gulp = require('gulp'),
16
+ eslint = require('gulp-eslint'),
17
+ jasmine = require('gulp-jasmine'),
18
+ babel = require('gulp-babel'),
19
+ polyfill = require('babel/polyfill'),
20
+ del = require('del'),
21
+ argv = require('yargs').argv,
22
+ inputDir = getInputDirectory(argv),
23
+ outputDir = getOutputDirectory(argv);
24
+
25
+ // Gulp tasks definition
26
+
27
+ gulp.task('default', [ 'test' ]);
28
+
29
+ gulp.task('test', [ 'babel' ], function () {
30
+ return gulp.src([ outputDir + '/*.spec.js' ])
31
+ .pipe(jasmine());
32
+ });
33
+
34
+ gulp.task('babel', function () {
35
+ return gulp.src([ inputDir + '/*.js', inputDir + '/lib/*.js' ])
36
+ .pipe(babel())
37
+ .pipe(gulp.dest(outputDir));
38
+ });
39
+
40
+ gulp.task('lint', function () {
41
+ return gulp.src([ inputDir + '/*.js' ])
42
+ .pipe(eslint({
43
+ envs: [
44
+ 'es6' //turns on all es6 features except modules
45
+ ],
46
+ rules: {
47
+ // full documentation here : http://eslint.org/docs/rules
48
+
49
+ // Possible errors
50
+ 'comma-dangle': [2, 'never'], // don't let a comma at the end of object properties or array element
51
+ 'no-cond-assign': [2, 'always'], // no assignments in conditional statements
52
+ 'no-console': 2, // no console.log() statements in production code
53
+ 'no-constant-condition': 2, // no constants in conditional statements
54
+ 'no-control-regex': 2, // no control characters in regex's
55
+ 'no-debugger': 2, // no debugger in productin code
56
+ 'no-dupe-args': 2, // no duplicated arguments in functions
57
+ 'no-dupe-keys': 2, // no duplicated keys when creating object literals
58
+ 'no-duplicate-case': 2, // no duplicated `case` in `switch` statements
59
+ 'no-empty-character-class': 2, // disallow the use of empty character classes in regular expressions
60
+ 'no-empty': 2, // no empty blocks
61
+ 'no-ex-assign': 2, // do not assign any value to an Exception raised
62
+ 'no-extra-boolean-cast': 2, // do not use !!falseExpression to cast to boolean
63
+ 'no-extra-parens': 2, // do not use extra parenthesis
64
+ 'no-extra-semi': 2, // do not use extra semicolons
65
+ 'no-func-assign': 2, // do not overwrite variables declared as functions
66
+ 'no-inner-declarations': [2, 'both'], // only declare var's and funct's on function scope
67
+ 'no-invalid-regexp': 2, // validates string arguments passed to RegExp constructor
68
+ 'no-irregular-whitespace': 2, // detects special characters used as spaces
69
+ 'no-negated-in-lhs': 2, // do not use negation in the left operand in an `in` expression
70
+ 'no-obj-calls': 2, // prevent calling global objects as if they were functions
71
+ 'no-regex-spaces': 2, // do not use multiple spaces in regex's
72
+ 'no-sparse-arrays': 2, // do not use sparse arrays (empty elements)
73
+ 'no-unexpected-multiline': 2, // Avoid code that looks like two expressions but is actually one
74
+ 'no-unreachable': 2, // detects unreachable statements (after return, throw,...)
75
+ 'use-isnan': 2, // do not compare with `NaN` value, use isNan() instead
76
+ 'valid-jsdoc': 2, // ensure JSDoc comments are valid
77
+ 'valid-typeof': 2 // ensure that the results of typeof are compared against a valid string
78
+ },
79
+ ecmaFeatures: {
80
+ 'modules': true //this gives us modules :)
81
+ }
82
+ }))
83
+ .pipe(eslint.format())
84
+ .pipe(eslint.failAfterError());
85
+ });
86
+
87
+ gulp.task('clean', function (cb) {
88
+ del([ outputDir ], cb);
89
+ });
@@ -0,0 +1,28 @@
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": "~5.8.29",
13
+ "del": "~2.0.2",
14
+ "gulp": "~3.9.0",
15
+ "gulp-babel": "~5.3.0",
16
+ "gulp-eslint": "^1.1.0",
17
+ "gulp-jasmine": "~2.0.1",
18
+ "yargs": "~3.27.0"
19
+ },
20
+ "scripts": {
21
+ "test": "gulp test",
22
+ "lint-test": "gulp lint test"
23
+ },
24
+ "licenses": [
25
+ "MIT"
26
+ ],
27
+ "dependencies": {}
28
+ }
@@ -0,0 +1,3 @@
1
+ ## Hints
2
+ For this exercise the following F# feature comes in handy:
3
+ - [BigInt](https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/numerics.biginteger-structure-%5Bfsharp%5D)
@@ -0,0 +1,2 @@
1
+ ## Hints
2
+ There is a property in the `DateTime` class that allows you to retrieve the date without its time component.
@@ -0,0 +1,2 @@
1
+ ## Hints
2
+ - The most simple way to check if a number is a palindrome is quite slow. To speed things up, you could implement a slighly more complex algorithm which uses mutable state.
@@ -55,6 +55,7 @@
55
55
  "binary-search-tree",
56
56
  "binary-search",
57
57
  "all-your-base",
58
+ "custom-set",
58
59
  "wordy",
59
60
  "palindrome-products"
60
61
  ],
@@ -314,6 +315,11 @@
314
315
  "difficulty": 1,
315
316
  "topics": []
316
317
  },
318
+ {
319
+ "slug": "custom-set",
320
+ "difficulty": 1,
321
+ "topics": []
322
+ },
317
323
  {
318
324
  "slug": "wordy",
319
325
  "difficulty": 1,