Skip to content

Commit c9fb093

Browse files
committed
Adding tests for "Gravity centrifuge".
1 parent c1fddff commit c9fb093

25 files changed

+492
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "Maximum sub-sequence".
3535
- Tests for "Snake encoding".
3636
- Tests for "Binary search tree traversal".
37+
- Tests for "Gravity centrifuge".
3738

3839
## [1.13.0] - 2022-09-30
3940
### Added
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* The "Gravity centrifuge" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/gravity-centrifuge}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const width = parseInt(inputs[0]);
8+
const height = parseInt(inputs[1]);
9+
const bitstream = readline();
10+
for (let i = 0; i < height; i++) {
11+
const raster = readline();
12+
}
13+
14+
// Write an answer using console.log()
15+
// To debug: console.error('Debug messages...');
16+
17+
console.log('...');
18+
console.log('write ###');
19+
}
20+
21+
export { execute };
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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/gravityCentrifuge/gravityCentrifuge.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Gravity centrifuge", 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("Tumble", function() {
22+
let inputFile = new File(__dirname + 'input/01 - tumble.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - tumble.txt');
27+
});
28+
29+
test("Double tumble", function() {
30+
let inputFile = new File(__dirname + 'input/02 - double tumble.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - double tumble.txt');
35+
});
36+
37+
test("Triple tumble", function() {
38+
let inputFile = new File(__dirname + 'input/03 - triple tumble.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - triple tumble.txt');
43+
});
44+
45+
test("Octal, remember?", function() {
46+
let inputFile = new File(__dirname + 'input/04 - octal, remember?.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - octal, remember?.txt');
51+
});
52+
53+
test("Dead beef!", function() {
54+
let inputFile = new File(__dirname + 'input/05 - dead beef!.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - dead beef!.txt');
59+
});
60+
61+
test("Wait, what?", function() {
62+
let inputFile = new File(__dirname + 'input/06 - wait, what?.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - wait, what?.txt');
67+
});
68+
69+
test("Leonardo would be proud of you!", function() {
70+
let inputFile = new File(__dirname + 'input/07 - leonardo would be proud of you!.txt');
71+
72+
execute(inputFile.readline.bind(inputFile));
73+
74+
assertOutputAnswer(__dirname + 'output/07 - leonardo would be proud of you!.txt');
75+
});
76+
77+
test("Randomize this! 1", function() {
78+
let inputFile = new File(__dirname + 'input/08 - randomize this! 1.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assertOutputAnswer(__dirname + 'output/08 - randomize this! 1.txt');
83+
});
84+
85+
test("Randomize this! 2", function() {
86+
let inputFile = new File(__dirname + 'input/09 - randomize this! 2.txt');
87+
88+
execute(inputFile.readline.bind(inputFile));
89+
90+
assertOutputAnswer(__dirname + 'output/09 - randomize this! 2.txt');
91+
});
92+
93+
test("Randomize this! 3", function() {
94+
let inputFile = new File(__dirname + 'input/10 - randomize this! 3.txt');
95+
96+
execute(inputFile.readline.bind(inputFile));
97+
98+
assertOutputAnswer(__dirname + 'output/10 - randomize this! 3.txt');
99+
});
100+
101+
test("Binary overflow", function() {
102+
let inputFile = new File(__dirname + 'input/11 - binary overflow.txt');
103+
104+
execute(inputFile.readline.bind(inputFile));
105+
106+
assertOutputAnswer(__dirname + 'output/11 - binary overflow.txt');
107+
});
108+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
1
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
2
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
3
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
21
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
33653337357
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
30 30
2+
0
3+
#.............................
4+
##............................
5+
###...........................
6+
####..........................
7+
#####.........................
8+
######........................
9+
#######.......................
10+
########......................
11+
#########.....................
12+
##########....................
13+
###########...................
14+
############..................
15+
#############.................
16+
##############................
17+
###############...............
18+
################..............
19+
#################.............
20+
##################............
21+
###################...........
22+
####################..........
23+
#####################.........
24+
######################........
25+
#######################.......
26+
########################......
27+
#########################.....
28+
##########################....
29+
###########################...
30+
############################..
31+
#############################.
32+
##############################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
036552005474503316045244671230763257003205014454317576646651415104774736246223373530313543560352164675733542160416774256562757577303267565012230756331362352034623360206073524577272542727226442237112601327613774057747725750341340753703545317067320271760727065756551547627517027756041053372433206524506305322662235721143776644653261365351545655002362143663425275352313534465104446036610600643036025772116355212061200241173664361043257311542104115720766553324425510464301637020654061515334351050457145403553442710724323272370165061645576562621353341046006465300722065367354371476040217304462317524626601116071471704311723534624446517016162546173154627355536105332145302452666667052741627742567041144634255113226074163450446340730577023251132562517764132661643634561101441605234725545672745147604047344107476323035165312334227520113715470352043224655552333531070060723733560137766353333476227620573710253513265475317654630057735435711244616721716003013704331332524464463622072302160525633656622276147130635210036151214373652774273660761320071053620621133557625334726662556436641742653246703131246066013553507376333015270160553757012763260125267743524524636030372645535203666750146610307147510144326347611134441256264766060726753173071641152023702530047241137740756725637666606025473241622520615527123673042600110346506536722372313355225463517175657475547503115103401362664075702426242144651613520651506777122360441166024773013444547461651724534302031343001147716263700252434406137523477300047534766512053651416524721362034205354172626744241146174301440216722041206622536315466023562476472430030006430603117002270204432726026454520035276670450431423020741205736652401724750355312225133510031717076564744555057350261100720427166027015615375177604577601164757003403444352471033655143723650320252674114315570223754537624102150012732443540551117225757056221102550141204076031570772177453344431514243705133567727310524640054624235456547520216717561536731021652540536375230055371650406261061745601110745003265216067544444550112227770343064763221111673171606516155512047663603130016501071257373376402305013340130367622760227271407353523022000701475236314772534000346752201356232615163574234002630675714211336714702060516663206015110067475047513142646330257055000277455200325061130657337316317554376162466055136155274054476145533163236466107467336747076613717223002745577657411627407725276747074567060763043646607724505664204427301661240615063577147445710213104031553504657301763373331262703553741317134271442306507670012276121100274304637243725253513214504246357470101416140032612206630415515123255662054100130013566517065461265407541006505531506707750631246524223542615004553564176641330356441502623631557520643635125022232750152112551576134720555414646530356414333546343723476573247167126166434111020045433364714613466022126163200737703664610034454501242354610660337744704732722736550631174224525627522620712231533253256744620435613663510675530565660636054015747727625204411141040701232260266324521361202704763406601210112636215103441353253031446312064451667417607145634430554561724211275363376756226272721514200415627737551614517560665643277776441366327407654272157735001157106744167475466657043537136066555562660774237250201512633010775404740262123501065250127473765550533045555740006355107070740045574766254354421774141716702051007035611103530567512220545040074203422355563562122577015565733135641377544727131474400533003316156434711750132507255503150625067041703333055757674071757660225173744650453543114705213253542074342640374204637310673460330374535070164174431727624324516252171644520355540417022403570353471127310176532661233043322177303137126101321532156631432760650705762422032636077130264643442716315175643750152013210665523346471047174003565736167173371504066137551633654255346563154367172465053317211533211545567276724767710047310503416674564751067127275053616001711644073225554250206115422671666204650143500277735400617472506327254661072236765413611213102743733715031404722155440022612574343350047603560515262276270437362305254516652017432742517671260073527064473216267173565511412605463176710343364471056641717311545145157037623411453260366064640633676714025772154736533152426253026771221625361631603466760444357706447144056565217225215450341432533136543670514756662324251711533713203013363740726411556072045307041021542331316160313436115016512506621713730672650273727213217135716064667326256170515764303344077024012231023100566264445374176356265152321170114463602432641517057661415512556046557411537512765577526554132654375524406675222306352325415150514321275503101277135423312150026713511432175572430001266173720271556443341134021562304331755716335451000227463526604422624033677623422124007637116336172346302205435713652021444620603066132311211054752010670235114733377751170700274114400654647567701714707160077141614437337570145366005401763532706420555772112544230356263715766037202021002643271675641424227607222405551224615156147513130716523306671341016352574273642202646071143443503662163165315200612501550461711373445675667361401725575065104535667412115722276340725623405060104117211372271057471721043201614773666744607020015421531071560203234776074501361400361036463660662172147607201462303020711563147517061631071433300531245210103132642112314104716321737773412725670634132565723076315625743207317065572360542674020662317753611274027557261442604770042022341653525077652026110217527243752317571526455306130443142353531513446665030046013635713616742556514345607516252623010131772346406366505126555326320212747764025322210676352724531633661116256736431565514640072033461166331506406605200032063427073710133213437677044347124443752127460654365072270512314644757023650423774066311014735413255226066763535651741611770210151171270060512554461207412630206256717660223510651517372532615134643170764260370235357774757573625415441043422752776341467403610127372203663757576775441443566432516175237464134072201251141230027735555324732012253710400025576773022016134705512211346056662746225563321404530402723321124045454312446263064450702057710703763043601001356234030540342630445420461773475524455605427050407265155516715556037444722011633634442275554137170577305721625614665603434474465320673700052405440701241565333651100636357214244313760164021241541233264624453147021032637237454505071025205217304415672345117273737325073356224235034334373637025551213237331243302674176164247005177532340650401543045310554471312127460651542701745223555723643105510077643071753755420141676317615775750550770033314550215361305523571016125357651712564130772652366126651176765517522004275757676565564326142350011376521354472337400530535214654230430750303412633206544517042411414222233312560342544143313617623656515625777303472342060410751325633262252342423762756136562576237067647104044637007332055516007564156702776157355477432746314101102032767722131574757066157527046375674164116442307204202123326203403404477544411377450443317347541563660021053764221624253735547447652131352660676541753355451656654434570473347144524244661112127760723132020556005470657210250376676565512043573473142306241742224140621226415551145214253714536030156055350051601423062607236571245027432451146455371744235007712343121447035023507726157776500115707370050512271211474506632657305457307260523306307532362255124760346246115457600531231617673671111660040056002157556064326634303602763564545135022074537704601333324577554306555741415152264210116206255411642213164671635574111431454655203255420570570401754561535777444447160634220256601514030111010332441145100046247102003124702146455151532550246173024117247675073664640561560112445705064766021103124575715030441672614451710520027746057147602150327130700214046032615516170043123270112330421604647642473251543656725677662542022146605214515035221063751253300443650701106165631531771353022417624147554746450337773647607170432421365324016552576457447427737200345443303241445120066000405343005750726204232120410154143514765050044127574147533527415004501305321565420562170763313272363544044437606410541246123666641377436413747557274733654517007643561431451250405211033245012010507167200326541235640037322213751413752601272665743755174400517223746457665436715256216307050360530074664660606322705153533411451246330225541722126316456424706732263061457553733554440234132542547166446724245016650501760170536035736617263400716451211050160635052747314207144515772265351243570574027165160747656022365422446632756473162201467075025315663654510224326246752677640375277376726607441043637300411767076626310777756161514275514523154111503662653302110533154356373043377156341613735747730412616062725553502526712132724723753753143366045741727237404756342727013443552157703435145333766605240573252050433447577505661740304645424306763646572305637227012332362467447410232022105305611045345353431027615702020672124020736646311231656357345746065245011606315437124322275207057021546436415132612607601003705252023306726704215672021007201664150171140164742342755651652566555063307255543051067027205070437614001524531003376645163563760643603025401640721110300154533004202433433427621513574040714611633457373001235350274541311655545706350536617772677664037136233560672147506360717265300303260474417416266443037501273073323766607203245661276055137716051622705400676534374735123563015156070416607020520017600176101514725260645242004153622442116205027174444425675466754123053633270332737527415407474220712276170432411705560512731425145361555326421567477464714443567164175714401756005415634032516254202746210262706345246366703264575400176467523315213467757653172244353441013646644504100744115672072605364346725552014561715306621162717262431700726071761311444216160650651310265560607231472567062602747264636370142025230671361254246023160126570417064746
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####

0 commit comments

Comments
 (0)