Skip to content

Commit 15cd24d

Browse files
committed
Adding tests for "Surface".
1 parent 04663a6 commit 15cd24d

19 files changed

+2094
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Tests for "Genome sequencing".
1313
- Tests for "Roller coaster".
1414
- Tests for "Super computer".
15+
- Tests for "Surface".
1516

1617
## [1.3.0] - 2022-03-02
1718
### Added
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* The "Surface" puzzle.
3+
*/
4+
function execute(readline) {
5+
const L = parseInt(readline());
6+
const H = parseInt(readline());
7+
for (let i = 0; i < H; i++) {
8+
const row = readline();
9+
}
10+
const N = parseInt(readline());
11+
for (let i = 0; i < N; i++) {
12+
var inputs = readline().split(' ');
13+
const X = parseInt(inputs[0]);
14+
const Y = parseInt(inputs[1]);
15+
}
16+
for (let i = 0; i < N; i++) {
17+
18+
// Write an answer using console.log()
19+
// To debug: console.error('Debug messages...');
20+
21+
console.log('answer');
22+
}
23+
}
24+
25+
export { execute };
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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/training/hard/surface/surface.js';
6+
7+
/**
8+
* Tests for the "Surface" puzzle.
9+
*/
10+
suite('Surface', function() {
11+
const sandbox = sinon.createSandbox();
12+
13+
setup(function () {
14+
sandbox.stub(console, "log");
15+
});
16+
17+
teardown(function () {
18+
sandbox.restore();
19+
});
20+
21+
22+
test('Example of the statement', function() {
23+
let inputFile = new File('./test/training/hard/surface/input/01 - example of the statement.txt');
24+
25+
execute(inputFile.readline.bind(inputFile));
26+
27+
assertOutputAnswer('./test/training/hard/surface/output/01 - example of the statement.txt');
28+
});
29+
30+
test('No lake', function() {
31+
let inputFile = new File('./test/training/hard/surface/input/02 - no lake.txt');
32+
33+
execute(inputFile.readline.bind(inputFile));
34+
35+
assert.strictEqual(
36+
console.log.getCall(0).args[0],
37+
0
38+
);
39+
});
40+
41+
test('The area is a lake', function() {
42+
let inputFile = new File('./test/training/hard/surface/input/03 - the area is a lake.txt');
43+
44+
execute(inputFile.readline.bind(inputFile));
45+
46+
assertOutputAnswer('./test/training/hard/surface/output/03 - the area is a lake.txt');
47+
});
48+
49+
test('1 lake on a small map', function() {
50+
let inputFile = new File('./test/training/hard/surface/input/04 - 1 lake on a small map.txt');
51+
52+
execute(inputFile.readline.bind(inputFile));
53+
54+
assertOutputAnswer('./test/training/hard/surface/output/04 - 1 lake on a small map.txt');
55+
});
56+
57+
test('Several lakes on a small map', function() {
58+
let inputFile = new File('./test/training/hard/surface/input/05 - several lakes on a small map.txt');
59+
60+
execute(inputFile.readline.bind(inputFile));
61+
62+
assertOutputAnswer('./test/training/hard/surface/output/05 - several lakes on a small map.txt');
63+
});
64+
65+
test('Some lakes on a 20x20 map', function() {
66+
let inputFile = new File('./test/training/hard/surface/input/06 - some lakes on a 20x20 map.txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assertOutputAnswer('./test/training/hard/surface/output/06 - some lakes on a 20x20 map.txt');
71+
});
72+
73+
test('Many lakes on a 100x50 map', function() {
74+
let inputFile = new File('./test/training/hard/surface/input/07 - many lakes on a 100x50 map.txt');
75+
76+
execute(inputFile.readline.bind(inputFile));
77+
78+
assertOutputAnswer('./test/training/hard/surface/output/07 - many lakes on a 100x50 map.txt');
79+
});
80+
81+
test('100 tests on a 1000x1000 map', function() {
82+
let inputFile = new File('./test/training/hard/surface/input/08 - 100 tests on a 1000x1000 map.txt');
83+
84+
execute(inputFile.readline.bind(inputFile));
85+
86+
assertOutputAnswer('./test/training/hard/surface/output/08 - 100 tests on a 1000x1000 map.txt');
87+
});
88+
89+
test('Large map, large lake', function() {
90+
let inputFile = new File('./test/training/hard/surface/input/09 - large map, large lake.txt');
91+
92+
execute(inputFile.readline.bind(inputFile));
93+
94+
assert.strictEqual(
95+
console.log.getCall(0).args[0],
96+
359997
97+
);
98+
});
99+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
4
2+
4
3+
####
4+
##O#
5+
#OO#
6+
####
7+
3
8+
0 0
9+
1 2
10+
2 1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1
2+
1
3+
#
4+
1
5+
0 0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3
2+
3
3+
OOO
4+
OOO
5+
OOO
6+
3
7+
0 0
8+
1 1
9+
2 2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
4
2+
4
3+
####
4+
#OO#
5+
#OO#
6+
####
7+
5
8+
0 0
9+
1 1
10+
2 1
11+
3 3
12+
1 2
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
6
2+
6
3+
OO###O
4+
#O###O
5+
#OO##O
6+
####O#
7+
##OO##
8+
##OO##
9+
5
10+
1 0
11+
3 3
12+
5 1
13+
0 5
14+
2 5
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
20
2+
20
3+
########OOOO#OOO####
4+
########OOOOOO######
5+
########OO##########
6+
########OO##########
7+
#######OOO##########
8+
#################O##
9+
#################O##
10+
######OOO######OOO##
11+
######OOOO####OOOO##
12+
##############OOOOO#
13+
##############OOO#OO
14+
##############OOOOOO
15+
#############OOOO###
16+
####################
17+
####################
18+
#####OO#############
19+
####################
20+
####################
21+
####################
22+
##############OOOOO#
23+
10
24+
8 2
25+
8 7
26+
6 15
27+
16 7
28+
6 7
29+
16 7
30+
14 19
31+
18 19
32+
16 7
33+
15 9
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
100
2+
50
3+
#################OO######OO#########O##########OOO#O#O##############################################
4+
#########################OOOOO#################OOOOOOOO#############################################
5+
#########################OOOOO#################OO#OOOOO#############################################
6+
####OO####################OOOOOO###############OOO#OOO###########################OO#################
7+
##OOOOO################O##OOOOOO###########OOOOOO##O##############################O####OO###########
8+
#OOOOOO##OO###########OO#OO##OOOOOO########OOO#OO##O####O############################OOOOO##########
9+
#OOO##################OO#####OOOOO#########O#####O#####OOOOO###OO###################OO#O############
10+
######################OO####OOO#OO#####################O#######OO########O##########################
11+
######################OOO###########################OOOOOOO###OOO##################O##############O#
12+
######################OOO###########################OOO#O#####OOO#################OO#OOO##########O#
13+
#####################################################OO#O#####OOOO################OOO#OO##########O#
14+
################O#####################################OOO#######OO#############OO###O##O#######OOO##
15+
####################################################OOOOO#####################OOO###O##########OO#O#
16+
###############################################OO####O#OO###################OOOOO###############OOO#
17+
##############################OO#####O#######OOO#####OOOO####################OO##################OO#
18+
##########################O###O######O#########O#######OO#######################O##########O#####OO#
19+
#########################OOO###################O################################O###################
20+
###########################OO##########################O#O#####################################OO###
21+
###########OO#######O##############O###################OOOO#####O############################OOOO###
22+
##########OO################OOO##OOO###################O#O######################################O#O#
23+
#########OO##################OOO##O####################O##############OOO#########################OO
24+
##OO#OO##########################OO##############O#####O##############OOO#########################OO
25+
###OOO###########################O#########O#####O#####################OO#########################O#
26+
####OOOO#######################OOO#########OO#######################################################
27+
###OOO#OO######################O####################################################################
28+
###OO##OO######################O###########################################################O########
29+
###################OOO###############################OO######################################O######
30+
################O##OOO###############################OOO############################################
31+
################O###OOO##########################################OO#################################
32+
################OO##OOO#######O##################################O##################################
33+
####################OO########OO###########OO####################O##################################
34+
####################OO#####################OO#######################################################
35+
####O#############################################################################O#################
36+
###OO########OO###############O###################################################O##############OOO
37+
##OOOOOO#####OO#############OOO####################OO#######################OO####OOO###########OO##
38+
OOOO#OO######O#####################################O##############################OOOO###########O##
39+
#OOO########OO######################################################O###########OOOOOO##########OO##
40+
#OOO#########OO########################################O############OO###########O#O############OO##
41+
OOOO###################################################OO######################OOO#OO###########OO##
42+
O##OO###################################################OOOO#################OOOO###OO#########OOO##
43+
#######################O###########OO###################O##########OO#O######OO################OOO##
44+
######################OOOO####OO##OO############OO######O#####O#####OOO######O################OOOO##
45+
###########OOOOO#####OOOOO##OOO###OOO#########################O####OO#OO######################OO#O##
46+
###############O#####OOO######O#####O#############OO################OOOOO#O###################OOOO##
47+
######################OO######O#####O#######OO##OOOO#################O##OOOOOO################OOOO##
48+
######################OOO####OOO#############O##OOOO#################O##OOOOO###############O###O###
49+
###################O##OO#######O########OO##OO####OOO###############OO##OO#O########################
50+
########################################OO###O######O######################O########################
51+
####################################################OOOO###################O####O##OOO##############
52+
#####################################################OO##################OOO#####OOOOO##############
53+
100
54+
30 4
55+
54 12
56+
30 14
57+
54 27
58+
97 11
59+
52 12
60+
22 28
61+
25 0
62+
83 49
63+
54 2
64+
31 23
65+
75 45
66+
15 43
67+
83 48
68+
27 3
69+
31 23
70+
56 13
71+
30 34
72+
49 41
73+
7 34
74+
84 39
75+
5 3
76+
31 4
77+
53 10
78+
56 12
79+
8 24
80+
7 34
81+
57 18
82+
70 40
83+
28 3
84+
54 1
85+
28 42
86+
22 45
87+
54 2
88+
23 43
89+
21 42
90+
45 14
91+
87 6
92+
44 46
93+
3 4
94+
96 36
95+
33 7
96+
62 8
97+
62 42
98+
19 26
99+
32 23
100+
82 32
101+
75 46
102+
96 13
103+
48 5
104+
24 45
105+
52 9
106+
2 36
107+
75 47
108+
23 42
109+
95 44
110+
6 35
111+
43 6
112+
13 35
113+
8 24
114+
7 24
115+
96 43
116+
98 22
117+
98 19
118+
30 33
119+
52 3
120+
28 17
121+
59 39
122+
77 44
123+
68 37
124+
74 43
125+
64 8
126+
55 15
127+
98 20
128+
80 38
129+
57 17
130+
43 23
131+
19 27
132+
30 42
133+
65 28
134+
47 3
135+
57 17
136+
21 27
137+
2 6
138+
98 13
139+
1 36
140+
36 0
141+
77 13
142+
44 4
143+
31 46
144+
87 4
145+
21 26
146+
28 3
147+
22 43
148+
80 15
149+
26 3
150+
29 45
151+
25 41
152+
65 11
153+
44 30

0 commit comments

Comments
 (0)