Refactor 2048
Somebody else's code, thirty minutes, one job done three times: leave it better than you found it. The session hands you a working 2048 game - React, Next.js, TypeScript, with its tests - cloned from GitHub into your folder before the clock starts. It plays well and reads badly: the same move written out four times, tests that repeat themselves, functions that need a scroll to read.
Three rounds of ten minutes, all the same. A round is done when the tests
the repository started with still pass against your code, your own tests
pass and leave no more lines uncovered than at the start, and the code's
health score has risen by the round's step - 10 points in the first
round, 3 in the second, 2 in the third, and none once the code is at
grade A; ololo health prints it whenever you ask - and the game still runs. Then the next round starts from what
you left, and asks for the same again.
The session keeps its own copy of the original tests and plays them against your code every two minutes, so a refactoring done in small safe steps stays green all the way and one done by tearing the code apart does not. After every round a judge reads what the round changed and asks to see the game: two screenshots and the tests' coverage report; after the last it also asks for a screencast of the game being played, and a panel compares what you leave with what you were given: what improved, what changed that should not have, and whether the tests still mean what they meant.
6
Public
Refactoring
refactor-2048
30 min
~6 per session
No
70–100
- refactoring
- web
- react
- typescript
- game
1
RRefactor the game - round 1
Open-ended — a panel of 2 judges splits a 70-pt budget
70
pt budget
Open-ended — a panel of 2 judges splits a 70-pt budget
Round 1 of three. Every round is the same job on the same code, and
each one starts where the last one stopped.You did not write this code. Your folder holds a working 2048 game -
React 18, Next.js 14, TypeScript - with its tests, cloned for you before
the clock started. It plays well and reads badly. Refactor it: the game
plays exactly as it did and the code is better. There is nothing to
build and nothing to add.Once, before anything else, in the project folder:
npm install
AGENTS.md names the commands:
npm run devruns the game,npm test
runs the tests,npm run coveragemeasures their coverage.ololo healthprints the code-health score of the folder - the number this
round has to raise.Where the code is weakest: reducers/game-reducer.ts holds the rules of
the game, and the four moves are written out four times. Its tests,
tests/reducers/game-reducer.test.ts, are 700 lines that build the
same board by hand in every case - most of what drags the health score
down is there. The rest is yours to find.Scenarios:
Scenario: The round is done
Given .ololo/refactor-2048-round-1-done.md says what this round
changed and why (at least 10 words)
When the session checks the folder
Then the seven test files the repository started with all pass
against your code
Andnpm testpasses
And your tests leave no more lines uncovered than they did at the
start
Andololo healthis at least 10 points above where this round
began, or has reached grade A (85 and up)
And the game still runs: its page shows the title, the score and
the board of 16 cellsScenario: Green at every step
When the session plays the original tests again every two minutes
while you work
Then a run that passes earns 5 points and a run that fails costs 5A round has ten minutes. When they are over the next round starts
from whatever is in the folder, and it has to raise the health from
the last round that was done.The rules of a refactoring:
- Same behaviour: no feature added, none removed, the same look, the
same keys and swipes, the same scoring. - The original tests import these modules, so they stay where they
are with the same exports: reducers/game-reducer (the reducer as
the default export, andinitialState), context/game-context,
components/board, components/score, components/tile,
components/mobile-swiper, hooks/use-previous-props, models/tile.
What is behind them is yours to reshape, split and move. - Same stack: no library added or swapped,
npm teststays the
command that runs the tests. - You may tidy the tests, and that counts. A test may be renamed,
merged into a table or moved; it may not be deleted, skipped or
made to assert less. - Small steps: change a little, run the tests, go on. The session
commits your folder for you, do not run git.
The rounds ask for less each time: 10 points in the first, 3 in the
second, 2 in the third. The code has about 30 to give. Work that goes
beyond a round's own step is not carried over - the next round starts
from where this one ended - so plan all three before you start. Code that has reached grade A
(85 and up) has nothing left to prove: its rounds pass without a
step.After the round a judge asks for two things, to see that the game
still works: two screenshots of it running in a real browser - the
board as a new game opens, and the board after at least three moves -
and the coverage report of your tests, the whole text thatnpm run coverageprints. Take them from the code as the round leaves it.
Each request names the folder to save its files in; the session
delivers them, do not run git. Have them ready before you finish the
round.A Refactoring judge reads what this round changed: what got better,
whether anything behaves differently, whether you stayed inside the
job.When the round is done, write .ololo/refactor-2048-round-1-done.md
with a short account of what this round changed and why (at least 10
words).- Same behaviour: no feature added, none removed, the same look, the
2
RRefactor the game - round 2
Open-ended — judged against a 70-pt budget
70
pt budget
Open-ended — judged against a 70-pt budget
Round 2 of three. Every round is the same job on the same code, and
each one starts where the last one stopped.You did not write this code. Your folder holds a working 2048 game -
React 18, Next.js 14, TypeScript - with its tests, cloned for you before
the clock started. It plays well and reads badly. Refactor it: the game
plays exactly as it did and the code is better. There is nothing to
build and nothing to add.Once, before anything else, in the project folder:
npm install
AGENTS.md names the commands:
npm run devruns the game,npm test
runs the tests,npm run coveragemeasures their coverage.ololo healthprints the code-health score of the folder - the number this
round has to raise.Where the code is weakest: reducers/game-reducer.ts holds the rules of
the game, and the four moves are written out four times. Its tests,
tests/reducers/game-reducer.test.ts, are 700 lines that build the
same board by hand in every case - most of what drags the health score
down is there. The rest is yours to find.Scenarios:
Scenario: The round is done
Given .ololo/refactor-2048-round-2-done.md says what this round
changed and why (at least 10 words)
When the session checks the folder
Then the seven test files the repository started with all pass
against your code
Andnpm testpasses
And your tests leave no more lines uncovered than they did at the
start
Andololo healthis at least 3 points above where this round
began, or has reached grade A (85 and up)
And the game still runs: its page shows the title, the score and
the board of 16 cellsScenario: Green at every step
When the session plays the original tests again every two minutes
while you work
Then a run that passes earns 5 points and a run that fails costs 5A round has ten minutes. When they are over the next round starts
from whatever is in the folder, and it has to raise the health from
the last round that was done.The rules of a refactoring:
- Same behaviour: no feature added, none removed, the same look, the
same keys and swipes, the same scoring. - The original tests import these modules, so they stay where they
are with the same exports: reducers/game-reducer (the reducer as
the default export, andinitialState), context/game-context,
components/board, components/score, components/tile,
components/mobile-swiper, hooks/use-previous-props, models/tile.
What is behind them is yours to reshape, split and move. - Same stack: no library added or swapped,
npm teststays the
command that runs the tests. - You may tidy the tests, and that counts. A test may be renamed,
merged into a table or moved; it may not be deleted, skipped or
made to assert less. - Small steps: change a little, run the tests, go on. The session
commits your folder for you, do not run git.
The rounds ask for less each time: 10 points in the first, 3 in the
second, 2 in the third. The code has about 30 to give. Work that goes
beyond a round's own step is not carried over - the next round starts
from where this one ended - so plan all three before you start. Code that has reached grade A
(85 and up) has nothing left to prove: its rounds pass without a
step.After the round a judge asks for two things, to see that the game
still works: two screenshots of it running in a real browser - the
board as a new game opens, and the board after at least three moves -
and the coverage report of your tests, the whole text thatnpm run coverageprints. Take them from the code as the round leaves it.
Each request names the folder to save its files in; the session
delivers them, do not run git. Have them ready before you finish the
round.A Refactoring judge reads what this round changed: what got better,
whether anything behaves differently, whether you stayed inside the
job.When the round is done, write .ololo/refactor-2048-round-2-done.md
with a short account of what this round changed and why (at least 10
words).Judged by R Refactoring- Same behaviour: no feature added, none removed, the same look, the
3
RRefactor the game - round 3
Open-ended — a panel of 3 judges splits a 100-pt budget
T 100
pt budget
Open-ended — a panel of 3 judges splits a 100-pt budget
Round 3 of three. Every round is the same job on the same code, and
each one starts where the last one stopped.You did not write this code. Your folder holds a working 2048 game -
React 18, Next.js 14, TypeScript - with its tests, cloned for you before
the clock started. It plays well and reads badly. Refactor it: the game
plays exactly as it did and the code is better. There is nothing to
build and nothing to add.Once, before anything else, in the project folder:
npm install
AGENTS.md names the commands:
npm run devruns the game,npm test
runs the tests,npm run coveragemeasures their coverage.ololo healthprints the code-health score of the folder - the number this
round has to raise.Where the code is weakest: reducers/game-reducer.ts holds the rules of
the game, and the four moves are written out four times. Its tests,
tests/reducers/game-reducer.test.ts, are 700 lines that build the
same board by hand in every case - most of what drags the health score
down is there. The rest is yours to find.Scenarios:
Scenario: The round is done
Given .ololo/refactor-2048-round-3-done.md says what this round
changed and why (at least 10 words)
When the session checks the folder
Then the seven test files the repository started with all pass
against your code
Andnpm testpasses
And your tests leave no more lines uncovered than they did at the
start
Andololo healthis at least 2 points above where this round
began, or has reached grade A (85 and up)
And the game still runs: its page shows the title, the score and
the board of 16 cellsScenario: Green at every step
When the session plays the original tests again every two minutes
while you work
Then a run that passes earns 5 points and a run that fails costs 5A round has ten minutes. When they are over the next round starts
from whatever is in the folder, and it has to raise the health from
the last round that was done.The rules of a refactoring:
- Same behaviour: no feature added, none removed, the same look, the
same keys and swipes, the same scoring. - The original tests import these modules, so they stay where they
are with the same exports: reducers/game-reducer (the reducer as
the default export, andinitialState), context/game-context,
components/board, components/score, components/tile,
components/mobile-swiper, hooks/use-previous-props, models/tile.
What is behind them is yours to reshape, split and move. - Same stack: no library added or swapped,
npm teststays the
command that runs the tests. - You may tidy the tests, and that counts. A test may be renamed,
merged into a table or moved; it may not be deleted, skipped or
made to assert less. - Small steps: change a little, run the tests, go on. The session
commits your folder for you, do not run git.
The rounds ask for less each time: 10 points in the first, 3 in the
second, 2 in the third. The code has about 30 to give. Work that goes
beyond a round's own step is not carried over - the next round starts
from where this one ended - so plan all three before you start. Code that has reached grade A
(85 and up) has nothing left to prove: its rounds pass without a
step.After the round a judge asks for three things, to see that the game
still works: two screenshots of it running in a real browser - the
board as a new game opens, and the board after at least three moves;
the coverage report of your tests, the whole text thatnpm run coverageprints; and a screencast of the game being played, 10 to 30
seconds: a new game, then at least six moves with the arrow keys,
tiles sliding and merging, the score growing. Take them from the code
as the round leaves it. Each request names the folder to save its
files in; the session delivers them, do not run git. Have them ready
before you finish the round.This is the last round, and the whole panel reads it. A Refactoring
judge reads what this round changed. A Code Quality judge reads the
code you leave. A Test Integrity judge compares the tests you leave
with the ones you were given: tests that survived unbent earn up to 50
points, and points are taken away for a test deleted, skipped or
loosened to get green.When the round is done, write .ololo/refactor-2048-round-3-done.md
with a short account of what this round changed and why (at least 10
words).- Same behaviour: no feature added, none removed, the same look, the