Skip to content

Commit 3beeb5f

Browse files
committed
Adding tests for "The urinal problem".
1 parent 9cdc0aa commit 3beeb5f

File tree

7 files changed

+87
-0
lines changed

7 files changed

+87
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Tests for "ASCII ART : glass stacking".
3030
- Tests for "De-FizzBuzzer".
3131
- Tests for "Find the replacement".
32+
- Tests for "The urinal problem".
3233

3334
## [1.16.0] - 2022-12-31
3435
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "The urinal problem" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/the-urinal-problem}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
const B = readline();
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('0');
13+
}
14+
15+
export { execute };
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/theUrinalProblem/theUrinalProblem.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("The urinal problem", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("Small bathroom", function() {
21+
let inputFile = new File(__dirname + 'input/01 - small bathroom.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
0
28+
);
29+
});
30+
31+
test("School bathroom", function() {
32+
let inputFile = new File(__dirname + 'input/02 - school bathroom.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
2
39+
);
40+
});
41+
42+
test("Sporting event", function() {
43+
let inputFile = new File(__dirname + 'input/03 - sporting event.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
23
50+
);
51+
});
52+
53+
test("Mostly empty", function() {
54+
let inputFile = new File(__dirname + 'input/04 - mostly empty.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
19
61+
);
62+
});
63+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
UU!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
!UUU!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
32
2+
!!U!!U!U!!UUUU!UU!!UUUUUUUUU!!!!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
20
2+
UUUUUUUUU!UUUUUUUUUU

0 commit comments

Comments
 (0)