Puzzle Grid Save Check accepts solutions that skip the row or column rule
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Observed behavior
The five built-in cases for Puzzle Grid Save Check (valid-sudoku, LeetCode 36) all pass for two incorrect implementations: one that never checks columns, and one that never checks rows. Only the box rule is tested on its own.
The cases labeled duplicate in column and duplicate in row each break a second rule as well, so a solution that skips the labeled rule still rejects them through the other one:
| Case | Repeated digit | Rules it breaks |
|---|---|---|
| duplicate in column | 8 at (0,0), (3,0) and (2,2) | column 0 and the top-left box |
| duplicate in row | 5 at (0,0), (0,8) and (7,8) | row 0 and column 8 |
| duplicate in box only | 5 at (0,0) and (2,1) | the top-left box only |
Reproduction
- Start a coding interview on Puzzle Grid Save Check and select JavaScript.
- Replace the editor contents with this solution, which checks rows and boxes but never columns:
function isGridConsistent(board) {
const seen = new Set();
for (let r = 0; r < 9; r++) {
for (let c = 0; c < 9; c++) {
const d = board[r][c];
if (d === ".") continue;
const box = Math.floor(r / 3) * 3 + Math.floor(c / 3);
for (const key of [`r${r}:${d}`, `b${box}:${d}`]) {
if (seen.has(key)) return false;
seen.add(key);
}
}
}
return true;
}
- Run the tests. All 5 built-in cases pass.
- Replace
`r${r}:${d}`with`c${c}:${d}`so the solution checks columns and boxes but never rows, and run the tests again. All 5 pass again.
Expected behavior
The contract says the function "returns true exactly when no digit repeats within any row, any column, or any of the nine non-overlapping 3 by 3 blocks", so a solution that ignores rows or columns should fail at least one built-in case.
Evidence
Reproduced in the interview page on codetrial 0.1.0 (925db68), the prebuilt macOS arm64 binary, in JavaScript: a correct solution, the column-skipping solution above, and the row-skipping variant each pass 5/5 built-in cases.
The same result against web/judges/puzzle-grid-save-check.json at 925db68fffc8e1d89f928c0b4c28ae482befafed, run with Node:
correct: 5/5
no column check: 5/5
no row check: 5/5
The cases come from problem-bank/judges.json (duplicate in column at line 3024, duplicate in row at line 3131).
Proposed change
Add two cases derived from valid partial board, each breaking exactly one rule: a column-only duplicate (4 at (8,0), repeating the 4 at (4,0)) and a row-only duplicate (7 at (0,8), repeating the 7 at (0,4)). Both are false. The column-only case fails the column-skipping solution and the row-only case fails the row-skipping one, while the correct solution passes both. The existing cases stay unchanged.
Regenerate web/judges/puzzle-grid-save-check.json with scripts/gen-problems.py, and add a test in tests/browser/compiler-explorer.test.js that the new cases reject both incorrect solutions, following the pattern of the jump-game and stock III tests there.
- Linguagem predominante
- Rust
- Estrelas
- 236
- Forks
- 153
- Merge médio
- 1d 9h
- PRs com merge (30d)
- 187
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sysprog21/codetrial
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
Unify Java harness validation error messagesTalvez já em andamento @weichieh0204 assumiu hoje. Aberta
sysprog21/codetrial#872 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Inferred void class operations are never checked against the starter's return typeTalvez já em andamento @papaya0112 assumiu hoje. Aberta
sysprog21/codetrial#871 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwriteTalvez já em andamento @BOBOGUAGUA428 assumiu hoje. Aberta
sysprog21/codetrial#869 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de sysprog21/codetrial
Issues semelhantes
-
BUG: WebGPU finds no adapter on Linux when a DRM card has no vendor file (ONNX Runtime 1.24.4)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
CyberTimon/RapidRAW#2303 ·
Mantenedores costumam responder em até 1 dia
-
[bug] NSIS installer reads its flags from $CMDLINE, so an unquoted forward-slash path (e.g. C:/Projects/...) triggers passive mode and skips the licence pageTalvez já em andamento @YusufMntm assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
tauri-apps/tauri#16660 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
manaflow-ai/cmux#59692 ·
Mantenedores costumam responder em até 1 dia
-
Retire stale Python-parity labels in Rust ingress and auth testsTalvez já em andamento @github-actions assumiu hoje. Abertafactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
JoshCLWren/comic-pile#5874 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
status:ready unit
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
nonagenticai/conveyor#787 ·
Mantenedores costumam responder em até 1 dia