Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/maintenance/alphametics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Maintenance Notes: `alphametics`

## Canonical Case Coverage Summary

- Total canonical entries in `exercises/practice/alphametics/.meta/tests.toml`: **10**
- Included: **10** (no `include = false` exclusions)
- Excluded: **0**

All 10 canonical cases in `.meta/tests.toml` map 1-to-1 to `@Test` methods in `exercises/practice/alphametics/src/test/java/AlphameticsTest.java`. The learner-facing stub throws `UnsupportedOperationException`, and all tests pass against `.meta/src/reference/java/Alphametics.java`.

## Selected UUID Rationales

| Canonical UUID | Canonical Description | Java Test Method (`@DisplayName`) | Status | Rationale & Java Operation |
| --- | --- | --- | --- | --- |
| `e0c08b07-9028-4d5f-91e1-d178fead8e1a` | `puzzle with three letters` | `testThreeLetters` (`"puzzle with three letters"`) | Included | Solves `I + BB == ILL`. `Alphametics.generate()` assigns distinct digits to characters via `isDigitsUsed`, and `Alphametics.isSumTally()` evaluates `mapToNumber()` to verify `1 + 99 == 100`. |
| `a504ee41-cb92-4ec2-9f11-c37e95ab3f25` | `solution must have unique value for each letter` | `testUniqueValue` (`"solution must have unique value for each letter"`) | Included | Tests puzzle `A == B`. Since each character must have a unique non-reusable digit, `A` and `B` cannot be assigned the same value. No valid assignment exists, and `solve()` correctly throws `UnsolvablePuzzleException`. |
| `4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a` | `leading zero solution is invalid` | `testLeadingZero` (`"leading zero solution is invalid"`) | Included | Tests puzzle `ACA + DD == BD`. `Alphametics.isLeadingDigitZero()` verifies whether the leading letter of any word is mapped to `0`. Mappings violating this invariant are pruned, leading to `UnsolvablePuzzleException`. |

## Full Canonical UUID-to-Test Mapping

| Canonical UUID | Canonical Description | Java Test Method | Included |
| --- | --- | --- | --- |
| `e0c08b07-9028-4d5f-91e1-d178fead8e1a` | `puzzle with three letters` | `testThreeLetters` | Yes |
| `a504ee41-cb92-4ec2-9f11-c37e95ab3f25` | `solution must have unique value for each letter` | `testUniqueValue` | Yes |
| `4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a` | `leading zero solution is invalid` | `testLeadingZero` | Yes |
| `8a3e3168-d1ee-4df7-94c7-b9c54845ac3a` | `puzzle with two digits final carry` | `testTwoDigitsFinalCarry` | Yes |
| `a9630645-15bd-48b6-a61e-d85c4021cc09` | `puzzle with four letters` | `testFourLetters` | Yes |
| `3d905a86-5a52-4e4e-bf80-8951535791bd` | `puzzle with six letters` | `testSixLetters` | Yes |
| `4febca56-e7b7-4789-97b9-530d09ba95f0` | `puzzle with seven letters` | `testSevenLetters` | Yes |
| `12125a75-7284-4f9a-a5fa-191471e0d44f` | `puzzle with eight letters` | `testEightLetters` | Yes |
| `fb05955f-38dc-477a-a0b6-5ef78969fffa` | `puzzle with ten letters` | `testTenLetters` | Yes |
| `9a101e81-9216-472b-b458-b513a7adacf7` | `puzzle with ten letters and 199 addends` | `testTenLettersAnd199Addends` | Yes |
3 changes: 3 additions & 0 deletions exercises/practice/alphametics/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

[e0c08b07-9028-4d5f-91e1-d178fead8e1a]
description = "puzzle with three letters"
comment = "Included: covered by AlphameticsTest.testThreeLetters (I + BB == ILL); Alphametics.generate() assigns distinct digits and isSumTally() verifies 1 + 99 == 100."

