On iPhone or iPad, open Safari’s Share menu and choose Add to Home Screen. On desktop, use your browser’s install or Add to Dock command if available.
Lessons are available offline on this device.
You’re offline.
A course update is ready.
A community center wants a bicycle loan checker for weekend visitors.
Correct answer Approve a visitor bicycle loan only when freeBikes > 0 and the visitor holds a valid photo ID
Option B names the actor, action, and two exact measurable conditions (freeBikes > 0 and valid photo ID); A and C omit the approval rule.
A campus print kiosk receives a student ID and page count, checks the student’s remaining print quota, and returns Approved or Declined.
Correct answer Request input: page count · Stored state: remaining quota · Output: Approved or Declined
Page count arrives with the request, remaining quota is stored prior state, and Approved/Declined is the returned decision output.
A parking meter accepts whole minutes from 0 to 120 inclusive. Policy: values outside 0..120 return INVALID_MINUTES; valid values >= 15 issue a ticket, and 0..14 return TOO_SHORT.
Correct answer 0 → TOO_SHORT (valid domain), -5 → INVALID_MINUTES (out of range)
0 is inside the inclusive domain [0, 120] and maps to TOO_SHORT, whereas -5 lies outside the domain and triggers INVALID_MINUTES.
A museum audio-guide desk wants to hand out devices only when stock > 0, limit devices to 1 per ticket, and display the remaining count in bold dark green.
Correct answer Display the remaining count in bold dark green
Font weight and color styling are presentation details that do not alter whether a device handover is approved.
A science lab loans a microscope only when the kit is inspected (inspected = true) AND the student completed safety training (trained = true).
Correct answer (inspected=true, trained=true) → true vs. (inspected=true, trained=false) → false
Holding inspected=true constant while toggling trained from true to false isolates the safety-training condition cleanly.
A locker bank starts with freeLockers = 1. Request A arrives and succeeds. Request B arrives immediately after. Then Request A’s student returns their key.
Correct answer 0, 0, 1 (Request B is declined and leaves state unchanged)
Request A reduces freeLockers from 1 to 0; Request B is declined so freeLockers stays 0; returning the key restores it to 1.
A school bus pass is discounted for riders aged 12 or younger (age <= 12).
Correct answer age = 12 → expected discounted (true)
Both age < 12 and age <= 12 agree on 11 and 13; only the exact cutoff age = 12 exposes the missing equality sign.
You discover an edge case where a user submits an empty string "" as a room code.
Correct answer 1. Name exact input ("") → 2. Declare invalid-input policy → 3. Record pass/fail check in contract
You must name the concrete input and agree on the invalid-input policy before locking the expected pass/fail check.
A dorm laundry spec states: "Residents may book a washer whenever one is free" and "Washers are closed after 22:00."
Correct answer Explicit precedence stating closing-hours decline overrides machine availability, plus the 22:15 → Decline check
Explicit rule precedence plus a concrete overlap case (22:15 → Decline) resolves the contradiction deterministically.
A locker kiosk unlocks a temporary gym locker using a scanned campus badge.
Correct answer 1. Read badge ID → 2. Check badge status → 3. If active, unlock locker; else decline
The kiosk must read the badge and check its status before deciding whether to unlock the locker.
A museum grants free youth entry to visitors under 18 years old (strictly less than 18).
Correct answer age < 18 → age 18 pays regular admission
"Under 18" is a strict upper bound (`age < 18`), so a visitor aged 18 is excluded from free entry.
An elevator opens on the roof deck only when `isStaff && !isWindAlert`.
Correct answer false — `!isWindAlert` becomes false, so AND fails
`!true` evaluates to `false`, and `true && false` evaluates to `false`.
Shipping tiers: `>= 100` → Express Free, `>= 50` → Standard Free, `< 50` → Paid. Someone wrote `if (total >= 50) return "Standard Free"; else if (total >= 100) return "Express Free";`.
Correct answer It wrongly returns "Standard Free"; check `total >= 100` first, then `total >= 50`
Because `120 >= 50` matches first, the `>= 100` branch is unreachable unless ordered from highest threshold to lowest.
A clinic intake flowchart first asks "Has appointment?". If Yes, it asks "Arrived on time?". Only Yes → Yes assigns a room; every other path asks the patient to check in at reception.
Correct answer hasAppointment && arrivedOnTime
When both nested conditions must be true for the sole success path and all other paths share one rejection action, AND is equivalent.
A ticket validator checks `if (isExpired) return "Reject";` and has no `else` branch for valid tickets.
Correct answer An open-ended branch: when `isExpired` is false, the flow never returns a defined decision
Every possible input path must terminate in an explicit output; the false branch was left unhandled.
A print spooler runs `while (pagesLeft > 0) { printOne(); pagesLeft = pagesLeft - 1; }`.
Correct answer 0 passes when starting at 0; 3 passes when starting at 3
A pre-test `while (pagesLeft > 0)` loop checks before running: 0 > 0 is immediately false (0 passes), while 3 runs for 3, 2, 1 (3 passes).
A student scans a tray of 5 envelopes looking for "Invoice #42" with `while (remaining > 0)` but forgets to decrement `remaining` inside the loop.
Correct answer An infinite loop — `remaining > 0` stays true forever because no state moves toward stopping
Without decrementing `remaining`, a missing target means the stopping condition is never reached.
Variables start as `left = "Room A"` and `right = "Room B"`. Code runs `left = right; right = left;`.
Correct answer Both become "Room B" because "Room A" was overwritten without a temporary variable
`left = right` immediately overwrites `"Room A"` with `"Room B"`, so `right = left` simply copies `"Room B"` back.
A form input returns `seats = "12"` as text, and a buggy checker adds `seats + 1` in JavaScript without converting to an integer.
Correct answer It produces `"121"` (string concatenation); validate or parse into an integer before math
In JavaScript, `+` with a string concatenates text (`"12" + 1 === "121"`). Explicit integer checks prevent silent type bugs.
A weather sensor logs three readings: Station 1 reports `0` °C, Station 2 reports `""`, Station 3 has `null` (offline).
Correct answer `0` is a valid freezing temperature, `""` is empty text, and `null` means missing data
Zero is a real numeric measurement, an empty string is blank text, and null represents absent data.
A helper counts how many badges in `badges = []` are active by initializing `count = 0` and looping over each item.
Correct answer It cleanly returns `0`; reading `badges[0]` directly crashes or returns undefined on an empty list
An empty list causes 0 loop iterations and cleanly returns the initial `count = 0`; direct index `[0]` access fails when length is 0.
Scores list is `[45, 70, 60, 88]`. A filter keeps scores `>= 60`, and a counter counts passing scores.
Correct answer Filtered list: `[70, 60, 88]` · Count: `3`
Because the threshold is inclusive (`>= 60`), 70, 60, and 88 all qualify in their original order (count = 3).
A campus directory maps 400 room codes (`"B-204"`) to seat counts. Unknown room codes should return `0` seats instead of throwing a lookup error.
Correct answer Key-value map with safe default lookup (e.g., `rooms.get(code, 0)` / `rooms[code] ?? 0`)
A map looks up keys directly by room code and a safe default (`0`) prevents crashes on unknown rooms.
Two teammates wrote `checkPass(score)`. Version A prints `"Pass"` directly to the console and returns nothing. Version B returns boolean `true` or `false`.
Correct answer Returning a typed value separates calculation from display so unit tests can assert the return value directly
Returning a boolean lets automated tests and any UI format the result however they need.
Function `promote(waitlist, seats)` calls `waitlist.shift()` inside the function, erasing items from the caller’s original array.
Correct answer Build and return a brand-new promoted list without mutating the input `waitlist`
Returning a fresh array leaves caller state intact so calling the function twice with the same inputs produces identical results.
You are writing pseudocode for `canRentBike(freeBikes)` where negative inputs must return `INVALID_BIKES` before checking `freeBikes > 0`.
Correct answer IF freeBikes < 0 THEN return ERROR "INVALID_BIKES" · ELSE return freeBikes > 0
Input validation must run before the main return statement so invalid values are caught immediately.
Pseudocode: `SET count = 0; FOR EACH seat IN [true, false, true, true]: IF seat == true THEN count = count + 1; RETURN count`.
Correct answer 3
Three items in `[true, false, true, true]` equal `true`, incrementing `count` from 0 to 3.
Look at these three return signatures for `canBook(freeSeats)`: 1) `def can_book(free_seats: int) -> bool:` 2) `function canBook(freeSeats)` 3) `func canBook(freeSeats int) bool`
Correct answer 1: Python · 2: JavaScript · 3: Go
`def ... -> bool:` is Python, `function name(...)` is JavaScript, and `func name(arg int) bool` is Go.
Python returns `False` for `can_book(0)` while JavaScript returns `true` for `canBook(0)`. Both return `true` for `1` and `2`.
Correct answer Contract drift: JavaScript likely used `freeSeats >= 0` instead of `freeSeats > 0`
Boundary input `0` immediately exposes an off-by-one `>= 0` vs `> 0` drift between the two ports.
You need to write the compound rule "seat is free AND not locked" in Python, JavaScript, and Go.
Correct answer Python: `is_free and not is_locked` · JS & Go: `isFree && !isLocked`
Python uses lowercase `and`/`or`/`not`, whereas JavaScript and Go use `&&`/`||`/`!`.
In Go, a learner writes `for i := range items` to sum positive integers in `items = []int{3, -1, 5}`.
Correct answer `i` is the index (0, 1, 2); use `for _, value := range items` to read each item directly
In Go, the first variable of `range` is always the index; use `for _, value := range items` to read element values.
A map `seats = {"A": 0}` is queried for key `"A"` in JavaScript using `seats["A"] || -1` versus `seats["A"] ?? -1`.
Correct answer `||` treats valid `0` as falsy and returns `-1`; `??` only falls back on `null` or `undefined` and preserves `0`
Nullish coalescing (`??`) preserves valid `0` and `false` values, whereas logical OR (`||`) overwrites them with the fallback.
In Python, `isinstance(True, int)` returns `True` because `bool` is a subclass of `int`.
Correct answer Check `isinstance(free_seats, bool) or not isinstance(free_seats, int) or free_seats < 0`
Explicitly rejecting `isinstance(x, bool)` before `isinstance(x, int)` stops `True`/`False` from slipping through as `1`/`0`.
You are briefing an AI coding agent to add a negative-input guard to `canLoanEquipment` in `src/loan.js`.
Correct answer Edit only `src/loan.js` and `tests/loan.test.js`: reject empty `itemCode` with `INVALID_LOAN_INPUT`, keep existing tests passing, and run `npm test`
Naming the exact file scope, explicit error code (`INVALID_LOAN_INPUT`), and test command gives the agent a checkable specification.
Task scope: fix the `>= 60` cutoff in `src/quiz.ts` and add a boundary test for `score = 60`.
Correct answer Rename all CSS theme variables and reformat 14 unrelated UI components
Renaming CSS variables and reformatting 14 unrelated UI files has nothing to do with the `>= 60` rule and makes diff review harder.
Before letting an AI agent edit your repository, you prepare context and review its plan.
Correct answer 1. Provide exact rule, target file, and boundary cases → 2. Read the agent’s plan & out-of-scope list → 3. Approve edit
Supplying minimal relevant context and checking the agent’s plan before edits catches scope creep and wrong assumptions early.
The agent’s plan says: "If `openSeats` is negative, I will clamp it to `0` and return `[]`." Your contract requires returning `INVALID_WAITLIST_INPUT`.
Correct answer Correct the hidden assumption in the plan so negative `openSeats` explicitly returns `INVALID_WAITLIST_INPUT`
Fixing a silent clamping assumption in the plan takes seconds and avoids writing code that contradicts the contract.
A bug report shows `canBookGroup(4, 0, true)` wrongly returns `true` instead of `INVALID_GROUP_BOOKING`.
Correct answer 1. Add test for `(4, 0, true)` → 2. Run test and observe red failure → 3. Add `requestedSeats < 1` guard → 4. Rerun full suite green
Seeing the new test fail red before editing proves the test actually exercises the bug; seeing the full suite turn green afterward proves the fix.
An agent reports "All tests pass!" You read the diff: `- assert.throws(() => canBook(-1), /INVALID_FREE_SEATS/); + assert.equal(canBook(-1), false);`
Correct answer Silent test weakening: the agent changed the contract assertion instead of fixing the missing negative-input guard
Changing an expected `INVALID_FREE_SEATS` error into `false` weakens the contract test instead of fixing the buggy function.
You asked to update the passing cutoff from `60` to `65` in Python and JavaScript. The diff updates `quiz.py` to `65`, leaves `quiz.js` at `60`, and reformats `README.md`.
Correct answer Cross-file contract drift (`quiz.js` still uses 60) and out-of-scope edit (`README.md` formatting)
Both sibling implementations must stay synchronized at `65`, and unrelated `README.md` edits should be reverted out of the patch.
Compare Commit X ("Fix zero-seat boundary in canBookRoom and add regression test" — 2 files) vs Commit Y ("misc updates" — 19 files mixing bug fix, UI color tweak, and dependency bump).
Correct answer It is atomic, explains the exact behavior change, and can be reverted cleanly without undoing unrelated work
Small atomic commits isolate one logical change so teammates can review, audit, or revert it cleanly.
A shuttle van holds between `1` and `12` riders inclusive (`1 <= riders <= 12`).
Correct answer `0, 1, 2` (lower edge) and `11, 12, 13` (upper edge)
Testing `0, 1, 2` checks the inclusive lower bound `1`, and `11, 12, 13` checks the inclusive upper bound `12`.
You wrote a list-average helper `countPassing(scores)` with tests only for `[70, 80, 90]`.
Correct answer Empty list `[]`, single-item `[60]`, and wrong type `"60"` or negative `[-5]` per policy
Empty lists, single-element lists, and invalid-type/negative cases catch initialization and validation bugs that typical 3-item lists hide.
A teammate sends a bug message in chat about `canCheckoutBook`.
Correct answer Input `(isAvailable=true, borrowedCount=3)` · Expected `false` · Actual `true` (failed at `borrowedCount <= 3`)
Naming exact input, expected result, and actual result lets any teammate reproduce the bug in seconds.
A test assertion fails with: `Expected: "ELIGIBLE" (string) Actual: "WARNING" (string) Input: checkAttendance(4, 5)`
Correct answer Either strict `> 80%` instead of `>= 80%`, or `>= 60%` was checked before `>= 80%`
Both outputs are strings, so it is a threshold/branch-order logic bug at exact 80% (`4/5`).
`scoreQuiz(["A","B","C"], ["A","B","C"])` returned `2` because the loop stopped at `i < key.length - 1`.
Correct answer Change to `i < key.length` and rerun ALL fixtures (partial, shifted, empty, full, and unequal-length invalid)
Fixing the stop bound to `i < key.length` checks the final index, and rerunning the full fixture suite confirms no neighbors broke.
After running a test command, the console prints: `Ran 0 tests in 0.001s — OK (exit code 0)`.
Correct answer No — 0 tests executed! Fix test discovery/naming until the exact regression test runs and shows a non-zero pass count
Zero tests executed proves nothing even when exit code is 0; real verification requires seeing the targeted checks execute.
Your local suite ran Node.js tests and passed. In CI, the job fails with `Error: Cannot find module "./fixtures.json"` and Go is not installed on the runner.
Correct answer Commit the untracked `fixtures.json`, rerun CI, and report Node/Python executed results separately from unexecuted Go
Missing committed files cause CI-only `Cannot find module` errors, and runtimes that did not run must be reported explicitly as unexecuted.
You finished a small bug fix and want to merge it safely to `main`.
Correct answer 1. Local tests & build pass → 2. Push & verify green CI → 3. Review diff for scope & assertion integrity → 4. Merge
Local verification, green clean-environment CI, and human diff review together form a reliable merge gate.
Contract `canBookGroup(freeSeats, requestedSeats, hasPermission)`: valid if `freeSeats >= 0`, `requestedSeats >= 1`, `hasPermission` boolean; returns `hasPermission && requestedSeats <= freeSeats`.
Correct answer `true`, `false`, `INVALID_GROUP_BOOKING`
`3 <= 3` fits (`true`), `4 <= 3` exceeds capacity (`false`), and `requestedSeats = 0` violates `>= 1` (`INVALID_GROUP_BOOKING`).
Library checkout allows borrowing when `isAvailable === true && borrowedCount < 3` (with `borrowedCount >= 0`).
Correct answer `isAvailable = true, borrowedCount = 3` → expected `false`
With `isAvailable = true` and `borrowedCount = 3`, the correct `< 3` rule returns `false` while the buggy `<= 3` rule wrongly returns `true`.
Contract `canLoanEquipment(stockMap, itemCode, hasSafetyClearance)`: empty `itemCode` returns `INVALID_LOAN_INPUT`; missing key defaults safely to `0` stock.
Correct answer `false` for `"UNKNOWN"`, and `INVALID_LOAN_INPUT` for `""`
Unknown equipment code defaults safely to `0` stock (`false`), whereas an empty string violates the input contract (`INVALID_LOAN_INPUT`).
You finished implementing `canLoanEquipment` and want to submit it against the project rubric.
Correct answer Plain-language contract, clean pure function, fixture tests (typical, boundary, missing-key, invalid), actual test output, and small explainable diff
Complete project evidence pairs the clear rule and pure code with runnable fixtures, real test output, and a reviewable diff.
Classroom Quiz Scorer compares `answerKey = ["A", "B", "C"]` against `studentAnswers = ["C", "A", "B"]`.
Correct answer Correct score is `0`; checking `answerKey.includes(ans[i])` instead of index equality `answerKey[i] === ans[i]` wrongly returns `3`
Quiz scoring compares answers at matching indexes; `"C"`, `"A"`, `"B"` never match `"A"`, `"B"`, `"C"` at the same position (score 0).
`waitlist = [{name:"Ece", eligible:false}, {name:"Kaan", eligible:true}, {name:"Mina", eligible:true}, {name:"Nuri", eligible:true}]` and `openSeats = 2`.
Correct answer Returns `["Kaan", "Mina"]` and leaves original `waitlist.length === 4` untouched
Filtering eligible entries first skips Ece, selects Kaan and Mina (2 seats), and leaves the original 4-item waitlist unmutated.
Contract `checkAttendance(attended, totalSessions)`: `>= 80%` → `"ELIGIBLE"`, `>= 60%` → `"WARNING"`, `< 60%` → `"INELIGIBLE"`; `totalSessions <= 0` or `attended > totalSessions` → `INVALID_ATTENDANCE`.
Correct answer `"WARNING"`, `INVALID_ATTENDANCE`, `INVALID_ATTENDANCE`
`3/5` is exact 60% (`"WARNING"`), `0/0` fails `totalSessions >= 1`, and `6/5` fails `attended <= totalSessions`.
You are porting your finished JavaScript Attendance Eligibility Checker to Python.
Correct answer 1. Freeze shared JSON fixtures → 2. Port guards & branches to Python → 3. Run Python runner on same fixtures → 4. Add both runners to CI
Freezing shared fixtures first, running the second language against those exact cases, and gating both in CI prevents contract drift.