Python tests lose every result when the solution returns inf or NaN
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 77/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, python, rust
Hướng nghiên cứu
Bắt đầu với trình chạy Python trong web/runners.js và tái hiện vấn đề bằng mã nguồn pythonDriver với mục coin-change trong problem-bank/judges.json. So sánh cách xử lý các kết quả không hữu hạn với các trình chạy JavaScript và Java được nhắc đến trong issue. Hoàn thành khi chỉ các trường hợp trả về inf hoặc nan thất bại và kết quả của các trường hợp còn lại được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 177
- Fork
- 100
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 151
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sysprog21/codetrial
-
Allow deselecting a chosen problem card by clicking it againCó thể đã có người làm @woohsin đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
sysprog21/codetrial#392 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Audio output can be confirmed without playing a test soundCó thể đã có người làm @ChenYingHan1121 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
sysprog21/codetrial#359 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add a Copy code button to the final reportCó thể đã có người làm @yansawu đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
sysprog21/codetrial#318 · 5 bình luận · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Outline Snapshot Duplicator question accept a copied random list that loops back into itselfCó thể đã có người làm @papaya0112 đã nhận hôm nay. Đang mở
sysprog21/codetrial#417 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add a live camera preview during the media preflightCó thể đã có người làm @ChenYingHan1121 đã nhận hôm nay. Đang mở
sysprog21/codetrial#414 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sysprog21/codetrial
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
chrisdickinson/trivia#26 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100