[a504ee41-cb92-4ec2-9f11-c37e95ab3f25]
description = "solution must have unique value for each letter"
comment = "Included: covered by AlphameticsTest.testUniqueValue (A == B); Alphametics.generate() uses boolean[10] to prevent duplicate digits, so no solution exists and solve() throws UnsolvablePuzzleException."

[4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a]
description = "leading zero solution is invalid"
comment = "Included: covered by AlphameticsTest.testLeadingZero (ACA + DD == BD); Alphametics.isLeadingDigitZero() rejects mappings where a leading letter is zero, throwing UnsolvablePuzzleException."

[8a3e3168-d1ee-4df7-94c7-b9c54845ac3a]
description = "puzzle with two digits final carry"
Expand Down
38 changes: 38 additions & 0 deletions work/R58-T031/actual.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"canonical_entry_count": 10,
"canonical_exclusion_count": 0,
"selected_cases": {
"e0c08b07-9028-4d5f-91e1-d178fead8e1a": {
"test_name": "testThreeLetters",
"display_name": "puzzle with three letters",
"puzzle": "I + BB == ILL",
"expected": {
"I": 1,
"B": 9,
"L": 0
},
"rationale": "Alphametics.generate() assigns one unused digit to each character. Alphametics.isSumTally() passes mapToNumber() values for I, BB, and ILL; I=1, B=9, L=0 gives 1 + 99 == 100."
},
"a504ee41-cb92-4ec2-9f11-c37e95ab3f25": {
"test_name": "testUniqueValue",
"display_name": "solution must have unique value for each letter",
"puzzle": "A == B",
"expected": "UnsolvablePuzzleException",
"rationale": "Alphametics.generate() uses a boolean[10] to prevent reuse of a digit, so A and B cannot receive the same digit. isSumTally() then cannot find a distinct-digit mapping for A == B, and solve() throws UnsolvablePuzzleException."
},
"4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a": {
"test_name": "testLeadingZero",
"display_name": "leading zero solution is invalid",
"puzzle": "ACA + DD == BD",
"expected": "UnsolvablePuzzleException",
"rationale": "isLeadingDigitZero() inspects the first character of every addend and the result. A, D, or B mapped to zero would be a leading digit in ACA, DD, or BD, so the valid-permutation base case rejects it and solve() throws UnsolvablePuzzleException."
}
},
"gradle_return_code": 0,
"test_counts": {
"tests": 13,
"failures": 0,
"errors": 0,
"skipped": 9
}
}
55 changes: 55 additions & 0 deletions work/R58-T031/canonical_inventory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"entry_count": 10,
"entries": [
{
"uuid": "e0c08b07-9028-4d5f-91e1-d178fead8e1a",
"description": "puzzle with three letters",
"excluded": false
},
{
"uuid": "a504ee41-cb92-4ec2-9f11-c37e95ab3f25",
"description": "solution must have unique value for each letter",
"excluded": false
},
{
"uuid": "4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a",
"description": "leading zero solution is invalid",
"excluded": false
},
{
"uuid": "8a3e3168-d1ee-4df7-94c7-b9c54845ac3a",
"description": "puzzle with two digits final carry",
"excluded": false
},
{
"uuid": "a9630645-15bd-48b6-a61e-d85c4021cc09",
"description": "puzzle with four letters",
"excluded": false
},
{
"uuid": "3d905a86-5a52-4e4e-bf80-8951535791bd",
"description": "puzzle with six letters",
"excluded": false
},
{
"uuid": "4febca56-e7b7-4789-97b9-530d09ba95f0",
"description": "puzzle with seven letters",
"excluded": false
},
{
"uuid": "12125a75-7284-4f9a-a5fa-191471e0d44f",
"description": "puzzle with eight letters",
"excluded": false
},
{
"uuid": "fb05955f-38dc-477a-a0b6-5ef78969fffa",
"description": "puzzle with ten letters",
"excluded": false
},
{
"uuid": "9a101e81-9216-472b-b458-b513a7adacf7",
"description": "puzzle with ten letters and 199 addends",
"excluded": false
}
]
}
1 change: 1 addition & 0 deletions work/R58-T031/check.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PASS
Loading