trackler 2.2.1.61 → 2.2.1.62
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/forth/canonical-data.json +1 -7
- data/problem-specifications/exercises/meetup/description.md +16 -12
- data/problem-specifications/exercises/sum-of-multiples/description.md +3 -3
- data/tracks/c/config.json +14 -1
- data/tracks/c/exercises/anagram/src/anagram.h +19 -4
- data/tracks/c/exercises/anagram/src/example.c +27 -40
- data/tracks/c/exercises/anagram/test/test_anagram.c +100 -152
- data/tracks/c/exercises/sublist/README.md +53 -0
- data/tracks/c/exercises/sublist/makefile +15 -0
- data/tracks/c/exercises/sublist/src/example.c +63 -0
- data/tracks/c/exercises/sublist/src/sublist.h +17 -0
- data/tracks/c/exercises/sublist/test/test_sublist.c +243 -0
- data/tracks/c/exercises/sublist/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/sublist/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/sublist/test/vendor/unity_internals.h +701 -0
- data/tracks/ecmascript/config.json +56 -0
- data/tracks/ecmascript/exercises/rectangles/README.md +95 -0
- data/tracks/ecmascript/exercises/rectangles/example.js +38 -0
- data/tracks/ecmascript/exercises/rectangles/package.json +72 -0
- data/tracks/ecmascript/exercises/rectangles/rectangles.spec.js +147 -0
- data/tracks/ecmascript/exercises/rotational-cipher/README.md +66 -0
- data/tracks/ecmascript/exercises/rotational-cipher/example.js +16 -0
- data/tracks/ecmascript/exercises/rotational-cipher/package.json +72 -0
- data/tracks/ecmascript/exercises/rotational-cipher/rotational-cipher.spec.js +73 -0
- data/tracks/ecmascript/exercises/spiral-matrix/README.md +59 -0
- data/tracks/ecmascript/exercises/spiral-matrix/example.js +26 -0
- data/tracks/ecmascript/exercises/spiral-matrix/package.json +72 -0
- data/tracks/ecmascript/exercises/spiral-matrix/spiral-matrix.spec.js +55 -0
- data/tracks/ecmascript/exercises/transpose/README.md +94 -0
- data/tracks/ecmascript/exercises/transpose/example.js +12 -0
- data/tracks/ecmascript/exercises/transpose/package.json +71 -0
- data/tracks/ecmascript/exercises/transpose/transpose.spec.js +121 -0
- data/tracks/go/exercises/allergies/.meta/gen.go +88 -0
- data/tracks/go/exercises/allergies/allergies_test.go +19 -46
- data/tracks/go/exercises/allergies/cases_test.go +60 -0
- data/tracks/go/exercises/bob/bob.go +0 -2
- data/tracks/go/exercises/forth/cases_test.go +2 -7
- data/tracks/go/exercises/nucleotide-count/nucleotide_count.go +0 -2
- data/tracks/go/exercises/pangram/.meta/gen.go +54 -0
- data/tracks/go/exercises/pangram/cases_test.go +62 -0
- data/tracks/go/exercises/pangram/example.go +3 -5
- data/tracks/go/exercises/pangram/pangram_test.go +3 -24
- data/tracks/go/exercises/rna-transcription/rna_transcription.go +0 -2
- data/tracks/go/exercises/robot-name/bonus_example.go +0 -2
- data/tracks/java/exercises/acronym/.meta/src/reference/java/Acronym.java +3 -3
- data/tracks/lfe/config.json +4 -3
- data/tracks/perl6/docs/SNIPPET.txt +8 -3
- data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/Example.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/allergies.t +10 -2
- data/tracks/perl6/exercises/allergies/example.yaml +10 -2
- data/tracks/perl6/exercises/leap/Example.pm6 +1 -1
- data/tracks/perl6/exercises/leap/Leap.pm6 +1 -1
- data/tracks/perl6/exercises/leap/example.yaml +10 -2
- data/tracks/perl6/exercises/leap/leap.t +10 -2
- data/tracks/perl6/exercises/luhn/Example.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/Luhn.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/example.yaml +10 -2
- data/tracks/perl6/exercises/luhn/luhn.t +10 -2
- data/tracks/perl6/exercises/pangram/Example.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/Pangram.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/example.yaml +12 -6
- data/tracks/perl6/exercises/pangram/pangram.t +9 -3
- data/tracks/python/config.json +38 -0
- data/tracks/python/exercises/complex-numbers/complex_numbers_test.py +81 -66
- data/tracks/python/exercises/connect/README.md +44 -0
- data/tracks/python/exercises/connect/connect.py +7 -0
- data/tracks/python/exercises/connect/connect_test.py +118 -0
- data/tracks/python/exercises/connect/example.py +61 -0
- data/tracks/python/exercises/go-counting/README.md +44 -0
- data/tracks/python/exercises/go-counting/example.py +62 -0
- data/tracks/python/exercises/go-counting/go_counting.py +38 -0
- data/tracks/python/exercises/go-counting/go_counting_test.py +92 -0
- data/tracks/python/exercises/parallel-letter-frequency/README.md +24 -0
- data/tracks/python/exercises/parallel-letter-frequency/example.py +56 -0
- data/tracks/python/exercises/parallel-letter-frequency/parallel_letter_frequency.py +2 -0
- data/tracks/python/exercises/parallel-letter-frequency/parallel_letter_frequency_test.py +61 -0
- data/tracks/python/exercises/strain/README.md +3 -1
- data/tracks/python/exercises/strain/strain.py +2 -2
- data/tracks/rust/.travis.yml +1 -0
- data/tracks/rust/README.md +2 -0
- data/tracks/rust/_test/check-exercises.sh +41 -54
- data/tracks/rust/_test/ensure-readmes-are-updated.sh +40 -0
- data/tracks/rust/bin/test-exercise +84 -0
- data/tracks/rust/exercises/alphametics/.meta/test-in-release-mode +2 -0
- data/tracks/rust/exercises/alphametics/src/lib.rs +1 -1
- data/tracks/rust/exercises/dominoes/README.md +3 -3
- data/tracks/rust/exercises/isbn-verifier/README.md +3 -2
- data/tracks/rust/exercises/nucleotide-count/README.md +2 -2
- data/tracks/rust/exercises/perfect-numbers/src/lib.rs +10 -0
- data/tracks/rust/exercises/phone-number/README.md +1 -1
- data/tracks/rust/exercises/pythagorean-triplet/src/lib.rs +3 -0
- data/tracks/rust/exercises/rectangles/README.md +9 -9
- data/tracks/rust/exercises/two-bucket/README.md +7 -7
- data/tracks/typescript/config.json +16 -0
- data/tracks/typescript/exercises/diamond/README.md +84 -0
- data/tracks/typescript/exercises/diamond/diamond.example.ts +51 -0
- data/tracks/typescript/exercises/diamond/diamond.test.ts +35 -0
- data/tracks/typescript/exercises/diamond/diamond.ts +0 -0
- data/tracks/typescript/exercises/diamond/package.json +36 -0
- data/tracks/typescript/exercises/diamond/tsconfig.json +22 -0
- data/tracks/typescript/exercises/diamond/tslint.json +127 -0
- data/tracks/typescript/exercises/diamond/yarn.lock +2624 -0
- metadata +53 -2
@@ -0,0 +1,16 @@
|
|
1
|
+
class RotationalCipher {
|
2
|
+
|
3
|
+
static rotate(text, shift) {
|
4
|
+
return [...text].map((c) => {
|
5
|
+
const isUpper = c.match(/[A-Z]/);
|
6
|
+
const isAlpha = c.match(/[a-z]/i);
|
7
|
+
const charShift = (isUpper ? 'A' : 'a').charCodeAt(0);
|
8
|
+
|
9
|
+
return isAlpha ?
|
10
|
+
String.fromCharCode((((c.charCodeAt(0) - charShift) + shift) % 26) + charShift) : c;
|
11
|
+
}).join('');
|
12
|
+
}
|
13
|
+
|
14
|
+
}
|
15
|
+
|
16
|
+
export default RotationalCipher;
|
@@ -0,0 +1,72 @@
|
|
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": "^21.2.0",
|
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": "^21.2.1"
|
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
|
+
"no-plusplus": "off"
|
66
|
+
}
|
67
|
+
},
|
68
|
+
"licenses": [
|
69
|
+
"MIT"
|
70
|
+
],
|
71
|
+
"dependencies": {}
|
72
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import RotationalCipher from './rotational-cipher';
|
2
|
+
|
3
|
+
describe('Rotational cipher', () => {
|
4
|
+
test('rotate a by 0, same output as input', () => {
|
5
|
+
const expected = 'a';
|
6
|
+
const actual = RotationalCipher.rotate('a', 0);
|
7
|
+
|
8
|
+
expect(actual).toEqual(expected);
|
9
|
+
});
|
10
|
+
|
11
|
+
xtest('rotate a by 1', () => {
|
12
|
+
const expected = 'b';
|
13
|
+
const actual = RotationalCipher.rotate('a', 1);
|
14
|
+
|
15
|
+
expect(actual).toEqual(expected);
|
16
|
+
});
|
17
|
+
|
18
|
+
xtest('rotate a by 26, same output as input', () => {
|
19
|
+
const expected = 'a';
|
20
|
+
const actual = RotationalCipher.rotate('a', 26);
|
21
|
+
|
22
|
+
expect(actual).toEqual(expected);
|
23
|
+
});
|
24
|
+
|
25
|
+
xtest('rotate m by 13', () => {
|
26
|
+
const expected = 'z';
|
27
|
+
const actual = RotationalCipher.rotate('m', 13);
|
28
|
+
|
29
|
+
expect(actual).toEqual(expected);
|
30
|
+
});
|
31
|
+
|
32
|
+
xtest('rotate n by 13 with wrap around alphabet', () => {
|
33
|
+
const expected = 'a';
|
34
|
+
const actual = RotationalCipher.rotate('n', 13);
|
35
|
+
|
36
|
+
expect(actual).toEqual(expected);
|
37
|
+
});
|
38
|
+
|
39
|
+
xtest('rotate capital letters', () => {
|
40
|
+
const expected = 'TRL';
|
41
|
+
const actual = RotationalCipher.rotate('OMG', 5);
|
42
|
+
|
43
|
+
expect(actual).toEqual(expected);
|
44
|
+
});
|
45
|
+
|
46
|
+
xtest('rotate spaces', () => {
|
47
|
+
const expected = 'T R L';
|
48
|
+
const actual = RotationalCipher.rotate('O M G', 5);
|
49
|
+
|
50
|
+
expect(actual).toEqual(expected);
|
51
|
+
});
|
52
|
+
|
53
|
+
xtest('rotate numbers', () => {
|
54
|
+
const expected = 'Xiwxmrk 1 2 3 xiwxmrk';
|
55
|
+
const actual = RotationalCipher.rotate('Testing 1 2 3 testing', 4);
|
56
|
+
|
57
|
+
expect(actual).toEqual(expected);
|
58
|
+
});
|
59
|
+
|
60
|
+
xtest('rotate punctuation', () => {
|
61
|
+
const expected = 'Gzo\'n zvo, Bmviyhv!';
|
62
|
+
const actual = RotationalCipher.rotate('Let\'s eat, Grandma!', 21);
|
63
|
+
|
64
|
+
expect(actual).toEqual(expected);
|
65
|
+
});
|
66
|
+
|
67
|
+
xtest('rotate all letters', () => {
|
68
|
+
const expected = 'Gur dhvpx oebja sbk whzcf bire gur ynml qbt.';
|
69
|
+
const actual = RotationalCipher.rotate('The quick brown fox jumps over the lazy dog.', 13);
|
70
|
+
|
71
|
+
expect(actual).toEqual(expected);
|
72
|
+
});
|
73
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Spiral matrix
|
2
|
+
|
3
|
+
Given the size, return a square matrix of numbers in spiral order.
|
4
|
+
|
5
|
+
The matrix should be filled with natural numbers, starting from 1
|
6
|
+
in the top-left corner, increasing in an inward, clockwise spiral order,
|
7
|
+
like these examples:
|
8
|
+
|
9
|
+
###### Spiral matrix of size 3
|
10
|
+
|
11
|
+
```text
|
12
|
+
1 2 3
|
13
|
+
8 9 4
|
14
|
+
7 6 5
|
15
|
+
```
|
16
|
+
|
17
|
+
###### Spiral matrix of size 4
|
18
|
+
|
19
|
+
```text
|
20
|
+
1 2 3 4
|
21
|
+
12 13 14 5
|
22
|
+
11 16 15 6
|
23
|
+
10 9 8 7
|
24
|
+
```
|
25
|
+
|
26
|
+
## Setup
|
27
|
+
|
28
|
+
Go through the setup instructions for ECMAScript to
|
29
|
+
install the necessary dependencies:
|
30
|
+
|
31
|
+
http://exercism.io/languages/ecmascript/installation
|
32
|
+
|
33
|
+
## Requirements
|
34
|
+
|
35
|
+
Install assignment dependencies:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
$ npm install
|
39
|
+
```
|
40
|
+
|
41
|
+
## Making the test suite pass
|
42
|
+
|
43
|
+
Execute the tests with:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ npm test
|
47
|
+
```
|
48
|
+
|
49
|
+
In the test suites all tests but the first have been skipped.
|
50
|
+
|
51
|
+
Once you get a test passing, you can enable the next one by
|
52
|
+
changing `xtest` to `test`.
|
53
|
+
|
54
|
+
## Source
|
55
|
+
|
56
|
+
Reddit [Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension.](https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/)
|
57
|
+
|
58
|
+
## Submitting Incomplete Solutions
|
59
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class SpiralMatrix {
|
2
|
+
|
3
|
+
static ofSize(size) {
|
4
|
+
const spiral = Array(size).fill().map(() => Array(0));
|
5
|
+
|
6
|
+
const totalNumbers = size**2;
|
7
|
+
let currentNumber = 1;
|
8
|
+
let topLeft = 0;
|
9
|
+
let bottomRight = size - 1;
|
10
|
+
|
11
|
+
while (currentNumber <= totalNumbers) {
|
12
|
+
for (let x = topLeft; x <= bottomRight; x++) spiral[topLeft][x] = currentNumber++;
|
13
|
+
for (let y = topLeft + 1; y <= bottomRight; y++) spiral[y][bottomRight] = currentNumber++;
|
14
|
+
for (let x = bottomRight - 1; x >= topLeft; x--) spiral[bottomRight][x] = currentNumber++;
|
15
|
+
for (let y = bottomRight - 1; y >= topLeft + 1; y--) spiral[y][topLeft] = currentNumber++;
|
16
|
+
|
17
|
+
topLeft++;
|
18
|
+
bottomRight--;
|
19
|
+
}
|
20
|
+
|
21
|
+
return spiral;
|
22
|
+
}
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
export default SpiralMatrix;
|
@@ -0,0 +1,72 @@
|
|
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": "^21.2.0",
|
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": "^21.2.1"
|
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
|
+
"no-plusplus": "off"
|
66
|
+
}
|
67
|
+
},
|
68
|
+
"licenses": [
|
69
|
+
"MIT"
|
70
|
+
],
|
71
|
+
"dependencies": {}
|
72
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import SpiralMatrix from './spiral-matrix';
|
2
|
+
|
3
|
+
describe('Spiral Matrix', () => {
|
4
|
+
test('empty spiral', () => {
|
5
|
+
const expected = [];
|
6
|
+
const actual = SpiralMatrix.ofSize(0);
|
7
|
+
|
8
|
+
expect(actual).toEqual(expected);
|
9
|
+
});
|
10
|
+
|
11
|
+
xtest('trivial spiral', () => {
|
12
|
+
const expected = [[1]];
|
13
|
+
const actual = SpiralMatrix.ofSize(1);
|
14
|
+
|
15
|
+
expect(actual).toEqual(expected);
|
16
|
+
});
|
17
|
+
|
18
|
+
xtest('spiral of size 2', () => {
|
19
|
+
const expected = [[1, 2],
|
20
|
+
[4, 3]];
|
21
|
+
const actual = SpiralMatrix.ofSize(2);
|
22
|
+
|
23
|
+
expect(actual).toEqual(expected);
|
24
|
+
});
|
25
|
+
|
26
|
+
xtest('spiral of size 3', () => {
|
27
|
+
const expected = [[1, 2, 3],
|
28
|
+
[8, 9, 4],
|
29
|
+
[7, 6, 5]];
|
30
|
+
const actual = SpiralMatrix.ofSize(3);
|
31
|
+
|
32
|
+
expect(actual).toEqual(expected);
|
33
|
+
});
|
34
|
+
|
35
|
+
xtest('spiral of size 4', () => {
|
36
|
+
const expected = [[1, 2, 3, 4],
|
37
|
+
[12, 13, 14, 5],
|
38
|
+
[11, 16, 15, 6],
|
39
|
+
[10, 9, 8, 7]];
|
40
|
+
const actual = SpiralMatrix.ofSize(4);
|
41
|
+
|
42
|
+
expect(actual).toEqual(expected);
|
43
|
+
});
|
44
|
+
|
45
|
+
xtest('spiral of size 5', () => {
|
46
|
+
const expected = [[1, 2, 3, 4, 5],
|
47
|
+
[16, 17, 18, 19, 6],
|
48
|
+
[15, 24, 25, 20, 7],
|
49
|
+
[14, 23, 22, 21, 8],
|
50
|
+
[13, 12, 11, 10, 9]];
|
51
|
+
const actual = SpiralMatrix.ofSize(5);
|
52
|
+
|
53
|
+
expect(expected).toEqual(actual);
|
54
|
+
});
|
55
|
+
});
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Transpose
|
2
|
+
|
3
|
+
Given an input text output it transposed.
|
4
|
+
|
5
|
+
Roughly explained, the transpose of a matrix:
|
6
|
+
|
7
|
+
```text
|
8
|
+
ABC
|
9
|
+
DEF
|
10
|
+
```
|
11
|
+
|
12
|
+
is given by:
|
13
|
+
|
14
|
+
```text
|
15
|
+
AD
|
16
|
+
BE
|
17
|
+
CF
|
18
|
+
```
|
19
|
+
|
20
|
+
Rows become columns and columns become rows. See <https://en.wikipedia.org/wiki/Transpose>.
|
21
|
+
|
22
|
+
If the input has rows of different lengths, this is to be solved as follows:
|
23
|
+
|
24
|
+
- Pad to the left with spaces.
|
25
|
+
- Don't pad to the right.
|
26
|
+
|
27
|
+
Therefore, transposing this matrix:
|
28
|
+
|
29
|
+
```text
|
30
|
+
ABC
|
31
|
+
DE
|
32
|
+
```
|
33
|
+
|
34
|
+
results in:
|
35
|
+
|
36
|
+
```text
|
37
|
+
AD
|
38
|
+
BE
|
39
|
+
C
|
40
|
+
```
|
41
|
+
|
42
|
+
And transposing:
|
43
|
+
|
44
|
+
```text
|
45
|
+
AB
|
46
|
+
DEF
|
47
|
+
```
|
48
|
+
|
49
|
+
results in:
|
50
|
+
|
51
|
+
```text
|
52
|
+
AD
|
53
|
+
BE
|
54
|
+
F
|
55
|
+
```
|
56
|
+
|
57
|
+
In general, all characters from the input should also be present in the transposed output.
|
58
|
+
That means that if a column in the input text contains only spaces on its bottom-most row(s),
|
59
|
+
the corresponding output row should contain the spaces in its right-most column(s).
|
60
|
+
|
61
|
+
## Setup
|
62
|
+
|
63
|
+
Go through the setup instructions for ECMAScript to
|
64
|
+
install the necessary dependencies:
|
65
|
+
|
66
|
+
http://exercism.io/languages/ecmascript
|
67
|
+
|
68
|
+
## Requirements
|
69
|
+
|
70
|
+
Install assignment dependencies:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
$ npm install
|
74
|
+
```
|
75
|
+
|
76
|
+
## Making the Test Suite Pass
|
77
|
+
|
78
|
+
Execute the tests with:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
$ npm test
|
82
|
+
```
|
83
|
+
|
84
|
+
In the test suite, all tests but the first have been skipped.
|
85
|
+
|
86
|
+
Once you get a test passing, you can enable the next one by
|
87
|
+
changing `xtest` to `test`.
|
88
|
+
|
89
|
+
## Source
|
90
|
+
|
91
|
+
Reddit r/dailyprogrammer challenge #270 [Easy]. [https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text](https://www.reddit.com/r/dailyprogrammer/comments/4msu2x/challenge_270_easy_transpose_the_input_text)
|
92
|
+
|
93
|
+
## Submitting Incomplete Solutions
|
94
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|