Skip to content

Commit d94a633

Browse files
committed
Adding tests for "Faro shuffle".
1 parent 30884b6 commit d94a633

File tree

8 files changed

+86
-0
lines changed

8 files changed

+86
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Tests for "What's so complex about Mandelbrot?".
2828
- Tests for "Auto pickup".
2929
- Tests for "Annihilation".
30+
- Tests for "Faro shuffle".
3031

3132
## [1.9.0] - 2022-06-01
3233
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "Faro shuffle" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/faro-shuffle}
4+
*/
5+
function execute(readline) {
6+
const n = parseInt(readline());
7+
const deck = readline();
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('answer');
13+
}
14+
15+
export { execute };
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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/faroShuffle/faroShuffle.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Faro shuffle", 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("Aces", function() {
22+
let inputFile = new File(__dirname + 'input/01 - aces.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
"AS AD AH AC"
29+
);
30+
});
31+
32+
test("Odd number of cards", function() {
33+
let inputFile = new File(__dirname + 'input/02 - odd number of cards.txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
"2S JH 5D JD QH 5S 3S KH 4S"
40+
);
41+
});
42+
43+
test("Multiple shuffles", function() {
44+
let inputFile = new File(__dirname + 'input/03 - multiple shuffles.txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
"KS 8S 5S QH 5H 9D 6D AH KD KH AS 7H 3S 5D QS 4S JH KC 5C JS"
51+
);
52+
});
53+
54+
test("Fresh deck", function() {
55+
let inputFile = new File(__dirname + 'input/04 - fresh deck.txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assertOutputAnswer(__dirname + 'output/04 - fresh deck.txt');
60+
});
61+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
AS AH AD AC
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
2S 5D QH 3S 4S JH JD 5S KH
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
10
2+
KS KC 4S 5D 7H KH AH 9D QH 8S 5C JH QS 3S AS KD 6D 5H 5S JS
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
52
2+
AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH KC QC JC 10C 9C 8C 7C 6C 5C 4C 3C 2C AC KD QD JD 10D 9D 8D 7D 6D 5D 4D 3D 2D AD
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AS 4H 7C 4D AH 10C 7D JS KC 10D 8S JH KD 5S 8H 3C 2S 5H 6C 3D 2H 9C 6D QS QC 9D 9S QH QD 6S 9H 2C 3S 6H 5C 2D 3H 8C 5D KS JC 8D 10S KH JD 7S 10H AC 4S 7H 4C AD

0 commit comments

Comments
 (0)