Gemma-4-31B
M4 Max 128 GB · llama.cpp llama-swap (version not exposed) · every run of this model · uwu · 2026-11-04
Race it: run Gemma-4-31B on your computer and see the two side by side.
- Tasks passed
- 27/44 15 not run
- Points
- 43/64Harder tasks count 3
- Tokens
- 318,25513,713 read, 304,542 written, as the runner counted them
- Speed
- 9.8 tok/sAs the runner measured it; the site cannot check this.
- Writing speed
- 9.8 tok/sPrompt reading left out. As the runner measured it; the site cannot check this.
tok/s is tokens a second: how fast the model writes. A token is about three quarters of a word. How the score works.
This setup, checked
No other runs of Gemma-4-31B on M4 Max 128 GB yet; the next one will be compared with this one.
Not on the leaderboard: it was posted under an earlier version of the task suite. Leaderboard
- Summarizing 0/5
- Extracting 0/5
- Following instructions 0/5
- Reasoning 5/5
- Reading code 4/4
- Using tools 5/5
- Building pages 5/5
- Building games 1/2
- Writing code 2/3
- Fixing code 2/2
- Planning and data 3/3
Run details
Flag this run
Failed 2
Build SnakeCut off at the app's length limitFailed
131,072 tokens: 463 read, 130,609 written · 3 h 50 min · 9.4 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, 6], [5, 5], [5, 4]], moving down, food at [4, 0], 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>.Evaluate arithmeticCut off at the app's length limitFailed
131,072 tokens: 200 read, 130,872 written · 3 h 52 min · 9.4 tok/s
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.
What it built
Pages and games, as the model wrote them, each in a sandbox. On a computer, click a game and use the arrow keys.
-
Build 2048Keeps a game's rules across many moves.Passed · 12k tokens · 12.9 tok/s
-
A small websiteLays out a small website with a menu and a footer.Passed · 1.9k tokens · 13.3 tok/s
-
A pricing table with a toggleSwitches every price between monthly and yearly with one button.Passed · 2.2k tokens · 13.3 tok/s
-
An accessible sign-up formChecks a sign-up form and labels each of its fields.Passed · 1.3k tokens · 13.3 tok/s
-
A to-do app that remembersKeeps data across a reload.Passed · 1.7k tokens · 13.3 tok/s
-
A bar chart in SVGDraws data to scale.Passed · 2k tokens · 13.3 tok/s
Scored tasks
Summarizing 0 of 5
One-sentence summaryNot run
Passes when One sentence of 5 to 30 words saying the library opens earlier (8 a.m.) on weekdays.
Summarize this in one sentence of at most 30 words. Starting March 3, the Millbrook Public Library will open at 8 a.m. instead of 10 a.m. on weekdays. The change follows a survey in which 62% of respondents asked for earlier hours. Weekend hours stay the same. The library will hire two part-time staff to cover the extra time, paid for by a state grant.
Meeting notes in three bulletsNot run
Passes when Exactly three bullet points and nothing else, each at most 20 words, covering the launch moving to June 12, the approved marketing budget and Priya owning testing, and leaving out the webhook fix and the coffee machine.
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: Priya, Omar, Jules, Sam. - Omar reported that the payment provider fixed the webhook bug; no action needed. - The launch date moves from June 5 to June 12 because the app store review is slow. - Jules showed the new onboarding screens. Everyone liked them. Small copy changes only. - The marketing budget of $40,000 was approved by finance on Monday. - Priya will own end-to-end testing from now on; Sam hands over the test plan by Friday. - Next sync is moved to Thursday at 10:00. - Coffee machine on floor 3 is broken again.
Review sentiment and complaintNot run
Passes when Both lines. Sentiment is mixed: the reviewer loves the battery and sound but is annoyed. The complaint names the charger or support in at most 12 words.
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 speaker every day for a month. The battery is honestly amazing, easily two full days, and it sounds far better than its size suggests. But the charger that came in the box stopped working after a week, and support took nine days to reply. I bought a replacement cable myself. Would I buy it again? Probably, but I'm annoyed.
Faithful summary of a studyNot run
Passes when At most 50 words with the 240 participants, the 12-week length and the 3.1-day result, and nothing the text does not say (no approval, cure, children or recommendation).
Summarize this in at most 50 words. Keep the key numbers. Do not add anything the text does not say. In a randomized trial, 240 adults with chronic migraine took either the new drug or a placebo for 12 weeks. Those on the drug had 3.1 fewer headache days per month on average, compared with 1.9 fewer days for placebo. Nausea was the most common side effect, reported by 9% of the drug group. The authors note the trial lasted only 12 weeks and call for longer studies before any recommendation is made.
Action items from an email threadNot run
Passes when Exactly four lines of the form "- owner: action": Dana sends the contract, Luis books the venue, Mei updates the budget sheet, Dana emails the caterer. Tom's declined offer, the logo and the invitations are left out.
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: Dana Hi all, quick recap of what's still open for the June offsite. I'll send the revised contract to the hotel by Wednesday. From: Tom I can book the venue for the dinner if that helps? From: Luis Thanks Tom, 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: Mei I'll update the budget sheet with the new hotel price tonight. From: Dana Great. Oh, and I'll email the caterer about the vegetarian options. Tom, could you just double-check the date on the invitations? Actually never mind, I checked them this morning, they're correct.
Extracting 0 of 5
Fields from an email as JSONNot run
Passes when Only a JSON object with exactly name "Laura Chen", company "Northwind Traders", meeting_date "2025-05-14" and attendees the number 4.
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 Laura Chen from Northwind Traders. We'd love to visit your workshop. Could we meet on the 14th of May 2025, any time after lunch? We'll be four people in total, including me. Best, Laura
Every email address, onceNot run
Passes when Exactly four addresses, one per line, in order: info@harbor-events.org, speakers@harbor-events.org, mia.k@studio-nine.io, accounts@harbor-events.org. "jo at harbor dot org" is not written out in full, and its inbox is closed.
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 info@harbor-events.org for general questions, or to speakers@harbor-events.org if you are presenting. Our designer (mia.k@studio-nine.io) made the poster. Billing questions: accounts@harbor-events.org. Again, presenters use speakers@harbor-events.org. Please don't write to jo at harbor dot org, that inbox is closed.
A list as CSVNot run
Passes when The header item,qty,price, then the four items with whole-number quantities and prices as plain numbers (no $).
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. Apples - 12 @ $0.50 Bread loaf - 2 @ $3.25 Olive oil (1 l) - 1 @ $8.90 Eggs - 18 @ $0.30
The real deadlineNot run
Passes when Only 2025-02-07, the extended deadline.
What is the final submission deadline? Answer with the date only, in YYYY-MM-DD format. The call for papers opened on 2 January 2025. Drafts were originally due January 20, but the committee extended the final submission deadline to 7 February 2025. Reviews are due by 28 February, and results will be announced on March 10, 2025.
Warnings and errors from a logNot run
Passes when Only a JSON array of the WARN line and the two ERROR lines, in order, with time, level and message copied exactly.
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-04 09:12:01 INFO server started on port 8080 2025-03-04 09:12:07 WARN config key "timeout" is deprecated 2025-03-04 09:13:44 INFO user alice logged in 2025-03-04 09:15:02 ERROR database connection lost 2025-03-04 09:15:03 INFO retrying in 5s 2025-03-04 09:15:08 INFO database reconnected 2025-03-04 09:20:30 DEBUG cache hit ratio 0.93 2025-03-04 09:31:12 ERROR payment webhook returned 502
Following instructions 0 of 5
Exactly one wordNot run
Passes when Exactly OK, with nothing else, not even a full stop.
Reply with exactly the word OK and nothing else.
Three lowercase linesNot run
Passes when Exactly three lines about the sea, all lowercase, the third ending with a question mark.
Write exactly three lines about the sea. Every line must be entirely lowercase, and the third line must end with a question mark. Output only the three lines.
Exact JSON shapeNot run
Passes when Only JSON with exactly two keys: colors (three lowercase color names) and count (the number 3).
Return a JSON object with exactly two keys: "colors", a list of exactly three color names in lowercase, and "count", the number 3. Output only the JSON.
Sort a listNot run
Passes when One line: apple, apricot, banana, cherry, pear (any capitalization).
Sort these words alphabetically, ignoring case, and output them on one line separated by commas: pear, Apple, banana, cherry, apricot
A name with three rulesNot run
Passes when Two words, both capitalized, with no letter e anywhere.
Suggest a product name for a solar-powered lamp. Rules: exactly two words, both capitalized, and the letter "e" must not appear anywhere. Output only the name.
Reasoning 5 of 5
Unit pricePassed
705 tokens: 58 read, 647 written · 49 s · 13.4 tok/s
A shop sells pencils at 5 for $1.50. How much do 19 pencils cost, in dollars? Work it out, then end with a line "ANSWER: <number>".
To find the cost of 19 pencils, we first determine the price of a single pencil. 1. **Find the cost per pencil:** The shop sells 5 pencils for $1.50. Cost per pencil = $1.50 ÷ 5 = $0.30 2. **Calculate the cost for 19 pencils:** Total cost = Cost per pencil × Number of pencils Total cost = $0.30 × 19 3. **Perform the multiplication:** $0.30 × 10 = $3.00 $0.30 × 9 = $2.70 $3.00 + $2.70 = $5.70 Alternatively, you can calculate it by finding the cost of 20 pencils and subtracting the cost of one: Cost of 20 pencils (4 sets of 5) = 4 × $1.50 = $6.00 Cost of 19 pencils = $6.00 - $0.30 = $5.70 ANSWER: 5.70Days of the weekPassed
820 tokens: 52 read, 768 written · 58 s · 13.4 tok/s
Today is Thursday. What day of the week will it be 293 days from today? Work it out, then end with a line "ANSWER: <day>".
To find out what day of the week it will be 293 days from today, we can use the fact that the days of the week repeat every 7 days. 1. **Divide the total number of days by 7 to find the remainder:** $293 \div 7$ $293 = 7 \times 41 + 6$ The remainder is 6. 2. **Count forward from the current day (Thursday) by the remainder:** * Day 1: Friday * Day 2: Saturday * Day 3: Sunday * Day 4: Monday * Day 5: Tuesday * Day 6: Wednesday Alternatively, adding 6 days is the same as subtracting 1 day from the current day: Thursday - 1 day = Wednesday. ANSWER: WednesdayWho owns the catPassed
396 tokens: 72 read, 324 written · 25 s · 13.5 tok/s
Ben, Ana and Lea each own exactly one pet: a cat, a dog or a fish, all different. Ana does not own the dog. Lea owns the fish. Who owns the cat? Work it out, then end with a line "ANSWER: <name>".
Lea owns the fish. Since Lea owns the fish, the remaining pets are the cat and the dog, and the remaining people are Ben and Ana. Ana does not own the dog, so she must own the cat. This leaves the dog for Ben. ANSWER: Ana
Arrival timePassed
579 tokens: 70 read, 509 written · 39 s · 13.5 tok/s
A train leaves at 18:45 and the trip takes 2 hours 45 minutes. At what time does it arrive? Work it out, then end with a line "ANSWER: <HH:MM>" in 24-hour time.
To find the arrival time, add the trip duration to the departure time: 1. **Start with the departure time:** 18:45 2. **Add the hours:** 18:45 + 2 hours = 20:45 3. **Add the minutes:** 20:45 + 45 minutes * Adding 15 minutes to 20:45 brings the time to 21:00. * There are 30 minutes remaining from the 45 minutes (45 - 15 = 30). * Adding the remaining 30 minutes to 21:00 brings the time to 21:30. ANSWER: 21:30Filling a tankPassed
1,091 tokens: 96 read, 995 written · 1 min 15 s · 13.4 tok/s
A tank holds 120 liters. Pipe A alone fills it in 10 hours, pipe B alone fills it in 12 hours, and a drain alone empties a full tank in 10 hours. With all three open and the tank starting empty, how many hours until it is full? Work it out, then end with a line "ANSWER: <number>".
To find the time it takes to fill the tank, we first determine the rate at which each pipe and the drain operate. 1. **Calculate the rates of each pipe and the drain:** * The tank capacity is 120 liters. * **Pipe A** fills the tank in 10 hours: Rate of A = 120 liters / 10 hours = 12 liters/hour. * **Pipe B** fills the tank in 12 hours: Rate of B = 120 liters / 12 hours = 10 liters/hour. * **The drain** empties the tank in 10 hours: Rate of Drain = 120 liters / 10 hours = 12 liters/hour. 2. **Calculate the net rate when all three are open:** Since Pipe A and Pipe B are filling the tank and the drain is emptying it, the net rate is: Net Rate = Rate of A + Rate of B - Rate of Drain Net Rate = 12 liters/hour + 10 liters/hour - 12 liters/hour Net Rate = 10 liters/hour. 3. **Calculate the time to fill the tank:** Time = Total Capacity / Net Rate Time = 120 liters / 10 liters/hour Time = 12 hours. Alternatively, using fractions of the tank per hour: * Pipe A fills 1/10 of the tank per hour. * Pipe B fills 1/12 of the tank per hour. * The drain empties 1/10 of the tank per hour. * Net rate = 1/10 + 1/12 - 1/10 = 1/12 of the tank per hour. * Time to fill = 1 / (1/12) = 12 hours. ANSWER: 12
Reading code 4 of 4
What does it printPassed
1,038 tokens: 85 read, 953 written · 1 min 12 s · 13.4 tok/s
What does this Python program print? Work it out, then end with a line "ANSWER: <output>". def f(xs): return sorted(xs)[::-1][:2] print(f([31, 24, 16, 13, 14, 40]))To determine the output of the Python program, let's follow the execution step-by-step: 1. **Function Definition**: The function `f(xs)` is defined. It takes a list `xs` and performs three operations: * `sorted(xs)`: Sorts the list in ascending order. * `[::-1]`: Reverses the sorted list (resulting in a descending order). * `[:2]`: Slices the first two elements of the resulting list. 2. **Function Call**: The function is called with the list `[31, 24, 16, 13, 14, 40]`. 3. **Step-by-Step Execution**: * **`sorted([31, 24, 16, 13, 14, 40])`**: The list is sorted in ascending order. Result: `[13, 14, 16, 24, 31, 40]` * **`[13, 14, 16, 24, 31, 40][::-1]`**: The sorted list is reversed. Result: `[40, 31, 24, 16, 14, 13]` * **`[40, 31, 24, 16, 14, 13][:2]`**: The first two elements of the reversed list are sliced. Result: `[40, 31]` 4. **Final Output**: The `print()` function outputs the result of the function call. ANSWER: [40, 31]Trace a loopPassed
2,018 tokens: 101 read, 1,917 written · 2 min 25 s · 13.3 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 % 2 == 0 or i % 7 == 0: total += i return total print(g(15))To determine the output of the Python program, let's trace the execution of the function `g(15)`. 1. **Function Definition**: The function `g(n)` calculates the sum of all integers from 1 up to `n` (inclusive) that are divisible by either 2 or 7. 2. **Input**: The function is called with `n = 15`. 3. **Iteration**: The loop `for i in range(1, 16)` iterates through the numbers 1, 2, 3, ..., 15. 4. **Condition Check**: For each number `i`, we check if `i % 2 == 0` (divisible by 2) or `i % 7 == 0` (divisible by 7). * `i = 1`: No * `i = 2`: Yes (divisible by 2) $\rightarrow$ total = 2 * `i = 3`: No * `i = 4`: Yes (divisible by 2) $\rightarrow$ total = 2 + 4 = 6 * `i = 5`: No * `i = 6`: Yes (divisible by 2) $\rightarrow$ total = 6 + 6 = 12 * `i = 7`: Yes (divisible by 7) $\rightarrow$ total = 12 + 7 = 19 * `i = 8`: Yes (divisible by 2) $\rightarrow$ total = 19 + 8 = 27 * `i = 9`: No * `i = 10`: Yes (divisible by 2) $\rightarrow$ total = 27 + 10 = 37 * `i = 11`: No * `i = 12`: Yes (divisible by 2) $\rightarrow$ total = 37 + 12 = 49 * `i = 13`: No * `i = 14`: Yes (divisible by 2 and 7) $\rightarrow$ total = 49 + 14 = 63 * `i = 15`: No 5. **Final Result**: The loop finishes, and the function returns the final `total` of 63. The `print` statement then outputs this returned value. ANSWER: 63Find the bugPassed
733 tokens: 116 read, 617 written · 47 s · 13.4 tok/s
Passes when A final line ANSWER: 6 (it divides by one less than the count).
This function should return the mean of a non-empty list. Which line has the bug? Work it out, then end with a line "ANSWER: <line number>". 1 def average(numbers): 2 """Return the mean of a non-empty list of numbers.""" 3 total = 0 4 for n in numbers: 5 total += n 6 count = len(numbers) - 1 7 return total / count
To find the mean of a list of numbers, you must divide the sum of the numbers by the total count of the numbers. 1. Line 3 initializes `total` to 0. 2. Lines 4 and 5 iterate through the list and correctly calculate the sum of all numbers. 3. Line 6 calculates the `count` as `len(numbers) - 1`. This is incorrect; the count should be the actual length of the list (`len(numbers)`). Subtracting 1 will result in an incorrect mean and will cause a `ZeroDivisionError` if the list contains only one element. 4. Line 7 divides the total by the incorrect count. The bug is on line 6. ANSWER: 6
Run a query in your headPassed
475 tokens: 153 read, 322 written · 25 s · 13.5 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 | 140 2 | ben | 25 3 | cal | 10 4 | ana | 15 5 | ben | 5 6 | cal | 100 Query: SELECT customer, SUM(amount) AS total FROM orders GROUP BY customer HAVING SUM(amount) > 100 ORDER BY total DESC;
ana,155 cal,110
Using tools 5 of 5
Call one toolPassed
421 tokens: 268 read, 153 written · 13 s · 13.4 tok/s
Passes when One get_weather call for Lisbon in celsius, then an answer giving the 21 °C the tool returned.
What's the weather in Lisbon right now, in celsius?
- user
What's the weather in Lisbon right now, in celsius?
- assistant
get_weather({"city":"Lisbon","unit":"celsius"}) - tool
{"city": "Lisbon", "conditions": "sunny", "temperature": 21, "unit": "celsius"} - assistant
The weather in Lisbon is currently sunny with a temperature of 21°C.
- user
Don't call a tool when none is neededPassed
266 tokens: 200 read, 66 written · 6 s · 13.5 tok/s
Passes when No tool call, and the answer is 144.
What is 12 times 12?
- user
What is 12 times 12?
- assistant
12 times 12 is 144.
- user
Two calls for two answersPassed
579 tokens: 368 read, 211 written · 18 s · 13.5 tok/s
Passes when Converts 250 EUR to USD and to JPY in at most three calls, then gives both amounts: 270.50 USD and 40,125 JPY.
Convert 250 EUR to USD and to JPY.
- user
Convert 250 EUR to USD and to JPY.
- assistant
convert_currency({"amount":250,"from":"EUR","to":"USD"})convert_currency({"amount":250,"from":"EUR","to":"JPY"}) - tool
{"amount": 270.5, "currency": "USD"} - tool
{"amount": 40125, "currency": "JPY"} - assistant
250 EUR is approximately 270.50 USD and 40,125 JPY.
- user
Chain two toolsPassed
875 tokens: 574 read, 301 written · 24 s · 13.5 tok/s
Passes when Looks up the customer first, asks for C-1042's orders, then reports A-77 shipped and A-80 processing.
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": [{"carrier": "DHL", "order_id": "A-77", "status": "shipped"}, {"order_id": "A-80", "status": "processing"}]} - assistant
The customer Kim Park (kim@example.com) has two orders: - Order A-77: shipped - Order A-80: processing
- user
Handle a failed call honestlyPassed
569 tokens: 305 read, 264 written · 21 s · 13.5 tok/s
Passes when Tries 19:00 for 2 people, never books another time without asking, does not claim the booking succeeded, and offers 18:30 or 20:30.
Book a table for 2 people at Luigi's tonight at 19:00.
- user
Book a table for 2 people at Luigi's tonight at 19:00.
- assistant
book_table({"people":2,"restaurant":"Luigi's","time":"19:00"}) - tool
{"available_times": ["18:30", "20:30"], "error": "fully booked at that time"} - assistant
I'm sorry, Luigi's is fully booked at 19:00. However, they do have tables available at 18:30 and 20:30. Would either of those work for you?
- user
Building pages 5 of 5
A small websitePassed
1,881 tokens: 128 read, 1,753 written · 2 min 13 s · 13.3 tok/s
Passes when A <header> with an <h1> naming the bakery, a <nav> with exactly 3 links, a <main> with <section id="menu"> holding at least 4 list items, and a <footer> with opening hours. Nothing loaded from another site and no network requests.
Build a one-page website for a bakery called "Crumb & 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; 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.
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>Crumb & Co | Artisan Bakery</title> <style> body { font-family: sans-serif; margin: 0; padding: 0; background-color: #fdfaf6; color: #5d4037; line-height: 1.6; } header { background-color: #8d6e63; color: white; text-align: center; padding: 2rem 0; } h1 { margin: 0; font-size: 3rem; letter-spacing: 2px; } nav { background-color: #6d4c41; display: flex; justify-content: center; padding: 10px 0; } nav a { color: white; text-decoration: none; margin: 0 20px; font-weight: bold; text-transform: uppercase; font-size: 0.9rem; } nav a:hover { text-decoration: underline; } main { max-width: 800px; margin: 40px auto; padding: 0 20px; } #menu { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); text-align: center; } h2 { border-bottom: 2px solid #d7ccc8; padding-bottom: 10px; margin-bottom: 20px; } ul { list-style: none; padding: 0; } li { padding: 15px 0; border-bottom: 1px solid #eee; font-size: 1.2rem; display: flex; justify-content: space-between; } li:last-child { border-bottom: none; } footer { text-align: center; padding: 20px 0; background-color: #efebe9; margin-top: 40px; font-size: 0.9rem; } </style> </head> <body> <header> <h1>Crumb & Co</h1> </header> <nav> <a href="#home">Home</a> <a href="#menu">Menu</a> <a href="#contact">Contact</a> </nav> <main> <section id="home" style="text-align: center; margin-bottom: 40px;"> <p>Welcome to Crumb & Co, where every bite is a piece of heaven. We specialize in traditional sourdough and hand-crafted pastries.</p> </section> <section id="menu"> <h2>Our Daily Menu</h2> <ul> <li><span>Classic Sourdough Loaf</span> <span>$8.00</span></li> <li><span>Butter Croissant</span> <span>$4.50</span></li> <li><span>Pain au Chocolat</span> <span>$5.00</span></li> <li><span>Sea Salt Brownie</span> <span>$3.50</span></li> <li><span>Cinnamon Morning Bun</span> <span>$4.00</span></li> </ul> </section> </main> <footer> <p><strong>Opening Hours:</strong><br> Monday - Friday: 7:00 AM - 6:00 PM<br> Saturday - Sunday: 8:00 AM - 4:00 PM</p> </footer> <script> document.querySelectorAll('nav a').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); document.querySelector(targetId).scrollIntoView({ behavior: 'smooth' }); }); }); </script> </body> </html> ```A pricing table with a togglePassed
2,221 tokens: 98 read, 2,123 written · 2 min 41 s · 13.3 tok/s
Passes when Three elements with class plan, each holding a price, and a <button id="billing-toggle"> handled by script; the page switches between monthly and yearly. Nothing loaded from another site and no network requests.
Build a pricing page with three plans. Each plan is an element with class "plan" containing an element with class "price". 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.
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 Page</title> <style> body { font-family: sans-serif; background-color: #f4f7f6; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; margin: 0; color: #333; } .header { text-align: center; margin-bottom: 30px; } #billing-toggle { padding: 10px 20px; font-size: 16px; cursor: pointer; background-color: #007bff; color: white; border: none; border-radius: 5px; transition: background-color 0.2s; margin-bottom: 40px; } #billing-toggle:hover { background-color: #0056b3; } .plans-container { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; } .plan { background: white; border: 1px solid #ddd; border-radius: 10px; padding: 30px; width: 250px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: transform 0.2s; } .plan:hover { transform: translateY(-5px); } .plan h2 { margin-top: 0; font-size: 24px; } .price { font-size: 48px; font-weight: bold; margin: 20px 0; color: #007bff; } .period { font-size: 16px; color: #777; margin-bottom: 20px; } .features { list-style: none; padding: 0; margin: 0 0 30px 0; text-align: left; } .features li { margin-bottom: 10px; font-size: 14px; } .features li::before { content: "✓ "; color: green; font-weight: bold; } </style> </head> <body> <div class="header"> <h1>Choose Your Plan</h1> <button id="billing-toggle">Switch to Yearly Billing</button> </div> <div class="plans-container"> <div class="plan"> <h2>Basic</h2> <div class="price" data-monthly="$10" data-yearly="$100">$10</div> <div class="period">per month</div> <ul class="features"> <li>1 User</li> <li>10GB Storage</li> <li>Email Support</li> </ul> </div> <div class="plan"> <h2>Pro</h2> <div class="price" data-monthly="$25" data-yearly="$250">$25</div> <div class="period">per month</div> <ul class="features"> <li>5 Users</li> <li>50GB Storage</li> <li>Priority Support</li> </ul> </div> <div class="plan"> <h2>Enterprise</h2> <div class="price" data-monthly="$50" data-yearly="$500">$50</div> <div class="period">per month</div> <ul class="features"> <li>Unlimited Users</li> <li>500GB Storage</li> <li>24/7 Dedicated Support</li> </ul> </div> </div> <script> const toggleBtn = document.getElementById('billing-toggle'); const priceElements = document.querySelectorAll('.price'); const periodElements = document.querySelectorAll('.period'); let isYearly = false; toggleBtn.addEventListener('click', () => { isYearly = !isYearly; // Update button text toggleBtn.textContent = isYearly ? 'Switch to Monthly Billing' : 'Switch to Yearly Billing'; // Update prices and periods priceElements.forEach(priceEl => { const monthlyPrice = priceEl.getAttribute('data-monthly'); const yearlyPrice = priceEl.getAttribute('data-yearly'); priceEl.textContent = isYearly ? yearlyPrice : monthlyPrice; }); periodElements.forEach(periodEl => { periodEl.textContent = isYearly ? 'per year' : 'per month'; }); }); </script> </body> </html> ```An accessible sign-up formPassed
1,343 tokens: 134 read, 1,209 written · 1 min 32 s · 13.3 tok/s
Passes when <form id="signup"> with name, email (type email) and password (type password, minlength 8 or more) inputs, each with a <label for>; a submit button; an element id="status" with role="status"; and script that stops the submit and writes to the status. Nothing loaded from another site and no network requests.
Build a sign-up form: <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. When the form is submitted and valid, prevent the real submission and show a confirmation in an element with id="status" and role="status". 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.
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>Sign Up</title> <style> body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f2f5; } .container { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 100%; max-width: 400px; } form { display: flex; flex-direction: column; gap: 1rem; } .field { display: flex; flex-direction: column; gap: 0.25rem; } label { font-weight: bold; font-size: 0.9rem; } input { padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; } button { padding: 0.75rem; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; font-weight: bold; } button:hover { background-color: #0056b3; } #status { margin-top: 1rem; text-align: center; font-weight: bold; color: #28a745; } </style> </head> <body> <div class="container"> <form id="signup"> <div class="field"> <label for="name">Full Name</label> <input type="text" id="name" name="name" required> </div> <div class="field"> <label for="email">Email Address</label> <input type="email" id="email" name="email" required> </div> <div class="field"> <label for="password">Password</label> <input type="password" id="password" name="password" minlength="8" required> </div> <button type="submit">Sign Up</button> </form> <div id="status" role="status"></div> </div> <script> document.getElementById('signup').addEventListener('submit', function(event) { event.preventDefault(); const status = document.getElementById('status'); const name = document.getElementById('name').value; status.textContent = `Thank you, ${name}! Your account has been created successfully.`; this.reset(); }); </script> </body> </html> ```A to-do app that remembersPassed
1,739 tokens: 121 read, 1,618 written · 2 min 3 s · 13.3 tok/s
Passes when The input, add button and list with the given ids, and script that saves to localStorage under "todos" and adds list items with a remove control. Nothing loaded from another site and no network requests.
Build a to-do list app with 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.
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>To-Do List</title> <style> body { font-family: sans-serif; display: flex; justify-content: center; padding-top: 50px; background-color: #f4f4f9; } .container { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); width: 300px; } .input-group { display: flex; gap: 5px; margin-bottom: 20px; } input { flex-grow: 1; padding: 8px; border: 1px solid #ccc; border-radius: 4px; } button#add { padding: 8px 12px; cursor: pointer; background-color: #28a745; color: white; border: none; border-radius: 4px; } ul { list-style: none; padding: 0; } li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; } .remove-btn { background-color: #dc3545; color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; } </style> </head> <body> <div class="container"> <div class="input-group"> <input type="text" id="new-task" placeholder="Enter a task..."> <button id="add">Add</button> </div> <ul id="tasks"></ul> </div> <script> const input = document.getElementById('new-task'); const addBtn = document.getElementById('add'); const taskList = document.getElementById('tasks'); // Load tasks from localStorage let todos = JSON.parse(localStorage.getItem('todos')) || []; function saveAndRender() { localStorage.setItem('todos', JSON.stringify(todos)); render(); } function render() { taskList.innerHTML = ''; todos.forEach((task, index) => { const li = document.createElement('li'); li.textContent = task; const removeBtn = document.createElement('button'); removeBtn.textContent = 'Remove'; removeBtn.className = 'remove-btn'; removeBtn.onclick = () => { todos.splice(index, 1); saveAndRender(); }; li.appendChild(removeBtn); taskList.appendChild(li); }); } addBtn.onclick = () => { const text = input.value.trim(); if (text !== '') { todos.push(text); input.value = ''; saveAndRender(); } }; // Allow pressing Enter to add input.addEventListener('keypress', (e) => { if (e.key === 'Enter') addBtn.click(); }); // Initial load render(); </script> </body> </html> ```A bar chart in SVGPassed
2,036 tokens: 146 read, 1,890 written · 2 min 23 s · 13.3 tok/s
Passes when Five <rect class="bar"> in an <svg>, written in the markup, with heights proportional to 12, 30, 18, 24 and 6 in that order, labelled Mon to Fri in <text>, and a <title> or aria-label. Nothing loaded from another site and no network requests.
Draw an inline SVG bar chart of coffee sold: Mon 12, Tue 30, Wed 18, Thu 24, Fri 6. Each bar is a <rect class="bar"> whose height attribute is proportional to its value, each bar is labelled with its day in a <text>, and the <svg> has a <title> or an aria-label. Write the bars and labels directly in the SVG markup, not with JavaScript. 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.
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>Coffee Sales Chart</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #fdfdfd; font-family: sans-serif; } .bar { fill: #6f4e37; transition: fill 0.2s; } .bar:hover { fill: #4b3621; } .label { font-size: 14px; text-anchor: middle; fill: #333; } .axis { stroke: #ccc; stroke-width: 1; } </style> </head> <body> <svg width="300" height="200" viewBox="0 0 300 200" aria-label="Bar chart showing coffee sold from Monday to Friday"> <title>Coffee Sold per Day</title> <!-- Baseline --> <line x1="20" y1="170" x2="280" y2="170" class="axis" /> <!-- Scale: 1 unit = 5px Max value: 30 (Tue) -> 150px height Base Y: 170 --> <!-- Monday: 12 * 5 = 60px height. Y = 170 - 60 = 110 --> <rect class="bar" x="40" y="110" width="30" height="60" /> <text x="55" y="190" class="label">Mon</text> <!-- Tuesday: 30 * 5 = 150px height. Y = 170 - 150 = 20 --> <rect class="bar" x="90" y="20" width="30" height="150" /> <text x="105" y="190" class="label">Tue</text> <!-- Wednesday: 18 * 5 = 90px height. Y = 170 - 90 = 80 --> <rect class="bar" x="140" y="80" width="30" height="90" /> <text x="155" y="190" class="label">Wed</text> <!-- Thursday: 24 * 5 = 120px height. Y = 170 - 120 = 50 --> <rect class="bar" x="190" y="50" width="30" height="120" /> <text x="205" y="190" class="label">Thu</text> <!-- Friday: 6 * 5 = 30px height. Y = 170 - 30 = 140 --> <rect class="bar" x="240" y="140" width="30" height="30" /> <text x="255" y="190" class="label">Fri</text> </svg> </body> </html> ```
Building games 1 of 2
Build 2048Passed
12,207 tokens: 467 read, 11,740 written · 15 min 11 s · 12.9 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. [4, 0, 0, 32] [16, 0, 2, 0] [0, 4, 8, 0] [0, 0, 16, 4] 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
```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>2048 Game</title> <style> body { background-color: #faf8ef; color: #776e65; font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } #game-container { position: relative; padding: 20px; background-color: #bbada0; border-radius: 6px; } #score-container { font-size: 24px; font-weight: bold; margin-bottom: 10px; text-align: right; width: 400px; } #board { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 15px; width: 400px; height: 400px; } .cell { width: 80px; height: 80px; background-color: rgba(238, 228, 218, 0.35); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 35px; font-weight: bold; transition: background-color 0.1s, color 0.1s; } .cell-0 { background-color: rgba(238, 228, 218, 0.35); color: transparent; } .cell-2 { background-color: #eee4da; color: #776e65; } .cell-4 { background-color: #ede0c8; color: #776e65; } .cell-8 { background-color: #f2b179; color: #f9f6f2; } .cell-16 { background-color: #f59563; color: #f9f6f2; } .cell-32 { background-color: #f67c5f; color: #f9f6f2; } .cell-64 { background-color: #f65e3b; color: #f9f6f2; } .cell-128 { background-color: #edcf72; color: #f9f6f2; font-size: 30px; } .cell-256 { background-color: #edcc61; color: #f9f6f2; font-size: 30px; } .cell-512 { background-color: #edcc61; color: #f9f6f2; font-size: 30px; } .cell-1024 { background-color: #edcc61; color: #f9f6f2; font-size: 25px; } .cell-2048 { background-color: #edcc61; color: #f9f6f2; font-size: 25px; } #game-over { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(238, 228, 218, 0.73); display: none; flex-direction: column; align-items: center; justify-content: center; border-radius: 6px; font-size: 40px; font-weight: bold; z-index: 10; } </style> </head> <body> <div id="score-container">Score: <span id="score">0</span></div> <div id="game-container"> <div id="board"></div> <div id="game-over">Game Over!</div> </div> <script id="game"> function createGame() { let state = { board: [ [4, 0, 0, 32], [16, 0, 2, 0], [0, 4, 8, 0], [0, 0, 16, 4] ], score: 0, over: false }; const transpose = (b) => b[0].map((_, i) => b.map(row => row[i])); const revRows = (b) => b.map(row => [...row].reverse()); const equalArrays = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]); const boardsEqual = (b1, b2) => b1.every((row, i) => equalArrays(row, b2[i])); function slideAndMerge(row) { let filtered = row.filter(x => x !== 0); let merged = []; let scoreGain = 0; for (let i = 0; i < filtered.length; i++) { if (i < filtered.length - 1 && filtered[i] === filtered[i + 1]) { let val = filtered[i] * 2; merged.push(val); scoreGain += val; i++; } else { merged.push(filtered[i]); } } while (merged.length < 4) merged.push(0); return { row: merged, scoreGain }; } function fillFirstEmpty(board) { for (let r = 0; r < 4; r++) { for (let c = 0; c < 4; c++) { if (board[r][c] === 0) { board[r][c] = 2; return; } } } } function wouldMoveChange(board, dir) { let rows; if (dir === 'left') rows = board; else if (dir === 'right') rows = revRows(board); else if (dir === 'up') rows = transpose(board); else if (dir === 'down') rows = revRows(transpose(board)); for (let row of rows) { let { row: mergedRow } = slideAndMerge(row); if (!equalArrays(row, mergedRow)) return true; } return false; } function checkOver(board) { return !(['left', 'right', 'up', 'down'].some(dir => wouldMoveChange(board, dir))); } // Initial setup: put 2 in first two empty cells in reading order let filled = 0; for (let r = 0; r < 4 && filled < 2; r++) { for (let c = 0; c < 4 && filled < 2; c++) { if (state.board[r][c] === 0) { state.board[r][c] = 2; filled++; } } } state.over = checkOver(state.board); return { move: function(dir) { if (state.over) return; let currentBoard = state.board.map(row => [...row]); let rows; if (dir === 'left') rows = currentBoard; else if (dir === 'right') rows = revRows(currentBoard); else if (dir === 'up') rows = transpose(currentBoard); else if (dir === 'down') rows = revRows(transpose(currentBoard)); let newRows = []; let scoreGain = 0; for (let row of rows) { let { row: mergedRow, scoreGain: gain } = slideAndMerge(row); newRows.push(mergedRow); scoreGain += gain; } let newBoard; if (dir === 'left') newBoard = newRows; else if (dir === 'right') newBoard = revRows(newRows); else if (dir === 'up') newBoard = transpose(newRows); else if (dir === 'down') newBoard = transpose(revRows(newRows)); if (!boardsEqual(state.board, newBoard)) { state.board = newBoard; state.score += scoreGain; fillFirstEmpty(state.board); state.over = checkOver(state.board); } }, state: function() { return { board: state.board.map(row => [...row]), score: state.score, over: state.over }; } }; } </script> <script> const game = createGame(); const boardEl = document.getElementById('board'); const scoreEl = document.getElementById('score'); const overEl = document.getElementById('game-over'); function render() { const { board, score, over } = game.state(); boardEl.innerHTML = ''; for (let r = 0; r < 4; r++) { for (let c = 0; c < 4; c++) { const val = board[r][c]; const cell = document.createElement('div'); cell.className = `cell cell-${val}`; cell.textContent = val === 0 ? '' : val; boardEl.appendChild(cell); } } scoreEl.textContent = score; overEl.style.display = over ? 'flex' : 'none'; } window.addEventListener('keydown', (e) => { if (e.key === 'ArrowUp') game.move('up'); else if (e.key === 'ArrowDown') game.move('down'); else if (e.key === 'ArrowLeft') game.move('left'); else if (e.key === 'ArrowRight') game.move('right'); render(); }); render(); </script> </body> </html> ```Build SnakeCut off at the app's length limitFailed
131,072 tokens: 463 read, 130,609 written · 3 h 50 min · 9.4 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, 6], [5, 5], [5, 4]], moving down, food at [4, 0], 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>.
Writing code 2 of 3
Merge intervalsPassed
1,781 tokens: 164 read, 1,617 written · 2 min 3 s · 13.3 tok/s
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.
```js function mergeIntervals(intervals) { if (intervals.length === 0) { return []; } // Create a shallow copy of the array and sort it by the start value // to avoid mutating the original input array. const sorted = intervals.slice().sort((a, b) => a[0] - b[0]); const merged = []; // Initialize the current interval with a copy of the first sorted interval let current = [...sorted[0]]; for (let i = 1; i < sorted.length; i++) { const next = sorted[i]; // If the next interval starts before or exactly when the current one ends, they overlap or touch. if (next[0] <= current[1]) { // Merge by extending the end of the current interval to the maximum end value seen. current[1] = Math.max(current[1], next[1]); } else { // No overlap: push the completed current interval and move to the next. merged.push(current); current = [...next]; } } // Push the final interval remaining after the loop. merged.push(current); return merged; } ```An LRU cachePassed
1,382 tokens: 176 read, 1,206 written · 1 min 32 s · 13.3 tok/s
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.
```js class LRUCache { constructor(capacity) { this.capacity = capacity; this.cache = new Map(); } get(key) { if (!this.cache.has(key)) { return -1; } // To mark as most recently used, we remove it and re-insert it const value = this.cache.get(key); this.cache.delete(key); this.cache.set(key, value); return value; } put(key, value) { if (this.cache.has(key)) { this.cache.delete(key); } this.cache.set(key, value); if (this.cache.size > this.capacity) { // Map.prototype.keys() returns an iterator in insertion order. // The first element is the least recently used. const firstKey = this.cache.keys().next().value; this.cache.delete(firstKey); } } } ```Evaluate arithmeticCut off at the app's length limitFailed
131,072 tokens: 200 read, 130,872 written · 3 h 52 min · 9.4 tok/s
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 2 of 2
Fix the bookings modulePassed
2,008 tokens: 707 read, 1,301 written · 1 min 42 s · 13.2 tok/s
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.```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 === 5 || weekday === 6 ? rates.weekend : rates.weekday; } return total; } ```Fix the CSV readerPassed
2,032 tokens: 545 read, 1,487 written · 1 min 55 s · 13.2 tok/s
This JavaScript module has one bug. A line that ends with a comma loses its last, empty field, so the next column's values shift. 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.```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; } } 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); } ```
Planning and data 3 of 3
A query over hidden dataPassed
1,061 tokens: 249 read, 812 written · 1 min 2 s · 13.3 tok/s
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: For each city, the total value (quantity times price_cents, summed) of the items in delivered orders placed in 2024. Columns: city, total. Highest total first. Leave out cities with no such items. Reply with only the query, in one ```sql code block: one SELECT statement (WITH is fine), nothing that changes the database.```sql SELECT c.city, SUM(i.quantity * i.price_cents) AS total FROM customers c JOIN orders o ON c.id = o.customer_id JOIN items i ON o.id = i.order_id WHERE o.status = 'delivered' AND o.placed LIKE '2024%' GROUP BY c.city ORDER BY total DESC; ```
Schedule five meetingsPassed
7,256 tokens: 276 read, 6,980 written · 8 min 56 s · 13.1 tok/s
Five people each have one meeting today: Ana, Dev, Hal, Kim, Max. 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: Cedar, Elm, Oak, Pine, Willow. 1. Dev's and Hal's rooms are not next to each other on the list of rooms. 2. Whoever is in Elm meets earlier than Ana. 3. Kim meets before lunch (before 13:00). 4. Hal meets earlier than Kim. 5. Dev is not in Willow. 6. Whoever is in Oak meets earlier than Hal. 7. Dev meets neither first nor last. 8. Whoever is in Cedar meets earlier than Kim. 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
Ana: 14:00, Willow Dev: 13:00, Pine Hal: 10:00, Cedar Kim: 11:00, Elm Max: 09:00, Oak
A replacement in ten calls or fewerPassed
8,599 tokens: 7,321 read, 1,278 written · 1 min 46 s · 13.2 tok/s
Passes when Looks up the account, opens order R-5530 (the kettle), checks north then south and stops, reserves one steel kettle at south for R-5530, opens a damage claim (a return, if tried, is refused), makes at most 10 calls, and tells the customer claim CL-2207 and that the replacement ships on 3 November, without claiming a return label.
Hi, it's ana.silva@example.com. My kettle arrived with a cracked lid. Can you sort it out?
- system
You are the support agent of Tidewell Home, working through its tools. When an item arrives damaged: confirm which order it came in, send a replacement from the north warehouse if it has the item, else from south, else from east (check each in that order, and only as far as needed), and take the damaged item back with a return. Then reply to the customer with what you did, giving any reference numbers and the date the replacement ships.
- user
Hi, it's ana.silva@example.com. My kettle arrived with a cracked lid. Can you sort it out?
- assistant
lookup_account({"email":"ana.silva@example.com"}) - tool
{"account_id": "AC-311", "name": "Ana Silva"} - assistant
list_orders({"account_id":"AC-311"}) - tool
{"orders": [{"order_id": "R-5521", "placed": "2026-10-02", "status": "delivered"}, {"order_id": "R-5530", "placed": "2026-10-09", "status": "delivered"}, {"order_id": "R-5544", "placed": "2026-10-20", "status": "in transit"}]} - assistant
get_order({"order_id":"R-5521"})get_order({"order_id":"R-5530"}) - tool
{"items": [{"name": "Oak table lamp", "quantity": 1, "sku": "lamp-oak"}], "order_id": "R-5521"} - tool
{"items": [{"name": "Steel kettle", "quantity": 1, "sku": "kettle-steel"}, {"name": "Grey mug", "quantity": 2, "sku": "mug-grey"}], "order_id": "R-5530"} - assistant
check_stock({"sku":"kettle-steel","warehouse":"north"}) - tool
{"available": 0, "sku": "kettle-steel", "warehouse": "north"} - assistant
check_stock({"sku":"kettle-steel","warehouse":"south"}) - tool
{"available": 4, "sku": "kettle-steel", "warehouse": "south"} - assistant
reserve_item({"order_id":"R-5530","sku":"kettle-steel","warehouse":"south"})create_return({"order_id":"R-5530","reason":"cracked lid"}) - tool
{"reservation_id": "RS-4410", "ships_on": "2026-11-03"} - tool
{"error": "damaged items are not returned: open a damage claim with open_claim instead"} - assistant
open_claim({"order_id":"R-5530","reason":"cracked lid"}) - tool
{"claim_id": "CL-2207", "order_id": "R-5530", "status": "open"} - assistant
I've sorted that out for you. I've arranged for a replacement Steel kettle from our south warehouse (Reference: RS-4410), which is scheduled to ship on 2026-11-03. I have also opened a damage claim (Reference: CL-2207) for the item from your order R-5530.
- system
Comments
Sign in or create an account to comment.