Skip to content

Reject overflowing digit recompositions - #98

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-silent-integer-overflow-in-digit-recomposition
Closed

Reject overflowing digit recompositions#98
krotname wants to merge 1 commit into
mainfrom
codex/fix-silent-integer-overflow-in-digit-recomposition

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Restore previous semantics where concatenated digit sequences reject out-of-range results instead of silently wrapping due to unchecked int arithmetic.

Description

  • Change DescendingOrder.sortDesc to build the reordered digits with a StringBuilder and return Integer.parseInt(...) so values outside int range throw NumberFormatException.
  • Change MinimumLine.minValue to concatenate sorted distinct values via mapToObj(String::valueOf) and Collectors.joining() and return Integer.parseInt(...) to preserve concatenation semantics and reject overflow.
  • Add regression tests rejectsReorderedValuesOutsideIntegerRange in DescendingOrderTest and rejectsConcatenatedValuesOutsideIntegerRange in MinimumLineTest that assert a NumberFormatException is thrown for the reported overflowing inputs.

Testing

  • Ran mvn -q -Dtest=DescendingOrderTest,MinimumLineTest test and the targeted tests passed.
  • Ran full test suite with mvn -q test and it completed successfully in this environment.
  • Ran git diff --check to validate no whitespace/diff issues and the working tree was clean.

Codex Task

Comment thread src/main/java/kyu7/DescendingOrder.java
Comment thread src/main/java/kyu7/MinimumLine.java
@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Закрываю как superseded by #116: изменения перенесены в одну проверенную ветку, все review findings учтены; локальный mvn verify прошёл полностью.

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-silent-integer-overflow-in-digit-recomposition branch August 1, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants