Skip to content

Commit 6fc351f

Browse files
committed
Adding tests for "Feature extraction".
1 parent 6db220f commit 6fc351f

File tree

11 files changed

+151
-0
lines changed

11 files changed

+151
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "Is the king in check? (part 1)".
3535
- Tests for "A mountain of a mole hill".
3636
- Tests for "Where's Wally".
37+
- Tests for "Feature extraction".
3738

3839
### Fixed
3940
- File import for "A child's play".
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* The "Feature extraction" puzzle.
3+
*/
4+
function execute(readline) {
5+
var inputs = readline().split(' ');
6+
const r = parseInt(inputs[0]);
7+
const c = parseInt(inputs[1]);
8+
for (let i = 0; i < r; i++) {
9+
var inputs = readline().split(' ');
10+
for (let j = 0; j < c; j++) {
11+
const pixel = parseInt(inputs[j]);
12+
}
13+
}
14+
var inputs = readline().split(' ');
15+
const m = parseInt(inputs[0]);
16+
const n = parseInt(inputs[1]);
17+
for (let i = 0; i < m; i++) {
18+
var inputs = readline().split(' ');
19+
for (let j = 0; j < n; j++) {
20+
const weight = parseInt(inputs[j]);
21+
}
22+
}
23+
24+
// Write an answer using console.log()
25+
// To debug: console.error('Debug messages...');
26+
27+
console.log('output matrix');
28+
}
29+
30+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5+
import { execute } from '../../../../../lib/community/training/easy/featureExtraction/featureExtraction.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Feature extraction", function() {
10+
const sandbox = sinon.createSandbox();
11+
12+
setup(function () {
13+
sandbox.stub(console, "log");
14+
});
15+
16+
teardown(function () {
17+
sandbox.restore();
18+
});
19+
20+
21+
test("Test 1", function() {
22+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - test 1.txt');
27+
});
28+
29+
test("Test 2", function() {
30+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - test 2.txt');
35+
});
36+
37+
test("Test 3", function() {
38+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - test 3.txt');
43+
});
44+
45+
test("Test 4", function() {
46+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - test 4.txt');
51+
});
52+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
3 3
2+
100 200 100
3+
200 100 200
4+
50 100 50
5+
2 2
6+
-1 1
7+
1 -1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
5 5
2+
100 200 0 200 240
3+
20 230 240 0 250
4+
117 199 200 267 83
5+
29 212 243 111 33
6+
100 200 300 400 500
7+
3 3
8+
-1 0 -1
9+
-1 0 -1
10+
-1 0 -1
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
10 10
2+
247 152 122 236 159 118 172 233 133 121
3+
174 201 193 86 94 203 42 3 69 21
4+
221 56 36 182 108 163 48 240 119 89
5+
162 150 97 219 180 133 78 51 237 62
6+
189 100 234 246 138 50 69 201 90 98
7+
42 155 149 181 172 194 17 234 134 52
8+
247 249 131 244 11 227 32 221 14 197
9+
132 246 162 16 24 185 15 146 156 227
10+
121 3 118 199 241 231 18 12 152 147
11+
185 231 237 114 239 145 215 33 218 227
12+
5 5
13+
1 1 1 1 1
14+
1 2 2 2 1
15+
1 2 3 2 1
16+
1 2 2 2 1
17+
1 1 1 1 1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
10 5
2+
129 176 6 190 225
3+
210 5 179 222 62
4+
137 51 87 40 106
5+
173 149 166 183 85
6+
53 81 213 6 228
7+
144 73 6 216 183
8+
32 9 200 34 54
9+
68 197 15 183 138
10+
143 197 113 34 94
11+
101 98 139 89 207
12+
3 3
13+
2 2 2
14+
2 5 2
15+
2 2 2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
200 -200
2+
-150 150
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-677 -1096 -1013
2+
-849 -1019 -1049
3+
-989 -1389 -1359
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5238 5033 4882 4664 4140 3970
2+
5182 5379 4911 4432 4178 3881
3+
5664 5667 4990 4720 4257 4362
4+
5714 5580 4839 4388 4271 4366
5+
5414 5240 4569 4428 4287 4309
6+
5379 5266 4919 4535 4388 4361

0 commit comments

Comments
 (0)