FAILURE MAP
← Case archive

FA-83471 / Card game rule engines / Open access

Mixed-suit sequences are accepted as runs · case 01

5-6-7 in different suits is scored as a run.

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

ROOT CAUSE

The single-suit check for runs is missing.

THE FAILURE

The single-suit check for runs is missing.

Unsuccessful approach: Allowing up to two suits still accepts mixed sequences.

Case contract

Input a list of cards. A set is 3-4 cards of one rank in distinct suits. A run is 3+ consecutive cards of one suit; ace is low (A-2-3) or high (Q-K-A) but runs do not wrap (K-A-2). Return "set", "run" or "invalid".

Why this case matters

Card-game engines, scoring apps and online tables apply this rule automatically on every hand.

1 / The failure

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

N = 1
observations = []
def solve(x):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, 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
meld case 0invalidinvalidPassed
meld case 1runrunPassed
meld case 2invalidinvalidPassed
meld case 3invalidinvalidPassed
meld case 4invalidinvalidPassed
meld case 5invalidinvalidPassed
meld case 6runinvalidFailed
meld case 7runinvalidFailed

SHA-256 / 06bac8803462a44e46985acaf6a53dedce4afd76667ec3dda355cf570a9a1e36

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    if len(set(suits)) > 2:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, 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
meld case 0invalidinvalidPassed
meld case 1runrunPassed
meld case 2invalidinvalidPassed
meld case 3invalidinvalidPassed
meld case 4invalidinvalidPassed
meld case 5invalidinvalidPassed
meld case 6runinvalidFailed
meld case 7runinvalidFailed

SHA-256 / 421e9476047e265bc6b4ee7739ebcfa5d6b2cecc52b2c23dd99e53cf2eb8f6cb

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 bounded toy rule contract stated explicitly in the contract field; cards are two-character codes (rank, suit). Not a complete implementation of any published rulebook or casino table rules. 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:50:21.948352+00:00.

Case digest / d4220f759cd11e218003a23ddd1fb5bdc66cbe78180a1f6fb419204f1eca5491