nvidia/nemotron-3.5-lightning:free run
OpenRouter · OpenCode 2.2.7 · every run of this model · uwu · 2026-11-13
Run nvidia/nemotron-3.5-lightning:free on your computer to see the two side by side.
A full run: 50 tasks, 82 points
- Tasks passed
- 34/50 12 not run
- Points
- 38/82Harder tasks count 3. How scores work
- Tokens
- 226,50112,018 read, 214,483 written.
- Speed
- 158 tok/sTokens a second, as the runner measured it. The site checks only that the machine could reach it. How speeds are checked
Not on the leaderboard: it ran through a hosted service, so it is not on a computer board. Leaderboard
- Summarizing 5/5
- Extracting 5/5
- Following instructions 4/5
- Reasoning 5/5
- Reading code 4/4
- Using tools 5/5
- Building pages 4/5
- Building games 2/4
- Building apps 0/4
- Writing code 0/3
- Fixing code 0/2
- Planning and data 0/3
Run details
Flag this run
Failed 4
Sort a listFailed
429 tokens: 51 read, 378 written · 4 s · 85 tok/s
Sort these words alphabetically, ignoring case. Output only the sorted words, on one line separated by commas: mango, Rice, melon, orange, lime.
lime,melon,mango,orange,rice
A pricing table with a toggleFailed
7,853 tokens: 222 read, 7,631 written · 52 s · 146 tok/s
Build a pricing page with three plans, in this order: Basic at $15 a month or $150 a year, Pro at $29 a month or $290 a year and Max at $43 a month or $430 a year. Each plan is an element with class "plan" containing an element with class "price". Show the monthly prices first, and write the words monthly and yearly as text in the markup, not as CSS content. Add a <button id="billing-toggle"> that switches every price between monthly and yearly billing when clicked. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pricing</title> <style> body { font-family: system-ui, sans-serif; max-width: 600px; margin: 2rem auto; padding: 0 1rem; } .plan { border: 1px solid #e0e0e0; border-radius: 8px; padding: 2rem 1.5rem; text-align: center; margin-bottom: 1.5rem; } .plan h2 { margin: 0 0 1rem; font-size: 1.2rem; color: #555; } .price { font-size: 3rem; margin: 1rem 0; } .price span { display: inline-block; margin-left: 1rem; vertical-align: middle; } .price .yearly { font-weight: normal; color: #bdc3c7; text-decoration: line-through; font-size: 1.5rem; } .price .monthly { font-weight: bold; color: #2c3e50; text-decoration: none; font-size: 3rem; } /* toggle state: yearly billing selected */ .billing-yearly .monthly { font-weight: normal; color: #bdc3c7; text-decoration: line-through; font-size: 1.5rem; } .billing-yearly .yearly { font-weight: bold; color: #2c3e50; text-decoration: none; font-size: 3rem; } button { padding: 0.6rem 1.2rem; font-size: 1rem; background: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background: #2980b9; } </style> </head> <body> <button id="billing-toggle">Toggle billing cycle</button> <div class="plan"> <h2>Basic</h2> <div class="price"> <span class="monthly">$15 monthly</span> <span class="yearly">$150 yearly</span> </div> </div> <div class="plan"> <h2>Pro</h2> <div class="price"> <span class="monthly">$29 monthly</span> <span class="yearly">$290 yearly</span> </div> </div> <div class="plan"> <h2>Max</h2> <div class="price"> <span class="monthly">$43 monthly</span> <span class="yearly">$430 yearly</span> </div> </div> <script> document.getElementById('billing-toggle').addEventListener('click', function() { document.querySelectorAll('.price').forEach(function(price) { price.classList.toggle('billing-yearly'); }); }); </script> </body> </html> ```Build SnakeFailed
25,901 tokens: 458 read, 25,443 written · 3 min 1 s · 141 tok/s
Build Snake as one web page on a 10 by 10 grid, playable with the arrow keys (one key press, one step), with the grid drawn on the page. In <script id="game">, define createGame() returning an object with step(dir) and state(). dir is "up", "down", "left" or "right". state() returns {snake, food, score, over}: snake is a list of [x, y] cells, head first; food is [x, y]; score is a number; over is a boolean. x is the column (0 to 9, left to right), y the row (0 to 9, top to bottom); up is y - 1. The rules, exactly: 1. The game starts with snake [[5, 5], [5, 6], [5, 7]], moving up, food at [4, 5], score 0. 2. step(dir): if dir is the opposite of the current direction it is ignored and the snake keeps going; otherwise dir becomes the current direction. The head moves one cell that way. 3. If the new head cell holds the food, the snake grows: its tail stays. Otherwise the tail cell is freed first. 4. If the new head is off the grid or on a cell of the snake (after rule 3), the game is over: over becomes true and nothing else changes. Once over, step does nothing. 5. Eating adds 1 to the score, and the next food goes to the first empty cell in reading order (row by row from the top, left to right) after the new head's cell, wrapping from [9, 9] to [0, 0]. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Snake Game</title> <style> body { margin: 0; background: #222; color: #fff; font-family: sans-serif; } #grid { display: grid; grid-template-columns: repeat(10, 20px); grid-template-rows: repeat(10, 20px); width: 209px; height: 209px; gap: 1px; background: #111; } .cell { background: #333; } .snake { background: #0f0; } .food { background: #f00; } </style> </head> <body> <div id="grid"></div> <script id="game"> function createGame() { let snake = [[5, 5], [5, 6], [5, 7]]; let currentDir = "up"; let food = [4, 5]; let score = 0; let over = false; const opposites = { up: "down", down: "up", left: "right", right: "left" }; const nextReadingCell = (cell) => { let [x, y] = cell; if (x < 9) return [x + 1, y]; else if (y < 9) return [0, y + 1]; else return [0, 0]; }; const findFoodPosition = (startCell, occupied) => { let current = startCell; for (let i = 0; i < 100; i++) { let occ = false; for (let j = 0; j < occupied.length; j++) { if (occupied[j][0] === current[0] && occupied[j][1] === current[1]) { occ = true; break; } } if (!occ) return current; current = nextReadingCell(current); } return startCell; }; const step = function(dir) { if (over) return; // determine new direction let newDir = currentDir; if (opposites[currentDir] !== dir) { newDir = dir; } currentDir = newDir; // compute new head let head = snake[0]; let newHead; if (currentDir === "up") newHead = [head[0], head[1] - 1]; else if (currentDir === "down") newHead = [head[0], head[1] + 1]; else if (currentDir === "left") newHead = [head[0] - 1, head[1]]; else if (currentDir === "right") newHead = [head[0] + 1, head[1]]; // check boundaries if (newHead[0] < 0 || newHead[0] > 9 || newHead[1] < 0 || newHead[1] > 9) { over = true; return; } // check if new head is food const ate = (newHead[0] === food[0] && newHead[1] === food[1]); let newSnake; let newScore = score; let newFood = food; if (ate) { newSnake = [newHead, ...snake]; newScore = score + 1; newFood = findFoodPosition(nextReadingCell(newHead), newSnake); } else { newSnake = [newHead, ...snake.slice(0, -1)]; newFood = food; } // check self collision after rule 3 let hitSelf = false; for (let i = 1; i < newSnake.length; i++) { if (newSnake[i][0] === newHead[0] && newSnake[i][1] === newHead[1]) { hitSelf = true; break; } } if (hitSelf) { over = true; return; } // apply changes snake = newSnake; score = newScore; food = newFood; }; return { step: step, state: function() { return { snake, food, score, over }; } }; } </script> <script> const grid = document.getElementById('grid'); // Build 10x10 grid of cells let html = ''; for (let y = 0; y < 10; y++) { for (let x = 0; x < 10; x++) { html += '<div class="cell" data-x="' + x + '" data-y="' + y + '"></div>'; } } grid.innerHTML = html; const game = createGame(); function render(state) { const cells = grid.querySelectorAll('.cell'); cells.forEach(cel => { cel.classList.remove('snake', 'food'); }); // Draw snake state.snake.forEach(([x, y]) => { const cel = grid.querySelector(`.cell[data-x="${x}"][data-y="${y}"]`); if (cel) cel.classList.add('snake'); }); // Draw food const foodCel = grid.querySelector(`.cell[data-x="${state.food[0]}"][data-y="${state.food[1]}"]`); if (foodCel) foodCel.classList.add('food'); } // Initial render render(game.state()); // Keyboard controls document.addEventListener('keydown', (e) => { let dir; if (e.key === 'ArrowUp') dir = 'up'; else if (e.key === 'ArrowDown') dir = 'down'; else if (e.key === 'ArrowLeft') dir = 'left'; else if (e.key === 'ArrowRight') dir = 'right'; else return; e.preventDefault(); game.step(dir); render(game.state()); }); </script> </body> </html>Box-pushing puzzleFailed
47,680 tokens: 1,122 read, 46,558 written · 4 min 0 s · 194 tok/s
Build a box-pushing puzzle as one web page on an 8 by 7 grid, playable with the arrow keys, with the level drawn on the page. Give the page and its heading the title Box-pushing puzzle. In <script id="game">, define createGame() returning an object with walk(dir) and state(). dir is "up", "down", "left" or "right". state() returns {player, boxes, pushes, steps, solved}: player is [x, y]; boxes is a list of [x, y] sorted by row, then column; pushes and steps are numbers; solved is a boolean. x is the column (0 to 7, left to right), y the row (0 to 6, top to bottom); up is y - 1. The level, row 0 first, 8 characters to a row (a space is empty floor; the outer ring is all wall): ``` ######## # #+ # # * # # # # *# $ # # ## # ######## ``` # wall, space floor, . goal, $ box, * box on a goal, @ player, + player on a goal. The rules, exactly: 1. The game starts with this level, steps 0, pushes 0 and solved false. Walls and goals never change. 2. walk(dir) moves the player one cell in dir. If that cell is a wall, nothing changes and nothing is counted. A goal is floor, so the player can stand on one. 3. If that cell holds a box, the box moves one cell further in dir and the player takes the box's old cell. This push happens only if the cell beyond the box is empty floor or a goal: not a wall and not another box. Otherwise nothing changes and nothing is counted. 4. A walk that moves the player adds 1 to steps. A push is a walk too, so it adds 1 to pushes as well. 5. solved is true when every box is on a goal. Once solved, walk does nothing. The page: the arrow keys do the same walks as walk(dir), one walk for each key press (a key that repeats while held walks once). Four buttons with data-dir="up", data-dir="down", data-dir="left" and data-dir="right" do the same walks. Label them Up, Down, Left and Right, laid out like the arrow keys: Up above Down, with Left, Down and Right in one row. A button with id="restart", labelled Restart, starts the level over, with steps and pushes back at 0. The board is an element with id="board". It holds one element per cell, 56 in all, row by row from the top, 8 to a row, and nothing else. Each cell has role="img" and an aria-label that names what it holds: wall, empty floor, empty goal, box, box on a goal, you or you on a goal. Every cell except empty floor also shows a visible character as its text, so that a wall, a goal, a box and you can each be seen (the character is yours to choose). Show the steps in an element with id="steps" and the pushes in one with id="pushes", each as a plain number. The status line is an element with id="status". Until the level is solved, it must not say that it is solved (a line such as Not solved yet is fine). Once it is, it says solved, with the number of steps next to the word steps and the number of pushes next to the word pushes, for example: Solved in 12 steps with 3 pushes. A tenth of a second after each key press, button press or Restart, the board, the steps, the pushes and the status line show what state() says. A page may draw on the next animation frame or after a timer. The page must not use eval or Function, must not give a timer a string of text (a timer takes a function), must not add a script element to the page, must not set an event attribute such as onclick from text, and must not make network requests or load anything from another site: no fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon or importScripts, and no image or file from another site. The whole page must be under 65,536 characters, and the script with id="game" under 20,000 characters. Light background; walls dark, goals ringed, boxes and the player easy to tell apart. Tell a box on a goal from one off a goal by a mark or shape, not by colour alone. The two scripts share one global scope, so give the page's copy of the map another name than the logic's (a const MAP in both stops the second script with an error), or wrap the page's script in a function. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Box-pushing puzzle</title> <style> body { background: #f5f5f5; font-family: sans-serif; margin: 0; } h1 { text-align: center; margin: 10px 0; } #board { display: flex; flex-wrap: wrap; width: 300px; margin: 0 auto; } .cell { width: 30px; height: 30px; border: 1px solid #ddd; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; } .wall { background: #2c3e50; color: #ecf0f1; } .goal { background: #e8f0f8; border: 2px solid #7f8c8d; } .box { color: #c0392b; } .player { color: #2980b9; } .empty { background: #fff; } </style> </head> <body> <h1>Box-pushing puzzle</h1> <div id="board"></div> <span id="steps">0</span> <span id="pushes">0</span> <div id="status">Not solved yet</div> <button data-dir="up">Up</button> <div style="display: flex; margin: 5px 0;"> <button data-dir="left">Left</button> <button data-dir="down">Down</button> <button data-dir="right">Right</button> </div> <button id="restart">Restart</button> <script id="game"> const MAP = `######## # #+ # # * # # # # *# $ # # ## # ########`.trim().split('\n'); function createGame() { const width = 8; const height = 7; const walls = new Set(); const goals = new Set(); let startPlayer = null; const boxes = []; for (let y = 0; y < height; y++) { const row = MAP[y]; for (let x = 0; x < width; x++) { const c = row.charAt(x); if (c === '#') { walls.add(x + ',' + y); } else if (c === '+' || c === '*') { goals.add(x + ',' + y); if (c === '+') startPlayer = [x, y]; if (c === '*') boxes.push([x, y]); } else if (c === '$') { boxes.push([x, y]); } } } let steps = 0; let pushes = 0; let solved = false; let player = startPlayer ? startPlayer : [0, 0]; const boxSet = new Set(boxes.map(b => b[0] + ',' + b[1])); function walk(dir) { if (solved) return; const dxMap = { up: 0, down: 0, left: -1, right: 1 }; const dyMap = { up: -1, down: 1, left: 0, right: 0 }; const dx = dxMap[dir]; const dy = dyMap[dir]; const nx = player[0] + dx; const ny = player[1] + dy; if (walls.has(nx + ',' + ny)) return; const boxKey = nx + ',' + ny; if (boxSet.has(boxKey)) { const bx = nx + dx; const by = ny + dy; const beyondKey = bx + ',' + by; if (walls.has(beyondKey)) return; if (boxSet.has(beyondKey)) return; boxSet.delete(boxKey); boxSet.add(beyondKey); player = [nx, ny]; steps++; pushes++; } else { player = [nx, ny]; steps++; } let allOnGoal = true; for (const b of boxSet) { if (!goals.has(b)) { allOnGoal = false; break; } } if (allOnGoal) solved = true; } function state() { const boxesSorted = Array.from(boxSet).map(k => { const p = k.split(',').map(Number); return [p[0], p[1]]; }); boxesSorted.sort((a, b) => a[1] - b[1] || a[0] - b[0]); return { player: player, boxes: boxesSorted, pushes: pushes, steps: steps, solved: solved }; } return { walk, state }; } </script> <script> (function() { const LEVEL = `######## # #+ # # * # # # # *# $ # # ## # ########`.trim().split('\n'); const width = 8; const height = 7; const walls = new Set(); const goals = new Set(); let startPlayer = null; const boxes = []; for (let y = 0; y < height; y++) { const row = LEVEL[y]; for (let x = 0; x < width; x++) { const c = row.charAt(x); if (c === '#') { walls.add(x + ',' + y); } else if (c === '+' || c === '*') { goals.add(x + ',' + y); if (c === '+') startPlayer = [x, y]; if (c === '*') boxes.push([x, y]); } else if (c === '$') { boxes.push([x, y]); } } } const board = document.getElementById('board'); for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { const cell = document.createElement('div'); cell.setAttribute('role', 'img'); const c = LEVEL[y].charAt(x); if (c === '#') { cell.setAttribute('aria-label', 'wall'); cell.textContent = '#'; cell.className = 'wall'; } else if (c === ' ') { cell.setAttribute('aria-label', 'empty floor'); cell.textContent = ''; cell.className = 'empty'; } else if (c === '+') { cell.setAttribute('aria-label', 'you on a goal'); cell.textContent = '+'; cell.className = 'player goal'; } else if (c === '*') { cell.setAttribute('aria-label', 'box on a goal'); cell.textContent = '*'; cell.className = 'goal box'; } else if (c === '$') { cell.setAttribute('aria-label', 'box'); cell.textContent = '$'; cell.className = 'box'; } board.appendChild(cell); } } let timeoutId = null; function updateUI() { const game = createGame(); const state = game.state(); document.getElementById('steps').textContent = state.steps; document.getElementById('pushes').textContent = state.pushes; const status = document.getElementById('status'); if (state.solved) { status.textContent = `Solved in ${state.steps} steps with ${state.pushes} pushes`; } else { status.textContent = 'Not solved yet'; } const cells = board.children; const boxSet = new Set(state.boxes.map(b => b[0] + ',' + b[1])); for (let i = 0; i < 56; i++) { const x = i % 8; const y = Math.floor(i / 8); const cell = cells[i]; if (walls.has(x + ',' + y)) { cell.setAttribute('aria-label', 'wall'); cell.textContent = '#'; cell.className = 'wall'; continue; } if (state.player[0] === x && state.player[1] === y) { if (goals.has(x + ',' + y)) { cell.setAttribute('aria-label', 'you on a goal'); cell.textContent = '+'; cell.className = 'player goal'; } else { cell.setAttribute('aria-label', 'you'); cell.textContent = '@'; cell.className = 'player'; } continue; } const boxKey = x + ',' + y; if (boxSet.has(boxKey)) { if (goals.has(boxKey)) { cell.setAttribute('aria-label', 'box on a goal'); cell.textContent = '*'; cell.className = 'goal box'; } else { cell.setAttribute('aria-label', 'box'); cell.textContent = '$'; cell.className = 'box'; } continue; } if (goals.has(boxKey)) { cell.setAttribute('aria-label', 'empty goal'); cell.textContent = '.'; cell.className = 'goal'; continue; } cell.setAttribute('aria-label', 'empty floor'); cell.textContent = ''; cell.className = 'empty'; } } function scheduleUpdate() { if (timeoutId) clearTimeout(timeoutId); timeoutId = setTimeout(updateUI, 100); } document.addEventListener('keydown', function(e) { if (e.key === 'ArrowUp') { document.querySelector('button[data-dir="up"]').click(); } else if (e.key === 'ArrowDown') { document.querySelector('button[data-dir="down"]').click(); } else if (e.key === 'ArrowLeft') { document.querySelector('button[data-dir="left"]').click(); } else if (e.key === 'ArrowRight') { document.querySelector('button[data-dir="right"]').click(); } }); document.querySelectorAll('button[data-dir]').forEach(btn => { btn.addEventListener('click', function() { const dir = this.getAttribute('data-dir'); const game = createGame(); game.walk(dir); scheduleUpdate(); }); }); document.getElementById('restart').addEventListener('click', function() { if (timeoutId) clearTimeout(timeoutId); updateUI(); timeoutId = setTimeout(updateUI, 100); }); timeoutId = setTimeout(updateUI, 100); })(); </script> </body> </html>
Reasons are shown for the fixed tasks. The varied tasks keep their checks private so answers cannot be fitted to them.
Think a grade is wrong? Say so in the chat.
What it built
Pages and games, as the model wrote them, each in a sandbox. Open one, then swipe or use the arrow keys.
-
Build 2048Keeps a game's rules across many moves.Passed · 33k tokens · 177 tok/s
-
Build SnakeRuns a game where a snake grows and the game ends on a crash.Failed · 26k tokens · 141 tok/s
-
Box-pushing puzzleShows whether a model can follow the push rules exactly across a whole level, counting steps and pushes as the rules say.Failed · 48k tokens · 194 tok/s
-
MinesweeperShows whether a model keeps the rules of a small game exact: where an empty area stops spreading, what a flag does to the count, and what a win or a loss reveals.Passed · 40k tokens · 163 tok/s
-
A small websiteLays out a small website with a menu and a footer.Passed · 3.8k tokens · 219 tok/s
-
A pricing table with a toggleSwitches every price between monthly and yearly with one button.Failed · 7.9k tokens · 146 tok/s
-
An accessible sign-up formChecks a sign-up form and labels each of its fields.Passed · 4.3k tokens · 136 tok/s
-
A to-do app that remembersKeeps data across a reload.Passed · 4.7k tokens · 137 tok/s
-
A bar chart in SVGDraws data to scale.Passed · 11k tokens · 133 tok/s
Scored tasks
Summarizing 5 of 5
One-sentence summaryPassed
6,552 tokens: 115 read, 6,437 written · 37 s · 175 tok/s
Summarize this in one sentence of at most 30 words. Starting May 11, the Wexford Vale Public Library will open at 7:20 a.m. instead of 10:05 a.m. on weekdays. The change follows a survey in which 87% of respondents asked for earlier hours. Weekend hours stay the same. The library will hire four part-time staff to cover the extra time, paid for by a county grant.
Starting May 11, Wexford Vale Public Library opens weekdays at 7:20 AM instead of 10:05 AM, weekends unchanged as 87% of respondents demanded earlier hours, with four grant-funded part-time staff.
Meeting notes in three bulletsPassed
1,385 tokens: 194 read, 1,191 written · 8 s · 151 tok/s
Summarize these meeting notes as exactly three bullet points, each at most 20 words. Keep only the decisions and ownership changes that matter. Output only the bullet points. Weekly sync, product team. Present: Amara, Ada, Cal, Mateo. - Cal reported that the payment provider fixed the cache bug; no action needed. - The launch date moves from February 20 to February 24 because the app store review is slow. - Mateo showed the new onboarding screens. Everyone liked them. Small copy changes only. - The marketing budget of $45,000 was approved by finance on Tuesday. - Amara will own end-to-end testing from now on; Ada hands over the test plan by Monday. - Next sync is moved to Wednesday at 14:30. - Coffee machine on floor 5 is broken again.
- Launch date moves from February 20 to February 24 due to slow app store review. - Marketing budget of $45,000 approved by finance. - Amara owns end-to-end testing; Ada hands over test plan by Monday.
Review sentiment and complaintPassed
974 tokens: 129 read, 845 written · 11 s · 80.4 tok/s
Read this product review and answer in exactly this format: Sentiment: <positive, negative or mixed> Complaint: <the main complaint in a few words> I've used this headset every day for a month. Honestly, the volume is loud enough for calls and it is light enough to forget I am wearing it. But the ear cushion that came in the box cracked after two weeks, and support took 8 days to reply. I bought a replacement ear cushion myself. Would I buy it again? Probably, but I'm annoyed.
Sentiment: mixed Complaint: ear cushion cracked
Faithful summary of a studyPassed
1,682 tokens: 137 read, 1,545 written · 7 s · 219 tok/s
Summarize this in at most 50 words. Keep the key numbers. Do not add anything the text does not say. In a randomized trial, 970 adults with chronic migraine took either Ardane or a placebo for 6 weeks. Those on Ardane had 3.4 fewer headache days per month on average, compared with 0.6 fewer days for placebo. Dry mouth was the most common side effect, reported by 17% of the drug group. The authors note the trial lasted only 6 weeks and call for longer studies before any recommendation is made.
A randomized trial with 970 chronic migraine patients found Ardane reduced headache days by 3.4 per month vs. 0.6 for placebo over 6 weeks. Dry mouth affected 17% of the Ardane group. Authors note the 6-week limit and urge longer studies before recommending Ardane.
Action items from an email threadPassed
4,833 tokens: 218 read, 4,615 written · 36 s · 130 tok/s
List every action item in this email thread that someone has committed to do, as lines of the form "- <owner>: <action>". Leave out offers that were declined and things that turned out not to be needed. Output only the list. From: Sam Hi all, quick recap of what's still open for the Lisbon workshop. I'll send the revised contract to the hotel by Sunday. From: Jules I can book the venue for the dinner if that helps? From: Felix Thanks Jules, but I'll book the venue myself since I already spoke to them. Also, no need to change the logo on the badges, it's fine as is. From: Sofia I'll update the budget sheet with the new hotel price tonight. From: Sam Great. Oh, and I'll email the caterer about the vegetarian options. Jules, could you just double-check the date on the invitations? Actually never mind, I checked them this morning, they're correct.
- Sam: send the revised contract to the hotel by Sunday - Felix: book the venue himself - Sofia: update the budget sheet with the new hotel price tonight - Sam: email the caterer about the vegetarian options
Extracting 5 of 5
Fields from an email as JSONPassed
652 tokens: 127 read, 525 written · 3 s · 176 tok/s
Extract these fields from the email as a JSON object with exactly these keys: "name" (the sender's full name), "company", "meeting_date" (YYYY-MM-DD) and "attendees" (a number). Output only the JSON. Hello! This is Yara Lindqvist from Ironbridge Tools. We'd love to visit your workshop. Could we meet on the 10th of July 2025, any time after lunch? We'll be two people in total, including me. Best, Yara
{ "name": "Yara Lindqvist", "company": "Ironbridge Tools", "meeting_date": "2025-07-10", "attendees": 2 }Every email address, oncePassed
1,168 tokens: 161 read, 1,007 written · 6 s · 164 tok/s
List every email address written out in full in this text (like name@example.com), one per line, in the order they first appear, without duplicates. Leave out any inbox the text says is closed. Output only the addresses. Contacts for the conference: write to hello@lakeside-talks.net for general questions, or to talks@lakeside-talks.net if you are presenting. Our designer (priya.p@studio-nine.io) made the poster. Billing questions: finance@lakeside-talks.net. Again, presenters use talks@lakeside-talks.net. Please don't write to ben at lakeside dot net, that inbox is closed.
hello@lakeside-talks.net talks@lakeside-talks.net priya.p@studio-nine.io finance@lakeside-talks.net
A list as CSVPassed
1,085 tokens: 109 read, 976 written · 6 s · 171 tok/s
Convert this shopping list to CSV with the header row item,qty,price. Write prices as plain numbers without a currency sign. Output only the CSV. Yogurt - 2 @ $4.85 Cheddar (200 g) - 17 @ $6.75 Apples - 24 @ $0.30 Rice (1 kg) - 19 @ $8.75
item,qty,price Yogurt,2,4.85 Cheddar (200 g),17,6.75 Apples,24,0.30 Rice (1 kg),19,8.75
The real deadlinePassed
407 tokens: 107 read, 300 written · 2 s · 181 tok/s
What is the final submission deadline? Answer with the date only, in YYYY-MM-DD format. The call for papers opened on 9 January 2025. Drafts were originally due August 20, but the committee extended the final submission deadline to 10 September 2025. Reviews are due by 18 September, and results will be announced on October 23, 2025.
2025-09-10
Warnings and errors from a logPassed
1,799 tokens: 285 read, 1,514 written · 16 s · 93 tok/s
From this log, return a JSON array with one object per WARN or ERROR line, in order, each with the keys "time" (HH:MM:SS), "level" and "message". Output only the JSON. 2025-03-23 09:23:15 INFO server started on port 3000 2025-03-23 09:23:48 WARN config key "timeout" is deprecated 2025-03-23 09:24:11 INFO user lena logged in 2025-03-23 09:25:55 ERROR database connection lost 2025-03-23 09:30:10 INFO retrying in 5s 2025-03-23 09:36:42 INFO database reconnected 2025-03-23 09:37:43 DEBUG cache hit ratio 0.90 2025-03-23 09:39:17 ERROR payment webhook returned 500
[ { "time": "09:23:48", "level": "WARN", "message": "config key \"timeout\" is deprecated" }, { "time": "09:25:55", "level": "ERROR", "message": "database connection lost" }, { "time": "09:39:17", "level": "ERROR", "message": "payment webhook returned 500" } ]
Following instructions 4 of 5
Exactly one wordPassed
188 tokens: 27 read, 161 written · 1 s · 121 tok/s
Reply with exactly the word Passed and nothing else.
Passed
Three lowercase linesPassed
1,139 tokens: 94 read, 1,045 written · 5 s · 204 tok/s
Write exactly three lines about a valley. Use the word valley in every line. Start every line with the letter s, and do not use any of these words: park, hospital, winter, school, island, crater, lighthouse, marsh, kitchen or stadium. Every line must be entirely lowercase, and the third line must end with a question mark. Output only the three lines.
silent valley winds whisper soft dawn sunlit valley shadows stretch silently silent valley seeks where sunrise goes?
Exact JSON shapePassed
501 tokens: 68 read, 433 written · 3 s · 172 tok/s
Return a JSON object with exactly two keys: "words", a list of exactly 2 different lowercase words that each start with the letter k and use only the plain letters a to z, and "count", the number 2. Output only the JSON.
{"words": ["kiwi", "kite"], "count": 2}Sort a listFailed
429 tokens: 51 read, 378 written · 4 s · 85 tok/s
Sort these words alphabetically, ignoring case. Output only the sorted words, on one line separated by commas: mango, Rice, melon, orange, lime.
lime,melon,mango,orange,rice
A name with three rulesPassed
9,008 tokens: 78 read, 8,930 written · 1 min 2 s · 144 tok/s
Suggest a product name for a solar-powered fridge. Rules: exactly two words, both capitalized, using only the plain letters A to Z, the first word starts with the letter R, the second word starts with the letter G, and the letter i must not appear anywhere. Output only the name.
Real Good
Reasoning 5 of 5
Unit pricePassed
1,079 tokens: 61 read, 1,018 written · 7 s · 141 tok/s
A shop sells pencils at 2 for $0.40. How much do 6 pencils cost, in dollars? Work it out, then end with a line "ANSWER: <number>".
Price for 2 pencils = $0.40 Price per pencil = $0.40 ÷ 2 = $0.20 Cost for 6 pencils = 6 × $0.20 = $1.20 (Equivalently, 6 pencils = 3 pairs, so 3 × $0.40 = $1.20) ANSWER: 1.20
Day and datePassed
2,041 tokens: 75 read, 1,966 written · 9 s · 208 tok/s
Today is Wednesday, 3 June 2026. What day of the week, and what date, is it 142 days from today? Work it out, then end with a line "ANSWER: <day of the week>, <YYYY-MM-DD>".
142 days from Wednesday, 3 June 2026: - June has 30 days, so from June 3 to June 30 = 27 days. - July = 31 days (cumulative 58) - August = 31 days (cumulative 89) - September = 30 days (cumulative 119) - Remaining days into October = 142 − 119 = 23 → October 23. - 142 mod 7 = 2, so 2 days after Wednesday = Friday. ANSWER: Friday, 2026-10-23
Who owns each petPassed
930 tokens: 175 read, 755 written · 4 s · 191 tok/s
Five people, Eli, Ana, Dee, Cal and Jon, each own exactly one of these pets: a cat, a dog, a fish, a bird and a rabbit. Each pet has one owner. Clues: - Dee owns the dog or the bird. - Eli does not own the bird. - Ana does not own the rabbit. - Cal owns the fish or the bird. - Eli owns the cat or the bird. - Ana owns the cat or the dog. Who owns each pet? Work it out, then end with a line "ANSWER: <owner of the cat>, <owner of the dog>, <owner of the fish>, <owner of the bird>, <owner of the rabbit>", with the five names in that order, separated by commas.
ANSWER: Eli, Ana, Cal, Dee, Jon
Arrival timePassed
700 tokens: 71 read, 629 written · 3 s · 198 tok/s
A train leaves at 13:15 and the trip takes 1 hour 55 minutes. At what time does it arrive? Work it out, then end with a line "ANSWER: <HH:MM>" in 24-hour time.
Departure time: 13:15 Add 1 hour → 14:15 Add 55 minutes → 15:10 ANSWER: 15:10
Filling a tankPassed
537 tokens: 98 read, 439 written · 2 s · 179 tok/s
A tank holds 780 liters and starts empty. Pipe A adds 14 liters an hour, pipe B adds 17 liters an hour, and a drain takes 11 liters an hour out of it. With all three open, how many hours until the tank is full? Work it out, then end with a line "ANSWER: <number>".
The tank fills at a net rate of 14 + 17 − 11 = 20 liters per hour. To fill 780 liters at 20 L/h takes 780 ÷ 20 = 39 hours. ANSWER: 39
Reading code 4 of 4
What does it printPassed
1,469 tokens: 94 read, 1,375 written · 7 s · 204 tok/s
What numbers does this Python program print, in order? Work it out, then end with a line "ANSWER: <numbers, separated by commas>". def f(xs): return sorted(xs)[::-1][:3] print(f([15, 44, 47, 31, 13, 14]))The function `f(xs)` performs three operations in sequence: 1. `sorted(xs)` sorts the input list in ascending order: `[13, 14, 15, 31, 44, 47]`. 2. `[::-1]` reverses that sorted list: `[47, 44, 31, 15, 14, 13]`. 3. `[:3]` takes the first three elements: `[47, 44, 31]`. When `print(f([15, 44, 47, 31, 13, 14]))` is executed, Python prints the list `[47, 44, 31]`. The numbers, in the order they are printed, are 47, 44, and 31. ANSWER: 47,44,31
Trace a loopPassed
1,963 tokens: 98 read, 1,865 written · 43 s · 43.8 tok/s
What does this Python program print? Work it out, then end with a line "ANSWER: <output>". def g(n): total = 0 for i in range(1, n + 1): if i % 4 == 0 or i % 3 == 0: total += i return total print(g(150))The function `g(n)` iterates through integers from 1 to `n` and sums those divisible by 3 or 4. To find `g(150)`, we can use the inclusion-exclusion principle: - **Multiples of 3** up to 150: there are 50 terms (3, 6, …, 150). Their sum is `3 × (50 × 51)/2 = 3825`. - **Multiples of 4** up to 150: there are 37 terms (4, 8, …, 148). Their sum is `4 × (37 × 38)/2 = 2812`. - **Multiples of 12** (divisible by both 3 and 4) up to 150: there are 12 terms (12, 24, …, 144). Their sum is `12 × (12 × 13)/2 = 936`. Applying inclusion-exclusion: `3825 + 2812 - 936 = 5701`. The program prints this value. ANSWER: 5701
Find the bugPassed
1,007 tokens: 121 read, 886 written · 4 s · 224 tok/s
The function count_even should return how many of the numbers in a list are even. The code below has one bug. Find the line with the bug, and write that line corrected, exactly as it should read in the code. Work it out, then end with a line "ANSWER: <corrected line>". def count_even(values): count = 0 for score in values: if score % 3 == 0: count += 1 return countThe bug is on the condition line: `if score % 3 == 0:` checks divisibility by 3, but the function `count_even` is supposed to count even numbers, which are divisible by 2. The correct check should use modulo 2. ANSWER: if score % 2 == 0:
Run a query in your headPassed
831 tokens: 148 read, 683 written · 3 s · 210 tok/s
What rows does this SQL query return? Output only the rows, one per line, as customer,total in the query's order. Table orders: id | customer | amount 1 | ana | 35 2 | ben | 95 3 | cal | 35 4 | ana | 55 5 | cal | 145 6 | ben | 50 Query: SELECT customer, SUM(amount) AS total FROM orders GROUP BY customer HAVING SUM(amount) > 100 ORDER BY total DESC;
cal,180 ben,145
Using tools 5 of 5
Call one toolPassed
830 tokens: 730 read, 100 written · 1 s · 76.9 tok/s
What's the weather in Denver right now, in celsius?
- user
What's the weather in Denver right now, in celsius?
- assistant
get_weather({"city":"Denver","unit":"celsius"}) - tool
{"city": "Denver", "conditions": "windy", "temperature": 6, "unit": "celsius"} - assistant
The current temperature in Denver is **6 °C** and it’s described as windy.
- user
Don't call a tool when none is neededPassed
632 tokens: 460 read, 172 written · 1 s · 199 tok/s
What is 22 times 13?
- user
What is 22 times 13?
- assistant
22 × 13 = 286
- user
Two calls for two answersPassed
1,638 tokens: 1,321 read, 317 written · 3 s · 119 tok/s
Convert 955 CHF to USD and to GBP.
- user
Convert 955 CHF to USD and to GBP.
- assistant
convert_currency({"amount":955,"from":"CHF","to":"USD"}) - tool
{"amount": 1099.27, "currency": "USD"} - assistant
convert_currency({"amount":955,"from":"CHF","to":"GBP"}) - tool
{"amount": 873.72, "currency": "GBP"} - assistant
Here are the conversions for **955 CHF**: | Currency | Converted Amount | |----------|------------------| | **USD** | **1,099.27 USD** | | **GBP** | **873.72 GBP** | These values are based on today’s exchange rates. If you need any other conversions or further details, just let me know!
- user
Chain two toolsPassed
1,506 tokens: 1,268 read, 238 written · 3 s · 82.3 tok/s
What is the status of each order for the customer with the email kim@example.com?
- user
What is the status of each order for the customer with the email kim@example.com?
- assistant
find_customer({"email":"kim@example.com"}) - tool
{"customer_id": "C-1042", "name": "Kim Park"} - assistant
get_orders({"customer_id":"C-1042"}) - tool
{"orders": [{"order_id": "A-79", "status": "cancelled"}, {"carrier": "DHL", "order_id": "A-87", "status": "shipped"}]} - assistant
Here are the orders for **Kim Park** (customer ID C‑1042) and their current status: | Order ID | Status | |----------|--------| | A‑79 | **cancelled** | | A‑87 | **shipped** (carrier: DHL) | So, order **A‑79** has been cancelled, while order **A‑87** has been shipped via DHL.
- user
Handle a failed call honestlyPassed
1,187 tokens: 824 read, 363 written · 3 s · 117 tok/s
Book a table for 2 people at Taverna Sol tonight at 18:45. If that time is not free, do not book another time without asking me first.
- user
Book a table for 2 people at Taverna Sol tonight at 18:45. If that time is not free, do not book another time without asking me first.
- assistant
book_table({"restaurant":"Taverna Sol","people":2,"time":"18:45"}) - tool
{"available_times": ["18:15", "20:15"], "error": "fully booked at that time"} - assistant
I tried to reserve a table for two at **Taverna Sol** for tonight at 18:45, but that slot is already fully booked. The system shows the following open times for tonight: - 18:15 - 20:15 Since you asked not to book another time without your permission, could you let me know which of these (or any other) time you’d like to reserve? If none work, just let me know and we can look for another date or restaurant.
- user
Building pages 4 of 5
A small websitePassed
3,814 tokens: 196 read, 3,618 written · 17 s · 219 tok/s
Build a one-page website for a bakery called "Ember & Co". It must have a <header> containing an <h1> with the bakery's name; a <nav> with exactly 3 links; a <main> with a <section id="menu"> listing at least 4 items in a list, including Pain au chocolat, Seeded roll, Almond cake and Croissant; and a <footer> with the opening hours. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Ember & Co</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, sans-serif; line-height: 1.6; background: #fafafa; color: #333; } header { background: #8b5a2b; color: #fff; padding: 1rem 0; text-align: center; } header h1 { margin: 0; font-size: 1.8rem; } nav { background: #6b4218; padding: 0.5rem; text-align: center; } nav ul { list-style: none; } nav ul li { display: inline-block; margin: 0 1rem; } nav ul li a { color: #fff; text-decoration: none; font-size: 1rem; } main { padding: 2rem; max-width: 800px; margin: 0 auto; } section#menu { background: #fff; padding: 1.5rem; border-radius: 4px; margin-top: 1rem; } section#menu h2 { margin-bottom: 0.8rem; color: #8b5a2b; } section#menu ul { list-style: none; padding: 0; } section#menu ul li { padding: 0.4rem 0; border-bottom: 1px solid #eee; } footer { background: #8b5a2b; color: #fff; text-align: center; padding: 1rem 0; margin-top: 2rem; font-size: 0.9rem; } </style> </head> <body> <header> <h1>Ember & Co</h1> </header> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">Menu</a></li> <li><a href="#">Contact</a></li> </ul> </nav> <main> <section id="menu"> <h2>Menu</h2> <ul> <li>Pain au chocolat</li> <li>Seeded roll</li> <li>Almond cake</li> <li>Croissant</li> <li>Fresh bread</li> </ul> </section> </main> <footer> <p>Opening hours: 7am - 3pm, Tuesday - Sunday</p> </footer> <script> // Inline JavaScript – harmless interaction document.querySelectorAll('a').forEach(link => { link.addEventListener('click', e => { e.preventDefault(); console.log('Link clicked: ' + link.textContent); }); }); </script> </body> </html> ```A pricing table with a toggleFailed
7,853 tokens: 222 read, 7,631 written · 52 s · 146 tok/s
Build a pricing page with three plans, in this order: Basic at $15 a month or $150 a year, Pro at $29 a month or $290 a year and Max at $43 a month or $430 a year. Each plan is an element with class "plan" containing an element with class "price". Show the monthly prices first, and write the words monthly and yearly as text in the markup, not as CSS content. Add a <button id="billing-toggle"> that switches every price between monthly and yearly billing when clicked. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pricing</title> <style> body { font-family: system-ui, sans-serif; max-width: 600px; margin: 2rem auto; padding: 0 1rem; } .plan { border: 1px solid #e0e0e0; border-radius: 8px; padding: 2rem 1.5rem; text-align: center; margin-bottom: 1.5rem; } .plan h2 { margin: 0 0 1rem; font-size: 1.2rem; color: #555; } .price { font-size: 3rem; margin: 1rem 0; } .price span { display: inline-block; margin-left: 1rem; vertical-align: middle; } .price .yearly { font-weight: normal; color: #bdc3c7; text-decoration: line-through; font-size: 1.5rem; } .price .monthly { font-weight: bold; color: #2c3e50; text-decoration: none; font-size: 3rem; } /* toggle state: yearly billing selected */ .billing-yearly .monthly { font-weight: normal; color: #bdc3c7; text-decoration: line-through; font-size: 1.5rem; } .billing-yearly .yearly { font-weight: bold; color: #2c3e50; text-decoration: none; font-size: 3rem; } button { padding: 0.6rem 1.2rem; font-size: 1rem; background: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background: #2980b9; } </style> </head> <body> <button id="billing-toggle">Toggle billing cycle</button> <div class="plan"> <h2>Basic</h2> <div class="price"> <span class="monthly">$15 monthly</span> <span class="yearly">$150 yearly</span> </div> </div> <div class="plan"> <h2>Pro</h2> <div class="price"> <span class="monthly">$29 monthly</span> <span class="yearly">$290 yearly</span> </div> </div> <div class="plan"> <h2>Max</h2> <div class="price"> <span class="monthly">$43 monthly</span> <span class="yearly">$430 yearly</span> </div> </div> <script> document.getElementById('billing-toggle').addEventListener('click', function() { document.querySelectorAll('.price').forEach(function(price) { price.classList.toggle('billing-yearly'); }); }); </script> </body> </html> ```An accessible sign-up formPassed
4,303 tokens: 256 read, 4,047 written · 30 s · 136 tok/s
Build a sign-up form for Copper Notes. Put the brand name in a heading above the form. The form is <form id="signup"> with inputs id="name", id="email" (type email) and id="password" (type password, minlength at least 8), each with a <label for>, and a submit button. Give the form a novalidate attribute, and check the fields yourself when it is submitted. If the email is not a valid address, or the password is shorter than 8 characters, do not send the form; show a message in an element with id="status" and role="status" that says what is wrong. If the form is valid, prevent the real submission and leave the status element empty. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Copper Notes Sign Up</title> <style> body { font-family: system-ui, sans-serif; max-width: 420px; margin: 2rem auto; padding: 0 1rem; } h1 { text-align: center; font-weight: 600; letter-spacing: 1px; margin-bottom: 1.5rem; } form { background: #fafafa; border: 1px solid #e0e0e0; border-radius: 12; padding: 2rem 1.5rem; } label { display: block; margin-top: 1.2rem; font-weight: 600; color: 333; } input { width: 100%; padding: 0.6rem 0.8rem; margin-top: 0.4rem; box-sizing: border-box; border: 1px solid #ccc; border-radius: 8; font-size: 1rem; } button { width: 100%; margin-top: 1.5rem; padding: 0.7rem; background: #007A7A; color: white; border: none; border-radius: 8; font-size: 1rem; font-weight: 600; cursor: pointer; } #status { margin-top: 1rem; font-size: 0.85rem; } </style> </head> <body> <h1>Copper Notes</h1> <form id="signup" novalidate> <label for="name">Name</label> <input type="text" id="name" name="name" required> <label for="email">Email</label> <input type="email" id="email" name="email" required> <label for="password">Password</label> <input type="password" id="password" name="password" minlength="8" required> <button type="submit">Sign Up</button> </form> <div id="status" role="status"></div> <script> document.getElementById('signup').addEventListener('submit', function(e) { e.preventDefault(); const email = document.getElementById('email').value.trim(); const password = document.getElementById('password').value.trim(); const status = document.getElementById('status'); const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const emailValid = emailRegex.test(email); const passwordValid = password.length >= 8; if (!emailValid || !passwordValid) { if (!emailValid && !passwordValid) { status.textContent = 'Please enter a valid email address and a password at least 8 characters long.'; } else if (!emailValid) { status.textContent = 'Please enter a valid email address.'; } else { status.textContent = 'Password must be at least 8 characters long.'; } } else { status.textContent = ''; // Form would submit here; we prevent real submission as instructed } }); </script> </body> </html>A to-do app that remembersPassed
4,665 tokens: 186 read, 4,479 written · 33 s · 137 tok/s
Build a to-do list app called "Camp plan". Show its name in a heading. The app has an <input id="new-task">, a <button id="add"> and a <ul id="tasks">. Clicking add appends the text as an <li> with its own remove button. Save the list in localStorage under the key "todos" and load it again when the page opens. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Camp plan</title> <style> body { font-family: sans-serif; margin: 2rem; } h1 { color: #333; margin-bottom: 1rem; } .task-list { list-style: none; padding: 0; margin: 0; } .task-list li { margin: 0.5rem 0; padding: 0.5rem; background: #f0f0f0; } .task-list button { margin-left: 0.5rem; padding: 0.3rem 0.5rem; } input { padding: 0.5rem; width: 250px; } button { padding: 0.5rem 1rem; cursor: pointer; } </style> </head> <body> <h1>Camp plan</h1> <input id="new-task" type="text" placeholder="Add a task"> <button id="add">Add</button> <ul id="tasks"></ul> <script> document.addEventListener('DOMContentLoaded', () => { const tasksList = document.getElementById('tasks'); const newTaskInput = document.getElementById('new-task'); const addBtn = document.getElementById('add'); let tasks = JSON.parse(localStorage.getItem('todos')) || []; function renderTasks() { tasksList.innerHTML = ''; tasks.forEach((text, index) => { const li = document.createElement('li'); const textNode = document.createTextNode(text); li.appendChild(textNode); const removeBtn = document.createElement('button'); removeBtn.textContent = 'Remove'; removeBtn.dataset.index = index; li.appendChild(removeBtn); tasksList.appendChild(li); }); } function saveTasks() { localStorage.setItem('todos', JSON.stringify(tasks)); } addBtn.addEventListener('click', () => { const text = newTaskInput.value.trim(); if (!text) return; tasks.push(text); renderTasks(); saveTasks(); newTaskInput.value = ''; }); tasksList.addEventListener('click', (e) => { if (e.target.tagName === 'BUTTON' && e.target.dataset.index !== undefined) { const index = parseInt(e.target.dataset.index); tasks.splice(index, 1); renderTasks(); saveTasks(); } }); renderTasks(); }); </script> </body> </html> ```A bar chart in SVGPassed
11,487 tokens: 239 read, 11,248 written · 1 min 25 s · 133 tok/s
Draw an inline SVG bar chart of scones sold, in this order: Wed 42, Thu 18, Fri 4, Sat 33 and Sun 11. Give the <svg> a width and a height, and a <title> or an aria-label. Each bar is a <rect class="bar"> whose height attribute is proportional to its value, and every bar is inside the <svg>. Each bar is labelled with its day or month in a <text> element under the bar. Write the bars and labels directly in the SVG markup, not with JavaScript. Do not move, resize or hide them with a transform or with CSS. Output one complete HTML document and nothing else. Put all CSS and JavaScript inline. Do not load anything from another site: no external scripts, stylesheets, fonts or images. Do not link to a file by a relative path either: no src, href or url() that names a file next to the page. Do not hide anything with CSS: no display: none, visibility: hidden or opacity: 0.
Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Scones Sold Bar Chart</title> </head> <body> <svg width="400" height="500" aria-label="Scones sold by day of week: Wed 42, Thu 18, Fri 4, Sat 33, Sun 11"> <rect class="bar" x="20" y="0" width="60" height="420" fill="#4a90e2" /> <text x="50" y="435" fill="black" font-family="sans-serif" font-size="14" text-anchor="middle">Wed</text> <rect class="bar" x="100" y="0" width="60" height="180" fill="#4a90e2" /> <text x="130" y="195" fill="black" font-family="sans-serif" font-size="14" text-anchor="middle">Thu</text> <rect class="bar" x="180" y="0" width="60" height="40" fill="#4a90e2" /> <text x="210" y="55" fill="black" font-family="sans-serif" font-size="14" text-anchor="middle">Fri</text> <rect class="bar" x="260" y="0" width="60" height="330" fill="#4a90e2" /> <text x="290" y="345" fill="black" font-family="sans-serif" font-size="14" text-anchor="middle">Sat</text> <rect class="bar" x="340" y="0" width="60" height="110" fill="#4a90e2" /> <text x="370" y="125" fill="black" font-family="sans-serif" font-size="14" text-anchor="middle">Sun</text> </svg> </body> </html> ```
Building games 2 of 4
Build 2048Passed
32,612 tokens: 454 read, 32,158 written · 3 min 1 s · 177 tok/s
Build the game 2048 as one web page, playable with the arrow keys, with the board drawn on the page. In <script id="game">, define createGame() returning an object with move(dir) and state(). dir is "up", "down", "left" or "right". state() returns {board, score, over}: board is 4 rows of 4 numbers, top row first (0 is an empty cell), score is a number, over is a boolean. The rules, exactly: 1. The board starts as this one, then a 2 is put in each of the first two empty cells in reading order (row by row from the top, left to right). The score starts at 0. [8, 0, 0, 2] [0, 0, 8, 0] [0, 4, 2, 0] [0, 0, 0, 0] 2. A move slides every tile as far as it goes toward dir. Two tiles of the same value that meet merge into one tile of their sum, nearest the side they move toward first: moving left, [2,2,2,2] becomes [4,4,0,0] and [2,2,2,0] becomes [4,2,0,0]. A tile made by a merge does not merge again in the same move. 3. Each merge adds the new tile's value to the score. 4. If a move changed the board, a 2 is put in the first empty cell in reading order. A move that changes nothing does nothing. 5. over is true when no move would change the board; then moves do nothing. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>2048</title> <style> body { font-family: Arial, sans-serif; text-align: center; margin-top: 20px; background: #bbada0; color: #f9f6f2; } #board { width: 420px; margin: 0 auto; } .tile { width: 100px; height: 100px; border: 2px solid #776e65; float: left; margin: 2px; text-align: center; line-height: 100px; font-size: 36px; color: #f9f6f2; background-color: #cdc1b4; } #score { margin-top: 10px; font-size: 20px; } .game-over { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); color: white; font-size: 40px; display: flex; align-items: center; justify-content: center; display: none; } </style> </head> <body> <div id="board"></div> <div id="score">Score: 0</div> <div class="game-over" id="game-over">Game Over</div> <script id="game"> function createGame() { let board = [ [8, 0, 0, 2], [0, 0, 8, 0], [0, 4, 2, 0], [0, 0, 0, 0] ]; let score = 0; // place first two 2s in reading order let empties = []; for (let r = 0; r < 4; r++) { for (let c = 0; c < 4; c++) { if (board[r][c] === 0) { empties.push({r, c}); if (empties.length === 2) break; } } if (empties.length === 2) break; } empties.forEach(p => board[p.r][p.c] = 2); function mergeRowLeft(row) { let arr = row.slice(); let scoreInc = 0; let w = 0; for (let r = 0; r < 4; r++) if (arr[r] !== 0) arr[w++] = arr[r]; for (; w < 4; w++) arr[w] = 0; for (let i = 0; i < 3; i++) { if (arr[i] !== 0 && arr[i] === arr[i+1]) { arr[i] *= 2; arr[i+1] = 0; scoreInc += arr[i]; } } w = 0; for (let r = 0; r < 4; r++) if (arr[r] !== 0) arr[w++] = arr[r]; for (; w < 4; w++) arr[w] = 0; return [arr, scoreInc]; } function mergeRowRight(row) { let rev = row.slice().reverse(); let [arr, s] = mergeRowLeft(rev); return [arr.reverse(), s]; } function simulateMove(dir) { let curBoard = board.map(r => r.slice()); let newBoard = curBoard.map(r => r.slice()); let newScore = score; if (dir === 'left') { for (let r = 0; r < 4; r++) { let [nr, s] = mergeRowLeft(newBoard[r]); newBoard[r] = nr; newScore += s; } } else if (dir === 'right') { for (let r = 0; r < 4; r++) { let [nr, s] = mergeRowRight(newBoard[r]); newBoard[r] = nr; newScore += s; } } else if (dir === 'up') { for (let c = 0; c < 4; c++) { let col = [curBoard[0][c], curBoard[1][c], curBoard[2][c], curBoard[3][c]]; let [nc, s] = mergeRowLeft(col); newBoard[0][c] = nc[0]; newBoard[1][c] = nc[1]; newBoard[2][c] = nc[2]; newBoard[3][c] = nc[3]; newScore += s; } } else if (dir === 'down') { for (let c = 0; c < 4; c++) { let col = [curBoard[0][c], curBoard[1][c], curBoard[2][c], curBoard[3][c]]; let [nc, s] = mergeRowRight(col); newBoard[0][c] = nc[0]; newBoard[1][c] = nc[1]; newBoard[2][c] = nc[2]; newBoard[3][c] = nc[3]; newScore += s; } } let changed = false; for (let r = 0; r < 4 && !changed; r++) { for (let c = 0; c < 4; c++) { if (newBoard[r][c] !== curBoard[r][c]) { changed = true; break; } } } return { newBoard, newScore, changed }; } function move(dir) { let res = simulateMove(dir); if (!res.changed) return; board = res.newBoard; score = res.newScore; let firstEmpty = null; for (let r = 0; r < 4; r++) { for (let c = 0; c < 4; c++) { if (board[r][c] === 0) { firstEmpty = {r, c}; break; } } if (firstEmpty) break; } if (firstEmpty) { board[firstEmpty.r][firstEmpty.c] = 2; } } function state() { let anyChange = false; for (let dir of ['up', 'down', 'left', 'right']) { let res = simulateMove(dir); if (res.changed) { anyChange = true; break; } } let over = !anyChange; return { board, score, over }; } return { move, state }; } </script> <script> const game = createGame(); const boardEl = document.getElementById('board'); const scoreEl = document.getElementById('score'); const gameOverEl = document.getElementById('game-over'); function render() { const state = game.state(); boardEl.innerHTML = ''; state.board.forEach((row, r) => { row.forEach((val, c) => { const tile = document.createElement('div'); tile.className = 'tile'; tile.textContent = val > 0 ? String(val) : ''; if (val > 0) { switch(val) { case 2: tile.style.backgroundColor = '#eee4da'; break; case 4: tile.style.backgroundColor = '#ede0c8'; break; case 8: tile.style.backgroundColor = '#f2b179'; break; case 16: tile.style.backgroundColor = '#f59563'; break; case 32: tile.style.backgroundColor = '#f67c5f'; break; case 64: tile.style.backgroundColor = '#f65e3b'; break; case 128: tile.style.backgroundColor = '#edcf72'; break; case 256: tile.style.backgroundColor = '#edcc61'; break; case 512: tile.style.backgroundColor = '#edc850'; break; case 1024: tile.style.backgroundColor = '#edc53f'; break; case 2048: tile.style.backgroundColor = '#edc22e'; break; } } boardEl.appendChild(tile); }); }); scoreEl.textContent = 'Score: ' + state.score; if (state.over) { gameOverEl.style.display = 'flex'; } else { gameOverEl.style.display = 'none'; } } render(); document.addEventListener('keydown', e => { let dir; if (e.key === 'ArrowUp') dir = 'up'; else if (e.key === 'ArrowDown') dir = 'down'; else if (e.key === 'ArrowLeft') dir = 'left'; else if (e.key === 'ArrowRight') dir = 'right'; else return; game.move(dir); render(); }); </script> </body> </html>Build SnakeFailed
25,901 tokens: 458 read, 25,443 written · 3 min 1 s · 141 tok/s
Build Snake as one web page on a 10 by 10 grid, playable with the arrow keys (one key press, one step), with the grid drawn on the page. In <script id="game">, define createGame() returning an object with step(dir) and state(). dir is "up", "down", "left" or "right". state() returns {snake, food, score, over}: snake is a list of [x, y] cells, head first; food is [x, y]; score is a number; over is a boolean. x is the column (0 to 9, left to right), y the row (0 to 9, top to bottom); up is y - 1. The rules, exactly: 1. The game starts with snake [[5, 5], [5, 6], [5, 7]], moving up, food at [4, 5], score 0. 2. step(dir): if dir is the opposite of the current direction it is ignored and the snake keeps going; otherwise dir becomes the current direction. The head moves one cell that way. 3. If the new head cell holds the food, the snake grows: its tail stays. Otherwise the tail cell is freed first. 4. If the new head is off the grid or on a cell of the snake (after rule 3), the game is over: over becomes true and nothing else changes. Once over, step does nothing. 5. Eating adds 1 to the score, and the next food goes to the first empty cell in reading order (row by row from the top, left to right) after the new head's cell, wrapping from [9, 9] to [0, 0]. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Snake Game</title> <style> body { margin: 0; background: #222; color: #fff; font-family: sans-serif; } #grid { display: grid; grid-template-columns: repeat(10, 20px); grid-template-rows: repeat(10, 20px); width: 209px; height: 209px; gap: 1px; background: #111; } .cell { background: #333; } .snake { background: #0f0; } .food { background: #f00; } </style> </head> <body> <div id="grid"></div> <script id="game"> function createGame() { let snake = [[5, 5], [5, 6], [5, 7]]; let currentDir = "up"; let food = [4, 5]; let score = 0; let over = false; const opposites = { up: "down", down: "up", left: "right", right: "left" }; const nextReadingCell = (cell) => { let [x, y] = cell; if (x < 9) return [x + 1, y]; else if (y < 9) return [0, y + 1]; else return [0, 0]; }; const findFoodPosition = (startCell, occupied) => { let current = startCell; for (let i = 0; i < 100; i++) { let occ = false; for (let j = 0; j < occupied.length; j++) { if (occupied[j][0] === current[0] && occupied[j][1] === current[1]) { occ = true; break; } } if (!occ) return current; current = nextReadingCell(current); } return startCell; }; const step = function(dir) { if (over) return; // determine new direction let newDir = currentDir; if (opposites[currentDir] !== dir) { newDir = dir; } currentDir = newDir; // compute new head let head = snake[0]; let newHead; if (currentDir === "up") newHead = [head[0], head[1] - 1]; else if (currentDir === "down") newHead = [head[0], head[1] + 1]; else if (currentDir === "left") newHead = [head[0] - 1, head[1]]; else if (currentDir === "right") newHead = [head[0] + 1, head[1]]; // check boundaries if (newHead[0] < 0 || newHead[0] > 9 || newHead[1] < 0 || newHead[1] > 9) { over = true; return; } // check if new head is food const ate = (newHead[0] === food[0] && newHead[1] === food[1]); let newSnake; let newScore = score; let newFood = food; if (ate) { newSnake = [newHead, ...snake]; newScore = score + 1; newFood = findFoodPosition(nextReadingCell(newHead), newSnake); } else { newSnake = [newHead, ...snake.slice(0, -1)]; newFood = food; } // check self collision after rule 3 let hitSelf = false; for (let i = 1; i < newSnake.length; i++) { if (newSnake[i][0] === newHead[0] && newSnake[i][1] === newHead[1]) { hitSelf = true; break; } } if (hitSelf) { over = true; return; } // apply changes snake = newSnake; score = newScore; food = newFood; }; return { step: step, state: function() { return { snake, food, score, over }; } }; } </script> <script> const grid = document.getElementById('grid'); // Build 10x10 grid of cells let html = ''; for (let y = 0; y < 10; y++) { for (let x = 0; x < 10; x++) { html += '<div class="cell" data-x="' + x + '" data-y="' + y + '"></div>'; } } grid.innerHTML = html; const game = createGame(); function render(state) { const cells = grid.querySelectorAll('.cell'); cells.forEach(cel => { cel.classList.remove('snake', 'food'); }); // Draw snake state.snake.forEach(([x, y]) => { const cel = grid.querySelector(`.cell[data-x="${x}"][data-y="${y}"]`); if (cel) cel.classList.add('snake'); }); // Draw food const foodCel = grid.querySelector(`.cell[data-x="${state.food[0]}"][data-y="${state.food[1]}"]`); if (foodCel) foodCel.classList.add('food'); } // Initial render render(game.state()); // Keyboard controls document.addEventListener('keydown', (e) => { let dir; if (e.key === 'ArrowUp') dir = 'up'; else if (e.key === 'ArrowDown') dir = 'down'; else if (e.key === 'ArrowLeft') dir = 'left'; else if (e.key === 'ArrowRight') dir = 'right'; else return; e.preventDefault(); game.step(dir); render(game.state()); }); </script> </body> </html>Box-pushing puzzleFailed
47,680 tokens: 1,122 read, 46,558 written · 4 min 0 s · 194 tok/s
Build a box-pushing puzzle as one web page on an 8 by 7 grid, playable with the arrow keys, with the level drawn on the page. Give the page and its heading the title Box-pushing puzzle. In <script id="game">, define createGame() returning an object with walk(dir) and state(). dir is "up", "down", "left" or "right". state() returns {player, boxes, pushes, steps, solved}: player is [x, y]; boxes is a list of [x, y] sorted by row, then column; pushes and steps are numbers; solved is a boolean. x is the column (0 to 7, left to right), y the row (0 to 6, top to bottom); up is y - 1. The level, row 0 first, 8 characters to a row (a space is empty floor; the outer ring is all wall): ``` ######## # #+ # # * # # # # *# $ # # ## # ######## ``` # wall, space floor, . goal, $ box, * box on a goal, @ player, + player on a goal. The rules, exactly: 1. The game starts with this level, steps 0, pushes 0 and solved false. Walls and goals never change. 2. walk(dir) moves the player one cell in dir. If that cell is a wall, nothing changes and nothing is counted. A goal is floor, so the player can stand on one. 3. If that cell holds a box, the box moves one cell further in dir and the player takes the box's old cell. This push happens only if the cell beyond the box is empty floor or a goal: not a wall and not another box. Otherwise nothing changes and nothing is counted. 4. A walk that moves the player adds 1 to steps. A push is a walk too, so it adds 1 to pushes as well. 5. solved is true when every box is on a goal. Once solved, walk does nothing. The page: the arrow keys do the same walks as walk(dir), one walk for each key press (a key that repeats while held walks once). Four buttons with data-dir="up", data-dir="down", data-dir="left" and data-dir="right" do the same walks. Label them Up, Down, Left and Right, laid out like the arrow keys: Up above Down, with Left, Down and Right in one row. A button with id="restart", labelled Restart, starts the level over, with steps and pushes back at 0. The board is an element with id="board". It holds one element per cell, 56 in all, row by row from the top, 8 to a row, and nothing else. Each cell has role="img" and an aria-label that names what it holds: wall, empty floor, empty goal, box, box on a goal, you or you on a goal. Every cell except empty floor also shows a visible character as its text, so that a wall, a goal, a box and you can each be seen (the character is yours to choose). Show the steps in an element with id="steps" and the pushes in one with id="pushes", each as a plain number. The status line is an element with id="status". Until the level is solved, it must not say that it is solved (a line such as Not solved yet is fine). Once it is, it says solved, with the number of steps next to the word steps and the number of pushes next to the word pushes, for example: Solved in 12 steps with 3 pushes. A tenth of a second after each key press, button press or Restart, the board, the steps, the pushes and the status line show what state() says. A page may draw on the next animation frame or after a timer. The page must not use eval or Function, must not give a timer a string of text (a timer takes a function), must not add a script element to the page, must not set an event attribute such as onclick from text, and must not make network requests or load anything from another site: no fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon or importScripts, and no image or file from another site. The whole page must be under 65,536 characters, and the script with id="game" under 20,000 characters. Light background; walls dark, goals ringed, boxes and the player easy to tell apart. Tell a box on a goal from one off a goal by a mark or shape, not by colour alone. The two scripts share one global scope, so give the page's copy of the map another name than the logic's (a const MAP in both stops the second script with an error), or wrap the page's script in a function. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Box-pushing puzzle</title> <style> body { background: #f5f5f5; font-family: sans-serif; margin: 0; } h1 { text-align: center; margin: 10px 0; } #board { display: flex; flex-wrap: wrap; width: 300px; margin: 0 auto; } .cell { width: 30px; height: 30px; border: 1px solid #ddd; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; } .wall { background: #2c3e50; color: #ecf0f1; } .goal { background: #e8f0f8; border: 2px solid #7f8c8d; } .box { color: #c0392b; } .player { color: #2980b9; } .empty { background: #fff; } </style> </head> <body> <h1>Box-pushing puzzle</h1> <div id="board"></div> <span id="steps">0</span> <span id="pushes">0</span> <div id="status">Not solved yet</div> <button data-dir="up">Up</button> <div style="display: flex; margin: 5px 0;"> <button data-dir="left">Left</button> <button data-dir="down">Down</button> <button data-dir="right">Right</button> </div> <button id="restart">Restart</button> <script id="game"> const MAP = `######## # #+ # # * # # # # *# $ # # ## # ########`.trim().split('\n'); function createGame() { const width = 8; const height = 7; const walls = new Set(); const goals = new Set(); let startPlayer = null; const boxes = []; for (let y = 0; y < height; y++) { const row = MAP[y]; for (let x = 0; x < width; x++) { const c = row.charAt(x); if (c === '#') { walls.add(x + ',' + y); } else if (c === '+' || c === '*') { goals.add(x + ',' + y); if (c === '+') startPlayer = [x, y]; if (c === '*') boxes.push([x, y]); } else if (c === '$') { boxes.push([x, y]); } } } let steps = 0; let pushes = 0; let solved = false; let player = startPlayer ? startPlayer : [0, 0]; const boxSet = new Set(boxes.map(b => b[0] + ',' + b[1])); function walk(dir) { if (solved) return; const dxMap = { up: 0, down: 0, left: -1, right: 1 }; const dyMap = { up: -1, down: 1, left: 0, right: 0 }; const dx = dxMap[dir]; const dy = dyMap[dir]; const nx = player[0] + dx; const ny = player[1] + dy; if (walls.has(nx + ',' + ny)) return; const boxKey = nx + ',' + ny; if (boxSet.has(boxKey)) { const bx = nx + dx; const by = ny + dy; const beyondKey = bx + ',' + by; if (walls.has(beyondKey)) return; if (boxSet.has(beyondKey)) return; boxSet.delete(boxKey); boxSet.add(beyondKey); player = [nx, ny]; steps++; pushes++; } else { player = [nx, ny]; steps++; } let allOnGoal = true; for (const b of boxSet) { if (!goals.has(b)) { allOnGoal = false; break; } } if (allOnGoal) solved = true; } function state() { const boxesSorted = Array.from(boxSet).map(k => { const p = k.split(',').map(Number); return [p[0], p[1]]; }); boxesSorted.sort((a, b) => a[1] - b[1] || a[0] - b[0]); return { player: player, boxes: boxesSorted, pushes: pushes, steps: steps, solved: solved }; } return { walk, state }; } </script> <script> (function() { const LEVEL = `######## # #+ # # * # # # # *# $ # # ## # ########`.trim().split('\n'); const width = 8; const height = 7; const walls = new Set(); const goals = new Set(); let startPlayer = null; const boxes = []; for (let y = 0; y < height; y++) { const row = LEVEL[y]; for (let x = 0; x < width; x++) { const c = row.charAt(x); if (c === '#') { walls.add(x + ',' + y); } else if (c === '+' || c === '*') { goals.add(x + ',' + y); if (c === '+') startPlayer = [x, y]; if (c === '*') boxes.push([x, y]); } else if (c === '$') { boxes.push([x, y]); } } } const board = document.getElementById('board'); for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { const cell = document.createElement('div'); cell.setAttribute('role', 'img'); const c = LEVEL[y].charAt(x); if (c === '#') { cell.setAttribute('aria-label', 'wall'); cell.textContent = '#'; cell.className = 'wall'; } else if (c === ' ') { cell.setAttribute('aria-label', 'empty floor'); cell.textContent = ''; cell.className = 'empty'; } else if (c === '+') { cell.setAttribute('aria-label', 'you on a goal'); cell.textContent = '+'; cell.className = 'player goal'; } else if (c === '*') { cell.setAttribute('aria-label', 'box on a goal'); cell.textContent = '*'; cell.className = 'goal box'; } else if (c === '$') { cell.setAttribute('aria-label', 'box'); cell.textContent = '$'; cell.className = 'box'; } board.appendChild(cell); } } let timeoutId = null; function updateUI() { const game = createGame(); const state = game.state(); document.getElementById('steps').textContent = state.steps; document.getElementById('pushes').textContent = state.pushes; const status = document.getElementById('status'); if (state.solved) { status.textContent = `Solved in ${state.steps} steps with ${state.pushes} pushes`; } else { status.textContent = 'Not solved yet'; } const cells = board.children; const boxSet = new Set(state.boxes.map(b => b[0] + ',' + b[1])); for (let i = 0; i < 56; i++) { const x = i % 8; const y = Math.floor(i / 8); const cell = cells[i]; if (walls.has(x + ',' + y)) { cell.setAttribute('aria-label', 'wall'); cell.textContent = '#'; cell.className = 'wall'; continue; } if (state.player[0] === x && state.player[1] === y) { if (goals.has(x + ',' + y)) { cell.setAttribute('aria-label', 'you on a goal'); cell.textContent = '+'; cell.className = 'player goal'; } else { cell.setAttribute('aria-label', 'you'); cell.textContent = '@'; cell.className = 'player'; } continue; } const boxKey = x + ',' + y; if (boxSet.has(boxKey)) { if (goals.has(boxKey)) { cell.setAttribute('aria-label', 'box on a goal'); cell.textContent = '*'; cell.className = 'goal box'; } else { cell.setAttribute('aria-label', 'box'); cell.textContent = '$'; cell.className = 'box'; } continue; } if (goals.has(boxKey)) { cell.setAttribute('aria-label', 'empty goal'); cell.textContent = '.'; cell.className = 'goal'; continue; } cell.setAttribute('aria-label', 'empty floor'); cell.textContent = ''; cell.className = 'empty'; } } function scheduleUpdate() { if (timeoutId) clearTimeout(timeoutId); timeoutId = setTimeout(updateUI, 100); } document.addEventListener('keydown', function(e) { if (e.key === 'ArrowUp') { document.querySelector('button[data-dir="up"]').click(); } else if (e.key === 'ArrowDown') { document.querySelector('button[data-dir="down"]').click(); } else if (e.key === 'ArrowLeft') { document.querySelector('button[data-dir="left"]').click(); } else if (e.key === 'ArrowRight') { document.querySelector('button[data-dir="right"]').click(); } }); document.querySelectorAll('button[data-dir]').forEach(btn => { btn.addEventListener('click', function() { const dir = this.getAttribute('data-dir'); const game = createGame(); game.walk(dir); scheduleUpdate(); }); }); document.getElementById('restart').addEventListener('click', function() { if (timeoutId) clearTimeout(timeoutId); updateUI(); timeoutId = setTimeout(updateUI, 100); }); timeoutId = setTimeout(updateUI, 100); })(); </script> </body> </html>MinesweeperPassed
40,034 tokens: 1,441 read, 38,593 written · 3 min 57 s · 163 tok/s
Build Minesweeper as one web page: a 9 by 9 board with 10 mines, in the layout below, with the board drawn on the page. In <script id="game">, define createGame() returning an object with press(move) and state(). The site plays the game more than once, calling createGame() again each time, so every game starts from the layout. move is an array [kind, row, col]: kind is "open" or "flag", row is 0 (top) to 8 (bottom), col is 0 (left) to 8 (right). state() returns {cells, status, mines_left}: cells is 9 strings of 9 characters, one per row from the top. A character is "#" for a hidden cell, "F" for a flagged cell, "." for an opened cell with no mines around it, "1" to "8" for an opened cell with that many mines among the 8 cells around it, and "*" for a mine after a loss. status is "playing", "won" or "lost". mines_left is 10 minus the number of flagged cells, and can be negative. The mines, row by row from the top. In this layout * is a mine and . is a safe cell. row 0 ......... row 1 ......... row 2 ......... row 3 .....*..* row 4 .*....*.. row 5 ...*..... row 6 ......... row 7 .**...*.* row 8 ........* The rules, exactly: 1. The game starts with every cell hidden, no flags, and status "playing". 2. press(["open", r, c]) on a hidden cell opens it. If it is a mine, status becomes "lost" and every mine shows "*", flagged or not. Otherwise the cell shows its number, or "." when no mine is among the cells around it. 3. An opened cell with no mines around it also opens each hidden, unflagged cell around it (8 directions). Each of those with no mines around it opens its own hidden, unflagged neighbours the same way, repeatedly, until nothing more opens. A flagged cell is never opened this way, and nothing spreads from it. A numbered cell opens, but nothing spreads from it. 4. press(["open", r, c]) on a flagged cell or an opened cell does nothing. 5. press(["flag", r, c]) on a hidden cell flags it. On a flagged cell it removes the flag, and the cell is hidden again. On an opened cell it does nothing. 6. status becomes "won" when every cell without a mine is opened, however the last cell is opened. A flag does not count: a flagged cell without a mine must be unflagged and opened. After a win every mine shows "F" and counts as flagged, whether or not the player flagged it, so mines_left is 0. 7. Once status is "won" or "lost", press does nothing. After a loss a flag still counts in mines_left, even on a mine that shows "*", and a flag on a safe cell still shows "F". The page: a title, a short paragraph of rules, then one white panel holding a status line, a Flag mode button and the board, on a warm off-white page. The type is the system sans-serif (font-family: system-ui, sans-serif); load no font. Give these parts these names, so the site can read them: - an element with role="status": it shows "Mines left" and mines_left as a number, with a minus sign when it is below zero, then the status word, "Playing", "Won" (green) or "Lost" (red); - a button with id="flag-mode": it starts with the text "Flag mode: off" and aria-pressed="false". When it is on, its text is "Flag mode: on", aria-pressed="true", and it is drawn in the pink accent; - the board, which is either 81 cell buttons, each with data-row (0 at the top to 8) and data-col (0 at the left to 8), or one canvas that draws all of it, with the id board: 324 pixels across and down (set its width and height attributes), nine squares of 36 pixels each way, row 0 at the top and column 0 at the left. On a canvas, a click or a right-click acts on the square under the pointer: find the square from the event's offsetX and offsetY, each scaled by the canvas's width over its clientWidth (or its height over its clientHeight), since a phone may draw the canvas smaller. A click on a cell calls press(["open", row, col]) for that cell, unless Flag mode is on: then it calls press(["flag", row, col]). A right-click on a cell (the contextmenu event) calls press(["flag", row, col]) and prevents the browser's own menu. Draw the board from state() after every press: a hidden or empty cell shows no text, a numbered cell shows its number, and a flag or a mine shows a mark with text in it (a symbol, or a word hidden from sight). On a canvas, clear the whole canvas and draw it again after every press, the cells in reading order (row 0 first, columns left to right): a numbered cell as its number in text, a flag or a mine as one short mark in text (F, *, or another plain symbol), and a hidden or empty cell as nothing; the canvas draws nothing else. Flags and mines are simple marks, not emoji. The page fits a phone with no sideways scrolling. A reload of the page starts a new game: every cell is hidden, no flag is set, Flag mode is off and the status reads "Playing", so nothing from the last load is kept. The keyboard is welcome but not checked: Tab moves between cells, Enter or Space opens one, and F flags it. The page runs its own code only: no eval, no Function(), no timer given as text, and no network request (fetch, XMLHttpRequest, WebSocket, EventSource, sendBeacon or importScripts). It loads nothing from another site. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>.Open the page on its own. It runs in a sandbox: no network, no access to this site.
Page source
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Minesweeper</title> <style> body { font-family: system-ui, sans-serif; background: #fdf6e3; margin: 0; padding: 2rem; color: #333; overflow-x: hidden; } h1 { text-align: center; margin-bottom: 0.5rem; } p.rules { text-align: center; margin-bottom: 1.5rem; font-size: 0.9rem; } .panel { background: white; padding: 1.5rem; margin-bottom: 1rem; border-radius: 8px; max-width: 360px; margin-left: auto; margin-right: auto; } #status { font-size: 1rem; margin-bottom: 0.5rem; } #flag-mode { width: 100%; padding: 0.5rem; font-size: 1rem; cursor: pointer; } #board { max-width: 324px; display: block; margin: 0.5rem auto; border: 1px solid #ccc; } </style> </head> <body> <h1>Minesweeper</h1> <p class="rules">Classic Minesweeper: click cells to open them, right-click or use Flag mode to flag suspected mines. Clear all safe cells to win, or hit a mine to lose.</p> <div class="panel"> <div id="status" role="status"></div> <button id="flag-mode" aria-pressed="false">Flag mode: off</button> <canvas id="board" width="324" height="324"></canvas> </div> <script id="game"> function createGame() { const mineCoords = [ [3,5],[3,8],[4,1],[4,6],[5,3],[7,1],[7,2],[7,6],[7,8],[8,8] ]; const minesSet = new Set(mineCoords.map(([r,c]) => `${r},${c}`)); let flagsSet = new Set(); let openedSet = new Set(); let status = "playing"; function countAdjacentMines(r, c) { let count = 0; for (let dr = -1; dr <= 1; dr++) { for (let dc = -1; dc <= 1; dc++) { if (dr === 0 && dc === 0) continue; const nr = r + dr, nc = c + dc; if (nr >= 0 && nr < 9 && nc >= 0 && nc < 9 && minesSet.has(`${nr},${nc}`)) count++; } } return count; } function openCell(r, c) { if (openedSet.has(`${r},${c}`) || flagsSet.has(`${r},${c}`)) return; openedSet.add(`${r},${c}`); const count = countAdjacentMines(r, c); if (count === 0) { for (let dr = -1; dr <= 1; dr++) { for (let dc = -1; dc <= 1; dc++) { if (dr === 0 && dc === 0) continue; const nr = r + dr, nc = c + dc; if (nr >= 0 && nr < 9 && nc >= 0 && nc < 9) { openCell(nr, nc); } } } } } function checkWin() { for (let r = 0; r < 9; r++) { for (let c = 0; c < 9; c++) { if (!minesSet.has(`${r},${c}`) && !openedSet.has(`${r},${c}`)) return; } } status = "won"; } function press(move) { const [kind, r, c] = move; if (status !== "playing") return; if (kind === "flag") { if (openedSet.has(`${r},${c}`)) return; if (flagsSet.has(`${r},${c}`)) { flagsSet.delete(`${r},${c}`); } else { flagsSet.add(`${r},${c}`); } checkWin(); } else if (kind === "open") { if (flagsSet.has(`${r},${c}`)) return; if (openedSet.has(`${r},${c}`)) return; if (minesSet.has(`${r},${c}`)) { status = "lost"; } else { openCell(r, c); checkWin(); } } } function state() { const cells = []; for (let r = 0; r < 9; r++) { let row = ""; for (let c = 0; c < 9; c++) { const isMine = minesSet.has(`${r},${c}`); const isFlagged = flagsSet.has(`${r},${c}`); const isOpened = openedSet.has(`${r},${c}`); let char; if (status === "won") { if (isMine) char = "F"; else { const count = countAdjacentMines(r, c); char = count === 0 ? "." : count; } } else if (status === "lost") { if (isMine) char = "*"; else { if (isFlagged) char = "F"; else if (isOpened) { const count = countAdjacentMines(r, c); char = count === 0 ? "." : count; } else { char = "#"; } } } else { if (isFlagged) char = "F"; else if (isOpened) { const count = countAdjacentMines(r, c); char = count === 0 ? "." : count; } else { char = "#"; } } row += char; } cells.push(row); } const mines_left = status === "won" ? 0 : 10 - flagsSet.size; return { cells, status, mines_left }; } return { press, state }; } </script> <script> document.addEventListener('DOMContentLoaded', () => { const game = createGame(); const canvas = document.getElementById('board'); const statusEl = document.getElementById('status'); const flagBtn = document.getElementById('flag-mode'); let flagMode = false; function updateUI() { const { cells, status, mines_left } = game.state(); let statusWord = "Playing"; let statusColor = ""; if (status === "won") { statusWord = "Won"; statusColor = "green"; } else if (status === "lost") { statusWord = "Lost"; statusColor = "red"; } statusEl.textContent = `Mines left ${mines_left} ${statusWord}`; statusEl.style.color = statusColor; flagBtn.textContent = flagMode ? "Flag mode: on" : "Flag mode: off"; flagBtn.setAttribute('aria-pressed', flagMode); flagBtn.style.background = flagMode ? 'pink' : ''; const ctx = canvas.getContext('2d'); const cell = 36; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.textBaseline = 'middle'; ctx.textAlign = 'center'; for (let r = 0; r < 9; r++) { for (let c = 0; c < 9; c++) { const ch = cells[r][c]; if (ch === '.' || ch === '#') continue; ctx.fillStyle = 'black'; ctx.fillText(ch, c * cell + 18, r * cell + 18); } } } updateUI(); flagBtn.addEventListener('click', () => { flagMode = !flagMode; flagBtn.textContent = flagMode ? "Flag mode: on" : "Flag mode: off"; flagBtn.setAttribute('aria-pressed', flagMode); flagBtn.style.background = flagMode ? 'pink' : ''; }); canvas.addEventListener('click', e => { if (e.button !== 0) return; const cx = e.offsetX * canvas.width / canvas.clientWidth; const cy = e.offsetY * canvas.height / canvas.clientHeight; const col = Math.floor(cx / 36); const row = Math.floor(cy / 36); if (col >= 0 && col < 9 && row >= 0 && row < 9) { if (flagMode) { game.press(["flag", row, col]); } else { game.press(["open", row, col]); } updateUI(); } }); canvas.addEventListener('contextmenu', e => { e.preventDefault(); const cx = e.offsetX * canvas.width / canvas.clientWidth; const cy = e.offsetY * canvas.height / canvas.clientHeight; const col = Math.floor(cx / 36); const row = Math.floor(cy / 36); if (col >= 0 && col < 9 && row >= 0 && row < 9) { game.press(["flag", row, col]); updateUI(); } }); }); </script> </body> </html>
Building apps 0 of 4
Step sequencerNot run
Build a web page called "Step sequencer": three rows labelled Kick, Snare and Hat, of 16 step buttons each, a Play button and a Stop button, and drums made with the Web Audio API, with no sound files. In <script id="game">, define createGame() returning an object with press(cmd) and state(). The page calls createGame() at load or on the first press. The logic keeps the pattern, whether it is playing, the playhead and the hits. The page makes the sound. Do not use eval or Function, and never run text as code: give a timer a function, not a string. The starting pattern, one row per track. Steps are numbered from 1 in the rows below: each row is 16 characters, 1 for on and 0 for off. The first character is step 1 on the page and step 0 for press(): kick 1000100000101000 snare 0000100000001010 hat 1010101110101000 The rules, exactly: 1. At the start, playing is false, playhead is 0 and hits is []. 2. press([track, step]) toggles one cell: track 0 is kick, 1 snare, 2 hat; step is 0 to 15, where 0 is the first step. Toggling changes the pattern and nothing else. 3. press('play') does nothing when playing is already true. Otherwise it sets playing to true, and hits becomes the list of track numbers (0 kick, 1 snare, 2 hat) whose cell at the playhead is 1, in ascending order ([] when there are none). So the step under the playhead sounds as play starts. 4. press('stop') sets playing to false, playhead to 0 and hits to []. 5. press('tick') does nothing unless playing is true. When it is, playhead goes on by one, and after 15 it goes back to 0. hits becomes the list of track numbers whose cell at the new playhead is 1, in ascending order ([] when there are none). 6. Any other cmd does nothing: a list that is not exactly two whole numbers (such as [0, 1, 2], [1], [] or [true, 0]), null, a number, true or false, a word other than play, stop or tick, and a track or step outside the ranges above. Track and step are whole numbers. state() returns {playing, playhead, hits, pattern}: playing is true or false; playhead is 0 to 15; hits lists the track numbers set by the last tick or by the play that started playback, in ascending order ([] at the start and after stop); pattern is three strings of 16 characters, kick first, each character 1 or 0. The page: - Each step button is a real button with the attributes data-track (0, 1 or 2) and data-step (0 to 15), and aria-pressed set to true or false to match its state. A click calls press([track, step]), and after every press, the page draws from state(). - A step that is on has the class on, and the stylesheet fills it dark; a step that is off has no class on. - Play has the id play and Stop the id stop. Play calls press('play') and starts one timer that calls press('tick') every 125 ms: 120 quarter-note beats a minute, four steps to a beat. Stop calls press('stop') and clears the timer. Each play and each tick sounds the hits that state() then reports, and nothing else sounds. - Play has the disabled attribute while playing, and Stop has it while stopped. - A status line with the id status reads "Stopped", or "Playing, step N of 16" with N the playhead plus 1. Give it a fixed height, so the grid does not move when its text changes. - A span with the id announce, set to aria-live polite, is empty until playback starts for the first time. From then on it says "Playing" when playback starts and "Stopped" when it stops, and changes at no other time. - The cells in the playhead column have the class playhead while playing, and no cell has it while stopped. - The numbers 1 to 16, as text, sit above the grid, and the playhead's number is pink. Under 720 px each step shows its number. - When the page becomes hidden, it presses Stop, so nothing sounds in a background tab. - Each track in hits plays its drum: kick is a falling sine tone, snare a short noise burst with a low body tone, hat a short high noise burst. Tones use oscillators; noise bursts use buffer sources playing a buffer of random samples: the kick is one oscillator, the snare one buffer source and one oscillator, the hat one buffer source. Hits that land together must not clip, so put a gain or a limiter before the output. Create the AudioContext inside the first click (browsers need a click before they make sound), and resume it if it is suspended. - Flat and plain: a light background, dark ink, no shadows or gradients, Play the one pink button (#b31f57), and the playhead cell outlined in pink where you are. At 1280 px the 16 steps sit in one row; under 720 px they form two bars of 8. The page never scrolls sideways. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and drives the sequencer through createGame(). Wire the page in another <script>.Grow a branching plantNot run
Build a plant that grows by a rewrite rule (an L-system) as one web page: a heading, a canvas that draws the plant, a Grow button and a Reset button. In <script id="game">, define createGame() returning an object with grow() and state(). grow() takes no argument. state() returns {generation, text, segments}: generation is a number, text is a string, and segments is a list with one [x1, y1, x2, y2] entry for each F in text, in the order the Fs appear in text. [x1, y1] is the cell a segment starts from and [x2, y2] the cell it ends on. The rules, exactly: 1. A pen starts at [0, 0] facing north, which is heading 6. Headings are numbered 0 to 7 clockwise, each one a step [dx, dy] with y growing downward: 0 [1, 0] east, 1 [1, 1] south-east, 2 [0, 1] south, 3 [-1, 1] south-west, 4 [-1, 0] west, 5 [-1, -1] north-west, 6 [0, -1] north, 7 [1, -1] north-east. 2. The text starts as F, at generation 0. The pen reads the text from left to right. F moves the pen one step along its heading and adds the segment [x1, y1, x2, y2] for that step. + adds 1 to the heading and - subtracts 1, both modulo 8. [ saves the pen's position and heading. ] restores the last saved position and heading and forgets them. Any other symbol does nothing. 3. grow() rewrites the text in one pass: every F becomes F[[++F]+F[--F]]F, and every other symbol stays as it is. The Fs that the rule adds are not rewritten in that pass. Then generation goes up by 1. 4. segments is what the pen draws over the new text, starting again at [0, 0] facing north, as in rule 1. 5. At the start, generation is 0, text is "F" and segments is [[0, 0, 0, -1]]. 6. grow() at generation 4 changes nothing: generation, text and segments stay as they are. The site calls grow() five times in a row, and reads state() before the first call and after each call, so every state must match these rules. The fifth call is made at generation 4. Keep the rule in the game script as one string, written exactly as rule 3 gives it: the site also runs the script with another rule in its place, and its states must follow that rule. The page: a heading (an <h1>) reading exactly "Grow a branching plant". Below it, one canvas draws each segment as a line from its start point to its end point, with the context's own moveTo, lineTo and stroke (not Path2D). The canvas draws nothing else: no other shapes, no text and no images. The drawing has the shape the segments give, with north up on the canvas: one scale on both axes, fitted to the canvas and centred. Each drawing starts by clearing the whole canvas (clearRect over all of it, or setting the canvas's width), so only the new plant is on it. Each press of Grow draws the whole plant again, at once, with one lineTo for each segment: no animation frames and no delays. The plant is drawn when the page loads, and Reset draws the stem again within a tenth of a second. Grow is a <button id="grow"> reading exactly "Grow". A press calls grow(), then draws and shows the new state, and Grow is disabled at generation 4. Reset is a <button id="reset"> reading exactly "Reset". A press calls createGame() for a new plant, draws it, and enables Grow again. Wire both with addEventListener('click', ...). A status line, an element with role="status", reads "Generation g of 4, n segments", where g is the generation and n the number of segments (the word is "segment" when n is 1), and it changes after each press. Look: plain and tidy, like a small app. A light, warm off-white page, the canvas in a white card with a thin border, the plant in dark ink, Grow as the main button and Reset as an outlined button under the card. The page must work at 390 px and at 1280 px wide with no sideways scrolling. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not use document, window, localStorage, sessionStorage or any timer, because the site runs that script on its own and plays the game through createGame(). The script is at most 20,000 characters. Wire the page in another <script>. Neither script may use eval or Function, reach Function through a constructor, or give a timer text to run; and neither may read window, self, globalThis, top, parent, frames or this with square brackets. A constructor() method in a class is fine, and so is a constructor key in an object; reading a constructor property, as x.constructor or x['constructor'], is not. A timer is given a function: one written in the call, or one the page declares by name. Square brackets take a number or a name, never quoted text, and window is used only as window.name.Falling sandNot run
Build a page called Falling sand: a 40 by 30 board drawn on a canvas. Sand falls one frame at a time and slides off the edges of piles. Pressing or dragging on the board pours sand, Play runs the frames, and Step runs one. In <script id="game">, define createGame(). It returns an object with play(move) and state(). move is "step" (run one frame) or [x, y] (pour one grain of sand into column x, row y). state() returns {frame, cells}: frame is the number of frames run so far (a pour is not a frame), and cells is 30 rows of 40 numbers, top row first: 0 is empty, 1 is sand, 2 is wall. Column x runs 0 to 39, left to right; row y runs 0 to 29, top to bottom. The start, exactly (both ends of each run are included): 1. frame is 0. Row 29 is all wall. 2. Walls: row 20, columns 8 to 16; column 3, rows 17 to 21; row 24, columns 20 to 26. 3. Sand: column 23, row 2; row 3, columns 19 to 27; row 4, columns 17 to 29; row 5, columns 17 to 29; row 6, columns 16 to 30; row 7, columns 17 to 29; row 8, columns 17 to 29; row 9, columns 19 to 27; column 23, row 10. 4. Every other cell is empty. The rules, exactly: 1. A pour [x, y] puts one grain in that cell if it is empty; a cell holding sand or wall, or outside the grid, is not empty, so the pour does nothing. 2. A step runs one frame, using frame as it is before the step, then frame goes up by 1. A frame scans the rows from row 28 up to row 0. Within a row it scans the columns from left to right when frame is even, and from right to left when frame is odd. 3. Each sand cell the scan reaches moves at most once: to (x, y+1) if that cell is empty; otherwise to (x-1, y+1) if that is empty; otherwise to (x+1, y+1) if that is empty; otherwise it stays. Anything outside the grid counts as wall. 4. Each check reads the cells as they are at that moment: a grain that has moved leaves its cell empty, and a cell an earlier grain filled in this frame is not empty. The site plays a list of moves through play() and checks state() after each one. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the game logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and plays the game through createGame(). Wire the page in another <script>. Do not run a string as code: no eval, no Function (not even as a function's constructor property), no timer given a string, no javascript: address, and no script element made from text. Network requests are refused, and the game script is at most 20,000 characters. The page: a canvas with the id board and the width and height attributes 640 and 480. The board may be shown at any size and place on the page: a press or drag finds its cell from where the board is on screen not from its 640 by 480 pixels. A press on the board pours one grain into the cell under the pointer. A drag pours into every cell on the straight line from the cell the pointer left to the cell it reached, both ends included (Bresenham's line algorithm). Buttons with the ids play, step and reset. play runs one frame about every 50 ms, and its label reads Pause while it runs; pressing it again pauses, and the label reads Play. step runs one frame. reset calls createGame() again, back to the start, and stops Play if it is running. After each pour, after each frame that Play or Step runs, and after Reset, the board is cleared or filled once, then each grain of sand is drawn with fillRect in its own cell; empty cells are not drawn one by one. One line under the board, with the id status, reads "Frame N, M grains of sand" ("1 grain of sand" for one), N is the frame and M the grains. Not checked, but wanted: keyboard pouring (arrow keys move a pour cursor when the board has focus; Space or Enter pours at it); a live region with the id say that announces Play, Pause, Step and Reset; reduced motion (prefers-reduced-motion: reduce): a press of Play runs one frame; off screen, Play pauses for real (no frame runs, the label reads Play) and resumes on return only if it was playing, and a press of Play then does nothing, while Step still runs one frame.Focus timerNot run
Build a focus timer as one web page. Work periods alternate with breaks, and after every few finished work periods the break is long. The page shows the name of the period, the time left, an SVG ring that empties as the time runs down, and how many work periods are done. In <script id="game">, define createGame(). It returns an object with two methods, tick(cmd) and state(). The page's own timer calls tick() once a second, and its buttons call tick('start'), tick('pause'), tick('skip') and tick('reset'). Those four exact lowercase words are commands: they change the timer and pass no time. Any other value passes one second, and only while the timer is running: no argument, null, undefined, a number, true, false, an empty text, any other text such as 'Start' or 'tick', or an object. state() returns {phase, left, running, done}: phase is 'work', 'short' or 'long'; left is the whole number of seconds left in this period; running is true or false; done is a number. The script in <script id="game"> is at most 20,000 characters. This run's lengths: work 1800 seconds (30 minutes), short break 420 seconds (7 minutes), long break 600 seconds (10 minutes). A long break follows every 3rd finished work period. The rules, exactly: 1. The timer starts in work, with left 1800, running false and done 0. 2. 'start' sets running to true, and 'pause' sets it to false. Neither changes anything else. 3. While running, each passed second lowers left by 1. While paused, passed seconds change nothing. 4. When left reaches 0, the period is over at once, so state() never shows 0. The next period starts with its full length and paused (running false). Seconds passed after that change nothing until 'start'. 5. A work period that ends this way adds 1 to done. Then a long break comes when done is a multiple of 3, otherwise a short break. 6. 'skip' ends the current period at once, whatever left is, and the next period starts paused. A skipped work period does not add to done, and the break after it is a short break whatever done is. A skipped break is followed by work. 7. After any break comes work. A break never adds to done. 8. 'reset' sets left back to the full length of the current period and sets running to false. It does not change the phase or done. The page: - A heading, "Focus timer". - The name of the period, alone in an element with the id phase: Focus, Short break or Long break. - The time left, as mm:ss with two digits each, alone in an element with the id time. At the start of this run's work period it reads 30:00. - An SVG ring around the time: a circle with pathLength="100" and stroke-dasharray="100". Set its stroke-dashoffset attribute to 100 times (1 minus left divided by the full length of the current period) on every redraw. The arc is full, with an offset of 0, at the start of a period, and it is empty, with an offset of 100, when the time is up. A track circle without a stroke-dashoffset may sit under it. - Four buttons in one row, with the ids start, pause, skip and reset, labelled Start, Pause, Skip and Reset. Each calls tick() with its command. Start is disabled while the timer runs, and Pause is disabled while it is paused. Skip and Reset are always enabled. Below 390 px they may wrap into two rows of two. - The count in an element with the id count, in words: "Focus periods done: 3". - The page's own timer calls tick() once a second, with no argument. After every call, the page redraws from state(). When a period ends, the page may play a short chime with the Web Audio API. - Look: a light, warm off-white page with one white card, dark ink text and muted grey for the small labels. One accent colour, used for the Start button only. Flat fills, no gradients or shadows, no outside fonts or images: use the system font. It must look tidy at 390 px and at 1280 px wide, with no sideways scrolling. Output one complete HTML document and nothing else, with all CSS and JavaScript inline and nothing loaded from another site. Put the timer's logic, and only it, in <script id="game">: it must not touch document, window or timers, because the site runs that script on its own and drives the timer through createGame(). Do not use eval, Function or any other way of running text as code: no string given to a timer, and no script element or event-handler attribute made from text while the page runs. Put the wiring in another <script>.
Writing code 0 of 3
Merge intervalsNot run
Write a JavaScript function mergeIntervals(intervals). intervals is an array of [start, end] pairs of integers with start <= end, in any order, possibly empty. Return a new array of the merged intervals sorted by start: intervals that overlap or touch (one ends where the next starts) become one. Do not change the input array or its pairs. mergeIntervals([[8, 10], [1, 3], [2, 6], [6, 7]]) returns [[1, 7], [8, 10]]. Reply with one ```js code block holding plain JavaScript (no imports, no exports, no DOM, no timers). The site runs it with hidden tests.
An LRU cacheNot run
Write a JavaScript class LRUCache: a least-recently-used cache of integer keys and values. - new LRUCache(capacity): capacity is an integer of at least 1. - get(key) returns the value stored for key, or -1 if there is none. A get that finds the key makes it the most recently used. - put(key, value) stores the value (replacing any value already there) and makes key the most recently used. If that leaves more than capacity keys, the least recently used key is removed. get and put should take constant time on average. Reply with one ```js code block holding plain JavaScript (no imports, no exports, no DOM, no timers). The site runs it with hidden tests.
Evaluate arithmeticNot run
Write a JavaScript function evaluate(expr) that returns the value of an arithmetic expression given as a string. The expression has non-negative integers, the operators + - * /, parentheses, unary minus (as in -3, - -3, 2 * -3 or -(1 + 2)) and spaces anywhere between tokens. * and / bind tighter than + and -, and operators of the same kind group from the left. / is integer division that truncates toward zero: 7 / 2 is 3 and -7 / 2 is -3. Dividing by zero must throw an Error. Do not use eval or Function. evaluate("2 + 3 * (4 - 6) / 4") returns 1. Reply with one ```js code block holding plain JavaScript (no imports, no exports, no DOM, no timers). The site runs it with hidden tests.
Fixing code 0 of 2
Fix the bookings moduleNot run
This JavaScript module has one bug. Guests are charged the weekend rate for Sunday nights and the weekday rate for Friday nights. Find it and fix it without changing anything else. ```js // Bookings for one holiday flat. A booking is { guest, checkIn, checkOut } with dates as "YYYY-MM-DD". // A guest sleeps the nights from checkIn up to, but not including, checkOut: checkOut is the day they leave, // and another guest may check in that same day. function dayNumber(date) { const [y, m, d] = date.split('-').map(Number); return Date.UTC(y, m - 1, d) / 86400000; } function toDate(day) { return new Date(day * 86400000).toISOString().slice(0, 10); } function nights(booking) { return dayNumber(booking.checkOut) - dayNumber(booking.checkIn); } function overlaps(a, b) { return dayNumber(a.checkIn) < dayNumber(b.checkOut) && dayNumber(b.checkIn) < dayNumber(a.checkOut); } function canBook(bookings, request) { if (nights(request) < 1) return false; for (const booking of bookings) { if (overlaps(booking, request)) return false; } return true; } function isBooked(bookings, day) { return bookings.some((b) => dayNumber(b.checkIn) <= day && day < dayNumber(b.checkOut)); } // The nights from `from` up to, but not including, `to` that someone has booked. function bookedNights(bookings, from, to) { let count = 0; for (let day = dayNumber(from); day < dayNumber(to); day++) { if (isBooked(bookings, day)) count++; } return count; } // The first night on or after `from` that nobody has booked, as "YYYY-MM-DD". function firstFreeNight(bookings, from) { let day = dayNumber(from); while (isBooked(bookings, day)) day++; return toDate(day); } // The price in cents: Friday and Saturday nights at rates.weekend, every other night at rates.weekday. function price(booking, rates) { let total = 0; for (let day = dayNumber(booking.checkIn); day < dayNumber(booking.checkOut); day++) { const weekday = new Date(day * 86400000).getUTCDay(); total += weekday === 6 || weekday === 0 ? rates.weekend : rates.weekday; } return total; } ``` Reply with the whole corrected module in one ```js code block, with the same function names.Fix the CSV readerNot run
This JavaScript module has one bug. A last field that is empty is dropped: the line x,y, comes back as two fields, x and y, instead of three: x, y and an empty field. Find it and fix it without changing anything else. ```js // Reads CSV the way spreadsheets write it: fields are separated by commas, a field may be wrapped in // double quotes so it can hold commas, and "" inside a quoted field stands for one double quote. // Fields are not trimmed. Empty lines are skipped. function parseLine(line) { const fields = []; let field = ''; let quoted = false; for (let i = 0; i < line.length; i++) { const ch = line[i]; if (quoted) { if (ch === '"') { if (line[i + 1] === '"') { field += '"'; i++; } else { quoted = false; } } else { field += ch; } } else if (ch === '"') { quoted = true; } else if (ch === ',') { fields.push(field); field = ''; } else { field += ch; } } if (field !== '') fields.push(field); return fields; } function parseCSV(text) { return text.split(/\r?\n/).filter((line) => line !== '').map(parseLine); } // Each row after the header as an object keyed by the header's names; a missing field is ''. function toObjects(text) { const [header, ...rows] = parseCSV(text); return rows.map((row) => { const record = {}; header.forEach((name, i) => { record[name] = i < row.length ? row[i] : ''; }); return record; }); } // The sum of a column's numbers; fields that are not numbers count as 0. function sumColumn(text, name) { return toObjects(text).reduce((total, record) => total + (Number(record[name]) || 0), 0); } ``` Reply with the whole corrected module in one ```js code block, with the same function names.
Planning and data 0 of 3
A query over hidden dataNot run
Write one SQLite query that answers the question below. The site runs it on its own copy of these tables, filled with rows you have not seen. ```sql CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT NOT NULL, city TEXT NOT NULL); CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER NOT NULL REFERENCES customers(id), placed TEXT NOT NULL, -- 'YYYY-MM-DD' status TEXT NOT NULL); -- 'delivered', 'cancelled' or 'pending' CREATE TABLE items (order_id INTEGER NOT NULL REFERENCES orders(id), product TEXT NOT NULL, quantity INTEGER NOT NULL, price_cents INTEGER NOT NULL); -- price_cents: for one unit ``` Question: Every customer who has no delivered order (including customers with no orders at all), with how many orders of any status they placed. Columns: name, orders. Any order of rows. Reply with only the query, in one ```sql code block: one SELECT statement (WITH is fine), nothing that changes the database.Schedule five meetingsNot run
Five people each have one meeting today: Ana, Cleo, Eli, Ivy, Lea. The five meetings are at different times, 09:00, 10:00, 11:00, 13:00, 14:00 (in that order: 10:00 is right after 09:00, 13:00 right after 11:00), and in different rooms. The list of rooms, in order: Maple, Oak, Pine, Rowan, Willow. 1. Cleo is not in Oak. 2. Lea meets earlier than Eli. 3. Eli is not in Maple. 4. Eli meets earlier than Ivy. 5. Ana's and Cleo's rooms are next to each other on the list of rooms. 6. Eli's and Lea's rooms are next to each other on the list of rooms. 7. Whoever is in Oak meets earlier than Ana. 8. Whoever is in Willow meets earlier than Cleo. 9. Whoever is in Rowan meets earlier than Ana. Exactly one schedule fits every clue. Work it out, then end with exactly five lines, one per person, in this form: Ana: 09:00, Oak
A replacement in ten calls or fewerNot run
Hi, it's ben.okafor@example.com. My kettle arrived with a cracked lid. Can you sort it out?
Comments
Sign in or create an account to comment.