Commit c5a137a
Reject non-lowercase input in a1z26 encode()
The A1Z26 cipher maps a-z to 1-26. Previously encode() had no input
validation and would silently produce nonsense output (negative numbers
for uppercase, out-of-range values for spaces/punctuation), e.g.
encode("A") returned [-31].
Raise ValueError for any character outside a-z, matching the
contribution guide's expectation that erroneous input should raise
exceptions rather than silently return wrong values. The empty string
is also rejected because encoding nothing has no meaningful result.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c0db072 commit c5a137a
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
| |||
0 commit comments