File tree Expand file tree Collapse file tree 6 files changed +100083
-0
lines changed
lib/training/hard/superComputer
test/training/hard/superComputer Expand file tree Collapse file tree 6 files changed +100083
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111- Tests for "CGX formatter".
1212- Tests for "Genome sequencing".
1313- Tests for "Roller coaster".
14+ - Tests for "Super computer".
1415
1516## [ 1.3.0] - 2022-03-02
1617### Added
Original file line number Diff line number Diff line change 1+ /**
2+ * The "Super computer" puzzle.
3+ */
4+ function execute(readline) {
5+ const N = parseInt(readline());
6+ for (let i = 0; i < N; i++) {
7+ var inputs = readline().split(' ');
8+ const J = parseInt(inputs[0]);
9+ const D = parseInt(inputs[1]);
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 };
Original file line number Diff line number Diff line change 1+ import { assert } from 'chai' ;
2+ import sinon from 'sinon' ;
3+ import File from '../../../File.js' ;
4+ import { execute } from '../../../../lib/training/hard/superComputer/superComputer.js' ;
5+
6+ /**
7+ * Tests for the "Super computer" puzzle.
8+ */
9+ suite ( 'Super computer' , 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 ( 'Example 1' , function ( ) {
22+ let inputFile = new File ( './test/training/hard/superComputer/input/01 - example 1.txt' ) ;
23+
24+ execute ( inputFile . readline . bind ( inputFile ) ) ;
25+
26+ assert . strictEqual (
27+ console . log . getCall ( 0 ) . args [ 0 ] ,
28+ 3
29+ ) ;
30+ } ) ;
31+
32+ test ( 'Example 2' , function ( ) {
33+ let inputFile = new File ( './test/training/hard/superComputer/input/02 - example 2.txt' ) ;
34+
35+ execute ( inputFile . readline . bind ( inputFile ) ) ;
36+
37+ assert . strictEqual (
38+ console . log . getCall ( 0 ) . args [ 0 ] ,
39+ 4
40+ ) ;
41+ } ) ;
42+
43+ test ( 'Large number of scientists' , function ( ) {
44+ let inputFile = new File ( './test/training/hard/superComputer/input/03 - large number of scientists.txt' ) ;
45+
46+ execute ( inputFile . readline . bind ( inputFile ) ) ;
47+
48+ assert . strictEqual (
49+ console . log . getCall ( 0 ) . args [ 0 ] ,
50+ 7879
51+ ) ;
52+ } ) ;
53+ } ) ;
Original file line number Diff line number Diff line change 1+ 4
2+ 2 5
3+ 9 7
4+ 15 6
5+ 9 3
Original file line number Diff line number Diff line change 1+ 5
2+ 3 5
3+ 9 2
4+ 24 5
5+ 16 9
6+ 11 6
You can’t perform that action at this time.
0 commit comments