Python tests lose every result when the solution returns inf or NaN
I maintainer di solito rispondono entro 1 giorno
@shensyuan ci sta già lavorando.
Dal 21/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 77/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, python, rust
Direzione di ricerca
Inizia con il runner Python in web/runners.js e riproduci il problema usando il codice sorgente di pythonDriver con la voce coin-change in problem-bank/judges.json. Confronta la gestione dei risultati non finiti con quella dei runner JavaScript e Java citati nell’issue. Il lavoro è completato quando falliscono solo i casi che restituiscono inf o nan e i risultati dei casi restanti vengono preservati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Observed behavior
When a Python solution returns float("inf") or float("nan") for any test case, the whole run is reported as a setup error and every case result is lost, including the passing ones. The test panel shows "Couldn't run your code" and a JSON parser message instead of a per-case table. The solution below is wrong for two cases, which is expected; the problem is how the run reports it.
The JavaScript and Java runners fail only the affected case (web/runners.js:517, web/compiler-explorer.js:695). Returning inf for "impossible" is a common mistake that the pitfalls entry of coin-change lists ("returning a large sentinel instead of -1").
The other runners handle the same value per case: the JavaScript Worker's sanitize (web/runners.js:517) turns Infinity into null, and the Java harness's json(double) (web/compiler-explorer.js:695) writes null for a non-finite value, so each of those fails only the affected case.
Expected behavior
Only the cases that returned a non-finite number fail, with their got shown, and the other cases keep their results, as in the JavaScript and Java runners. For the solution below that is 3 passing cases and 2 failing ones ("impossible amount" and "large token ignored", which expect -1).
Reproduction
- Start an interview on
coin-change (Kiosk Token Payout)and choose Python. - Replace the starter with:
class Solution:
def fewestTokens(self, tokens: list[int], amount: int) -> int:
dp = [float("inf")] * (amount + 1)
dp[0] = 0
for a in range(1, amount + 1):
for t in tokens:
if t <= a:
dp[a] = min(dp[a], dp[a - t] + 1)
return dp[amount]
- Click Run tests.
- The test results panel shows "Couldn't run your code" and the
JSON.parsemessage below instead of the per-case results.
Without a browser, the same result can be seen by running the pythonDriver source from web/runners.js under CPython 3 with this solution and the coin-change entry of problem-bank/judges.json (with entry set to fewestTokens for the variant). Its output is:
{"results": [{"actual": 3, ...}, {"actual": Infinity, ...}, {"actual": 0, ...}, {"actual": 2, ...}, {"actual": Infinity, ...}]}
Passing that string to JSON.parse throws SyntaxError: Unexpected token 'I'.
CodeTrial version
codetrial 0.1.0 (e9851ab)
Environment
OS: Windows 11
Browser: Google Chrome 153.0.8010.54
Access: local server at http://127.0.0.1:3000/
Language: Python
Problem: coin-change (Kiosk Token Payout variant)
Sanitized evidence
Test results panel:
Couldn't run your code
Unexpected token 'I', ...""actual": Infinity, "... is not valid JSON
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
- Lingua principale
- Rust
- Stelle
- 177
- Fork
- 100
- Merge medio
- 1g 11h
- PR unite (30g)
- 182
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sysprog21/codetrial
-
Selecting a pen color leaves Example drawing in eraser modeForse già presa @Aa99841 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
sysprog21/codetrial#437 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Allow deselecting a chosen problem card by clicking it againForse già presa @woohsin l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
sysprog21/codetrial#392 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Audio output can be confirmed without playing a test soundForse già presa @ChenYingHan1121 l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
sysprog21/codetrial#359 · 5 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Add a Copy code button to the final reportForse già presa @yansawu l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
sysprog21/codetrial#318 · 6 commenti · 2 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
sysprog21/codetrial#451 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sysprog21/codetrial
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
IngvarConsulting/unica#2006 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
limitlessprojects/Go-Hybrid#1377 ·
I maintainer di solito rispondono entro 1 giorno
-
[deps] Bump tokio past RUSTSEC-2026-0386 (AsyncFd I/O safety) and rand past RUSTSEC-2026-0097Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Docker host resolution missing default rootless Docker pathForse già presa @500B l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
testcontainers/testcontainers-rs#1000 ·
I maintainer di solito rispondono entro 3 giorni
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
andyintheshell/perseid#73 ·
I maintainer di solito rispondono entro 1 giorno