Wide Register Arithmetic judge accepts solutions that lose precision on long binary strings
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Observed behavior
In Wide Register Arithmetic (add-binary, LeetCode 67), all five built-in judge cases use binary strings of at most four bits.
As a result, an incorrect JavaScript implementation that converts binary strings into Number values passes all five existing cases, even though it loses integer precision on longer inputs.
function sumBitStrings(a, b) {
return (parseInt(a, 2) + parseInt(b, 2)).toString(2);
}
JavaScript's Number type cannot represent every integer beyond Number.MAX_SAFE_INTEGER (2^53 - 1) exactly.
For example, when adding 2^53 and 1, the implementation returns 2^53 instead of 2^53 + 1 due to floating-point rounding.
This input is valid under the problem's stated constraints, which allow binary strings of up to 10,000 characters. The existing judge does not sufficiently exercise this requirement.
Expected behavior
The built-in judge should include at least one case that requires exact binary addition beyond JavaScript's safe integer range.
The precision-losing implementation above should fail the new case, while a correct implementation should continue to pass every case.
Reproduction
- Open Wide Register Arithmetic in CodeTrial and select JavaScript.
- Paste the implementation above into the editor.
- Click Run tests. The expected result is 5/5 built-in cases passing.
- Under Add a case, enter the following input and expected output.
Input JSON:
["100000000000000000000000000000000000000000000000000000", "1"]
Expected JSON:
"100000000000000000000000000000000000000000000000000001"
- Run the tests again. The additional case should fail because the implementation produces:
100000000000000000000000000000000000000000000000000000
CodeTrial version
Source examined at commit 7023a392dfbd26656c73098b90dad43ec3b751b6.
Environment
- OS: Windows 11
- Browser: chrome
- Language: JavaScript
- Interview loop: Practice
- Problem: Wide Register Arithmetic
- REACTO step: Test
Sanitized evidence
1. Incorrect implementation passes all built-in cases
The Number-based implementation passes all five built-in judge cases (5/5), despite its inability to perform exact integer addition beyond JavaScript's safe integer range.
2. The additional case exposes the precision loss
After adding a valid case representing 2^53 + 1, the incorrect implementation still passes all five built-in cases but fails the custom case. The result is rounded to 2^53 instead of the expected 2^53 + 1, demonstrating a gap in the existing judge coverage.
3. Correct implementation passes all cases
Replacing the Number-based implementation with a BigInt-based implementation allows exact integer addition. All five built-in cases and the additional custom case pass, confirming that the proposed case distinguishes the incorrect implementation from a correct one.
Test Results Summary
The results demonstrate that the existing judge does not adequately cover the problem's requirement to handle long binary strings.
| Implementation | Built-in cases | Custom case | Total |
|---|---|---|---|
| Number-based (incorrect) | 5/5 | 0/1 | 5/6 |
| BigInt-based (correct) | 5/5 | 1/1 | 6/6 |
The proposed case strengthens judge coverage without changing the existing problem contract.
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
- Vorherrschende Sprache
- Rust
- Sterne
- 236
- Forks
- 153
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 187
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus sysprog21/codetrial
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Unify Java harness validation error messagesEvtl. vergeben @weichieh0204 hat das heute übernommen. Offen
sysprog21/codetrial#872 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Inferred void class operations are never checked against the starter's return typeEvtl. vergeben @papaya0112 hat das heute übernommen. Offen
sysprog21/codetrial#871 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwriteEvtl. vergeben @BOBOGUAGUA428 hat das heute übernommen. Offen
sysprog21/codetrial#869 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in sysprog21/codetrial
Ähnliche Issues
-
BUG: WebGPU finds no adapter on Linux when a DRM card has no vendor file (ONNX Runtime 1.24.4)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
CyberTimon/RapidRAW#2303 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[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 pageEvtl. vergeben @YusufMntm hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
tauri-apps/tauri#16660 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
manaflow-ai/cmux#59692 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Retire stale Python-parity labels in Rust ingress and auth testsEvtl. vergeben @github-actions hat das heute übernommen. Offenfactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
JoshCLWren/comic-pile#5874 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
status:ready unit
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
nonagenticai/conveyor#787 ·
Maintainer antworten meist innerhalb von 1 Tag