DDigitTally
Workflows

Coding workflows · ASCII Luhn validation

03
Built around your work

A concrete starting point

Validate a synthetic string of 2 through 64 ASCII digits with the Luhn checksum. Keep leading zeros and test both parity lengths, rejecting spaces and non-ASCII digits without claiming account validity.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

ASCII Luhn validation

A concrete starting point
def luhn_valid(text):
    if type(text) is not str or not 2 <= len(text) <= 64:
        raise ValueError("luhn.length")
    if any(char < "0" or char > "9" for char in text):
        raise ValueError("luhn.alphabet")
    total = 0
    for index, char in enumerate(reversed(text)):
        digit = ord(char) - ord("0")
        if index % 2:
            digit *= 2
            if digit > 9:
                digit -= 9
        total += digit
    return total % 10 == 0

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