Skip to content

Commit 0b280a7

Browse files
committed
Adding tests for "Snake encoding".
1 parent 7c31d57 commit 0b280a7

File tree

11 files changed

+129
-0
lines changed

11 files changed

+129
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Magic stones".
3333
- Tests for "Game of life".
3434
- Tests for "Maximum sub-sequence".
35+
- Tests for "Snake encoding".
3536

3637
## [1.13.0] - 2022-09-30
3738
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Snake encoding" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/snake-encoding}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
const X = parseInt(readline());
8+
for (let i = 0; i < N; i++) {
9+
const LINE = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
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/medium/snakeEncoding/snakeEncoding.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Snake encoding", 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("Very easy", function() {
22+
let inputFile = new File(__dirname + 'input/01 - easy peasy.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - easy peasy.txt');
27+
});
28+
29+
test("More rows", function() {
30+
let inputFile = new File(__dirname + 'input/02 - more rows.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - more rows.txt');
35+
});
36+
37+
test("More loops", function() {
38+
let inputFile = new File(__dirname + 'input/03 - more loops.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - more loops.txt');
43+
});
44+
45+
test("Let's try everything", function() {
46+
let inputFile = new File(__dirname + 'input/04 - let\'s try everything.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - let\'s try everything.txt');
51+
});
52+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3
2+
1
3+
ABC
4+
DEF
5+
GHI
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
5
2+
1
3+
ABCDE
4+
FGHIJ
5+
KLMNO
6+
PQRST
7+
UVWXY
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
7
2+
5
3+
I_LOVE_
4+
TESTING
5+
AMAZING
6+
ENCODES
7+
NOTYOU?
8+
NUM83R5
9+
NICE:)!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
38
3+
PN_OOEITH_
4+
_THYSNLIKM
5+
LRNIEGC'A_
6+
_CVDR!IO'E
7+
!E!Y!U9_0O
8+
OT_IO_RINE
9+
>EAGE!BHEL
10+
NO_E__ITWS
11+
A!T!A!Z0_0
12+
RMWRTWRAED
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DAF
2+
GBI
3+
CEH
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FAHCJ
2+
KBMDO
3+
PGRIT
4+
ULWNY
5+
EQVSX
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NNMT3O5
2+
NECC:D!
3+
_AIAEI)
4+
GTUS8IR
5+
GIOLYVU
6+
S_NOOEE
7+
?EMTZNN

0 commit comments

Comments
 (0)