FAILURE MAP
← Case archive

FA-72751 / Check-digit algorithms / Open access

Mastercard 2-series range excludes 2720 · case 01

Cards issued at the top of the 2-series BIN range are reported as unknown.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The 2-series upper bound is exclusive (< 2720).

THE FAILURE

The 2-series upper bound is exclusive (< 2720).

Unsuccessful approach: Widening the bound to 2799 claims unassigned prefixes for Mastercard.

Case contract

Card number screening: spaces removed, nonempty ASCII digits required (else "malformed"). Network by prefix and length: visa 4 with 13/16/19 digits; amex 34 or 37 with 15; mastercard 51-55 or 2221-2720 with 16; discover 6011, 644-649 or 65 with 16-19; otherwise "unknown". Return [network, Luhn validity].

Why this case matters

Checkout forms route card numbers to the right processor and reject Luhn failures before authorization.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s):
    t = s.replace(' ', '')
    if not t or not t.isascii() or not t.isdigit():
        return 'malformed'
    n = len(t)
    if t[0] == '4' and n in (13, 16, 19):
        net = 'visa'
    elif t[:2] in ('34', '37') and n == 15:
        net = 'amex'
    elif (51 <= int(t[:2]) <= 55 or 2221 <= int(t[:4]) < 2720) and n == 16:
        net = 'mastercard'
    elif (t[:4] == '6011' or 644 <= int(t[:3]) <= 649 or t[:2] == '65') and 16 <= n <= 19:
        net = 'discover'
    else:
        net = 'unknown'
    total = 0
    for i, ch in enumerate(reversed(t)):
        d = int(ch) * (2 if i % 2 else 1)
        total += d - 9 if d > 9 else d
    return [net, total % 10 == 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["4846348185497646"]', ['4846348185497646'], ['visa', False]], ['control ["4677178611987"]', ['4677178611987'], ['visa', False]], ['control ["4654355756337734313"]', ['4654355756337734313'], ['visa', False]], ['control ["341466066267172"]', ['341466066267172'], ['amex', False]], ['control ["376431358491919"]', ['376431358491919'], ['amex', False]], ['control ["351552971521401"]', ['351552971521401'], ['unknown', True]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["351552971521401"]', ['351552971521401'], ['unknown', True]], ['control ["367788575584486"]', ['367788575584486'], ['unknown', False]], ['control ["5168420993367718"]', ['5168420993367718'], ['mastercard', False]], ['control ["5518245380112330"]', ['5518245380112330'], ['mastercard', False]], ['control ["5656984207856782"]', ['5656984207856782'], ['unknown', False]], ['control ["2221631854572594"]', ['2221631854572594'], ['mastercard', False]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["2221631854572594"]', ['2221631854572594'], ['mastercard', False]], ['control ["2719349847162292"]', ['2719349847162292'], ['mastercard', False]], ['control ["6011388299412119"]', ['6011388299412119'], ['discover', False]], ['control ["6441839750335463"]', ['6441839750335463'], ['discover', False]], ['control ["6490399248434857177"]', ['6490399248434857177'], ['discover', False]], ['control ["6408243514832764"]', ['6408243514832764'], ['unknown', False]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["6408243514832764"]', ['6408243514832764'], ['unknown', False]], ['control ["6438800916518222"]', ['6438800916518222'], ['unknown', False]], ['control ["65813918194527509"]', ['65813918194527509'], ['discover', False]], ['control ["6692677811687578"]', ['6692677811687578'], ['unknown', True]], ['control ["4111 1111 1111 1111"]', ['4111 1111 1111 1111'], ['visa', True]], ['control ["378282246310005"]', ['378282246310005'], ['amex', True]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["378282246310005"]', ['378282246310005'], ['amex', True]], ['control ["5555555555554444"]', ['5555555555554444'], ['mastercard', True]], ['control ["2223003122003222"]', ['2223003122003222'], ['mastercard', True]], ['control ["6011111111111117"]', ['6011111111111117'], ['discover', True]], ['control ["4111-1111"]', ['4111-1111'], 'malformed'], ['control [""]', [''], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression ["2720611269032342"]['unknown', False]['mastercard', False]Failed
partial-repair ["2721101650461399"]['unknown', False]['unknown', False]Passed
control ["4846348185497646"]['visa', False]['visa', False]Passed
control ["4677178611987"]['visa', False]['visa', False]Passed
control ["4654355756337734313"]['visa', False]['visa', False]Passed
control ["341466066267172"]['amex', False]['amex', False]Passed
control ["376431358491919"]['amex', False]['amex', False]Passed
control ["351552971521401"]['unknown', True]['unknown', True]Passed

SHA-256 / 2b2ea289ba18573dd212f4afbcf0835ec64b3ff1f28d13bb2bdb14cfd8ec7ff3

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s):
    t = s.replace(' ', '')
    if not t or not t.isascii() or not t.isdigit():
        return 'malformed'
    n = len(t)
    if t[0] == '4' and n in (13, 16, 19):
        net = 'visa'
    elif t[:2] in ('34', '37') and n == 15:
        net = 'amex'
    elif (51 <= int(t[:2]) <= 55 or 2221 <= int(t[:4]) <= 2799) and n == 16:
        net = 'mastercard'
    elif (t[:4] == '6011' or 644 <= int(t[:3]) <= 649 or t[:2] == '65') and 16 <= n <= 19:
        net = 'discover'
    else:
        net = 'unknown'
    total = 0
    for i, ch in enumerate(reversed(t)):
        d = int(ch) * (2 if i % 2 else 1)
        total += d - 9 if d > 9 else d
    return [net, total % 10 == 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["4846348185497646"]', ['4846348185497646'], ['visa', False]], ['control ["4677178611987"]', ['4677178611987'], ['visa', False]], ['control ["4654355756337734313"]', ['4654355756337734313'], ['visa', False]], ['control ["341466066267172"]', ['341466066267172'], ['amex', False]], ['control ["376431358491919"]', ['376431358491919'], ['amex', False]], ['control ["351552971521401"]', ['351552971521401'], ['unknown', True]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["351552971521401"]', ['351552971521401'], ['unknown', True]], ['control ["367788575584486"]', ['367788575584486'], ['unknown', False]], ['control ["5168420993367718"]', ['5168420993367718'], ['mastercard', False]], ['control ["5518245380112330"]', ['5518245380112330'], ['mastercard', False]], ['control ["5656984207856782"]', ['5656984207856782'], ['unknown', False]], ['control ["2221631854572594"]', ['2221631854572594'], ['mastercard', False]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["2221631854572594"]', ['2221631854572594'], ['mastercard', False]], ['control ["2719349847162292"]', ['2719349847162292'], ['mastercard', False]], ['control ["6011388299412119"]', ['6011388299412119'], ['discover', False]], ['control ["6441839750335463"]', ['6441839750335463'], ['discover', False]], ['control ["6490399248434857177"]', ['6490399248434857177'], ['discover', False]], ['control ["6408243514832764"]', ['6408243514832764'], ['unknown', False]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["6408243514832764"]', ['6408243514832764'], ['unknown', False]], ['control ["6438800916518222"]', ['6438800916518222'], ['unknown', False]], ['control ["65813918194527509"]', ['65813918194527509'], ['discover', False]], ['control ["6692677811687578"]', ['6692677811687578'], ['unknown', True]], ['control ["4111 1111 1111 1111"]', ['4111 1111 1111 1111'], ['visa', True]], ['control ["378282246310005"]', ['378282246310005'], ['amex', True]]], [['regression ["2720611269032342"]', ['2720611269032342'], ['mastercard', False]], ['partial-repair ["2721101650461399"]', ['2721101650461399'], ['unknown', False]], ['control ["378282246310005"]', ['378282246310005'], ['amex', True]], ['control ["5555555555554444"]', ['5555555555554444'], ['mastercard', True]], ['control ["2223003122003222"]', ['2223003122003222'], ['mastercard', True]], ['control ["6011111111111117"]', ['6011111111111117'], ['discover', True]], ['control ["4111-1111"]', ['4111-1111'], 'malformed'], ['control [""]', [''], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression ["2720611269032342"]['mastercard', False]['mastercard', False]Passed
partial-repair ["2721101650461399"]['mastercard', False]['unknown', False]Failed
control ["4846348185497646"]['visa', False]['visa', False]Passed
control ["4677178611987"]['visa', False]['visa', False]Passed
control ["4654355756337734313"]['visa', False]['visa', False]Passed
control ["341466066267172"]['amex', False]['amex', False]Passed
control ["376431358491919"]['amex', False]['amex', False]Passed
control ["351552971521401"]['unknown', True]['unknown', True]Passed

SHA-256 / 3cb01c779bd8185f2b0cd9177f352ee1a02b73522248904d53f0a7a13bd42bdb

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic, bounded teaching model of the named scheme under the stated contract; not a certified validator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:48:41.257931+00:00.

Case digest / da799fade5ead31054fbd5a45c6800e91f053b3fb06e1225da1be561a1f3d810