Python tests lose every result when the solution returns inf or NaN
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 77/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, python, rust
Línea de trabajo
Empieza con el ejecutor de Python en web/runners.js y reproduce el problema usando el código fuente de pythonDriver con la entrada coin-change de problem-bank/judges.json. Compara cómo maneja los resultados no finitos con los ejecutores de JavaScript y Java citados en el issue. Se considera terminado cuando solo fallan los casos que devuelven inf o nan y se conservan los resultados de los demás casos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 177
- Forks
- 100
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 151
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sysprog21/codetrial
-
Allow deselecting a chosen problem card by clicking it againPosiblemente ocupada @woohsin la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
sysprog21/codetrial#392 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Audio output can be confirmed without playing a test soundPosiblemente ocupada @ChenYingHan1121 la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
sysprog21/codetrial#359 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Add a Copy code button to the final reportPosiblemente ocupada @yansawu la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
sysprog21/codetrial#318 · 5 comentarios · 2 reacciones · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Outline Snapshot Duplicator question accept a copied random list that loops back into itselfPosiblemente ocupada @papaya0112 la tomó hoy. Abierto
sysprog21/codetrial#417 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Add a live camera preview during the media preflightPosiblemente ocupada @ChenYingHan1121 la tomó hoy. Abierto
sysprog21/codetrial#414 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de sysprog21/codetrial
Issues similares
-
area: config effort: S good first issue P3 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
ferenyl/azuredevopstui#63 ·
-
needs-triage O-Arm T-libs
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
bug CLI config mcp
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
yunaremaia/sandbox-ffi-layers#56 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
git-ai-project/git-ai#2434 ·
Los mantenedores suelen responder en 1 día