broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    b=x['board']; fr,to=x['move']; p=b[fr]; white=p.isupper()
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    def at(f,r): return b.get(chr(97+f)+str(r+1)) if 0<=f<8 and 0<=r<8 else None
    def sq(f,r): return chr(97+f)+str(r+1)
    def attackers(s, by_white):
        f,r=ord(s[0])-97,int(s[1])-1
        P,N,B,R,Q=('PNBRQ' if by_white else 'pnbrq')
        out=[]
        pr=r-1 if by_white else r+1
        for df in (-1,1):
            if at(f+df,pr)==P: out.append(sq(f+df,pr))
        for df,dr in ((1,2),(2,1),(-1,2),(-2,1),(1,-2),(2,-1),(-1,-2),(-2,-1)):
            if at(f+df,r+dr)==N: out.append(sq(f+df,r+dr))
        for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
            kinds=(R,Q) if df==0 or dr==0 else (B,Q)
            ff,rr=f+df,r+dr
            while 0<=ff<8 and 0<=rr<8:
                v=at(ff,rr)
                if v:
                    if v in kinds: out.append(sq(ff,rr))
                    break
                ff+=df; rr+=dr
        return out
    checkers=attackers(ks, not white)
    if len(checkers)>=2: return False
    if not checkers: return True
    c=checkers[0]
    if to==c: return True
    if b[c].lower() in ('n','p'): return False
    cf,cr=ord(c[0])-97,int(c[1])-1
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    sf=1 if cf>kf else -1; sr=1 if cr>kr else -1
    f,r=kf+sf,kr+sr
    between=[]
    while (f,r)!=(cf,cr) and 0<=f<8 and 0<=r<8:
        between.append(sq(f,r)); f+=sf; r+=sr
    return to in between
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('knight check sidestep piece',
   {'board': {'a8': 'k', 'b2': 'B', 'd3': 'n', 'e1': 'K'}, 'move': ['b2', 'c3']}, False),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('cannot block knight',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'f3': 'n'}, 'move': ['d1', 'e2']}, False),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True)],
 [('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('cannot block knight',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'f3': 'n'}, 'move': ['d1', 'e2']}, False),
  ('double check block',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r', 'f3': 'n'}, 'move': ['d1', 'e2']},
   False),
  ('double check capture one',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']},
   False),
  ('diagonal interpose',
   {'board': {'a5': 'b', 'c1': 'N', 'e1': 'K', 'h8': 'k'}, 'move': ['c1', 'b3']}, False),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('double check capture one',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']},
   False),
  ('diagonal interpose',
   {'board': {'a5': 'b', 'c1': 'N', 'e1': 'K', 'h8': 'k'}, 'move': ['c1', 'b3']}, False),
  ('diagonal interpose d2',
   {'board': {'a5': 'b', 'e1': 'K', 'f3': 'N', 'h8': 'k'}, 'move': ['f3', 'd2']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('black cannot block white knight',
   {'board': {'a1': 'K', 'c8': 'b', 'd6': 'N', 'e8': 'k'}, 'move': ['c8', 'd7']}, False),
  ('irrelevant move in check',
   {'board': {'a2': 'P', 'a8': 'k', 'e1': 'K', 'e8': 'r'}, 'move': ['a2', 'a3']}, False),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('black cannot block white knight',
   {'board': {'a1': 'K', 'c8': 'b', 'd6': 'N', 'e8': 'k'}, 'move': ['c8', 'd7']}, False),
  ('irrelevant move in check',
   {'board': {'a2': 'P', 'a8': 'k', 'e1': 'K', 'e8': 'r'}, 'move': ['a2', 'a3']}, False),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('knight check sidestep piece',
   {'board': {'a8': 'k', 'b2': 'B', 'd3': 'n', 'e1': 'K'}, 'move': ['b2', 'c3']}, False),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    b=x['board']; fr,to=x['move']; p=b[fr]; white=p.isupper()
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    def at(f,r): return b.get(chr(97+f)+str(r+1)) if 0<=f<8 and 0<=r<8 else None
    def sq(f,r): return chr(97+f)+str(r+1)
    def attackers(s, by_white):
        f,r=ord(s[0])-97,int(s[1])-1
        P,N,B,R,Q=('PNBRQ' if by_white else 'pnbrq')
        out=[]
        pr=r-1 if by_white else r+1
        for df in (-1,1):
            if at(f+df,pr)==P: out.append(sq(f+df,pr))
        for df,dr in ((1,2),(2,1),(-1,2),(-2,1),(1,-2),(2,-1),(-1,-2),(-2,-1)):
            if at(f+df,r+dr)==N: out.append(sq(f+df,r+dr))
        for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
            kinds=(R,Q) if df==0 or dr==0 else (B,Q)
            ff,rr=f+df,r+dr
            while 0<=ff<8 and 0<=rr<8:
                v=at(ff,rr)
                if v:
                    if v in kinds: out.append(sq(ff,rr))
                    break
                ff+=df; rr+=dr
        return out
    checkers=attackers(ks, not white)
    if len(checkers)>=2: return False
    if not checkers: return True
    c=checkers[0]
    if to==c: return True
    if b[c].lower() in ('n','p'): return False
    cf,cr=ord(c[0])-97,int(c[1])-1
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    sf=(cf-kf)//abs(cf-kf) if cf!=kf else 1; sr=(cr-kr)//abs(cr-kr) if cr!=kr else 1
    f,r=kf+sf,kr+sr
    between=[]
    while (f,r)!=(cf,cr) and 0<=f<8 and 0<=r<8:
        between.append(sq(f,r)); f+=sf; r+=sr
    return to in between
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('knight check sidestep piece',
   {'board': {'a8': 'k', 'b2': 'B', 'd3': 'n', 'e1': 'K'}, 'move': ['b2', 'c3']}, False),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('cannot block knight',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'f3': 'n'}, 'move': ['d1', 'e2']}, False),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True)],
 [('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('cannot block knight',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'f3': 'n'}, 'move': ['d1', 'e2']}, False),
  ('double check block',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r', 'f3': 'n'}, 'move': ['d1', 'e2']},
   False),
  ('double check capture one',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']},
   False),
  ('diagonal interpose',
   {'board': {'a5': 'b', 'c1': 'N', 'e1': 'K', 'h8': 'k'}, 'move': ['c1', 'b3']}, False),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('double check capture one',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']},
   False),
  ('diagonal interpose',
   {'board': {'a5': 'b', 'c1': 'N', 'e1': 'K', 'h8': 'k'}, 'move': ['c1', 'b3']}, False),
  ('diagonal interpose d2',
   {'board': {'a5': 'b', 'e1': 'K', 'f3': 'N', 'h8': 'k'}, 'move': ['f3', 'd2']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('black cannot block white knight',
   {'board': {'a1': 'K', 'c8': 'b', 'd6': 'N', 'e8': 'k'}, 'move': ['c8', 'd7']}, False),
  ('irrelevant move in check',
   {'board': {'a2': 'P', 'a8': 'k', 'e1': 'K', 'e8': 'r'}, 'move': ['a2', 'a3']}, False),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('black cannot block white knight',
   {'board': {'a1': 'K', 'c8': 'b', 'd6': 'N', 'e8': 'k'}, 'move': ['c8', 'd7']}, False),
  ('irrelevant move in check',
   {'board': {'a2': 'P', 'a8': 'k', 'e1': 'K', 'e8': 'r'}, 'move': ['a2', 'a3']}, False),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)],
 [('no check', {'board': {'b1': 'N', 'e1': 'K', 'e8': 'k'}, 'move': ['b1', 'c3']}, True),
  ('block rook check',
   {'board': {'a8': 'k', 'b1': 'N', 'e1': 'K', 'e8': 'r'}, 'move': ['b1', 'c3']}, False),
  ('interpose on file',
   {'board': {'a8': 'k', 'd1': 'Q', 'e1': 'K', 'e8': 'r'}, 'move': ['d1', 'e2']}, True),
  ('capture rook checker',
   {'board': {'a8': 'k', 'e1': 'K', 'e8': 'r', 'h8': 'R'}, 'move': ['h8', 'e8']}, True),
  ('knight check sidestep piece',
   {'board': {'a8': 'k', 'b2': 'B', 'd3': 'n', 'e1': 'K'}, 'move': ['b2', 'c3']}, False),
  ('bishop takes knight checker',
   {'board': {'a8': 'k', 'e1': 'K', 'f3': 'n', 'g2': 'B'}, 'move': ['g2', 'f3']}, True),
  ('black blocks white queen',
   {'board': {'a1': 'K', 'c6': 'n', 'e1': 'Q', 'e8': 'k'}, 'move': ['c6', 'e7']}, True),
  ('rank check interpose',
   {'board': {'a1': 'K', 'a8': 'k', 'b3': 'N', 'h1': 'q'}, 'move': ['b3', 'c1']}, True)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
Interposing on the checking file is rejected while unrelated diagonal squares are accepted.

Input: {"board", "move": [from, to]} for a non-king piece whose king may be in check (pins are ignored). Return true if the move is allowed by the check rules: no check means true; double check means false; a single check is answered by capturing the checker or, for a rook, bishop or queen checker, by moving onto a square strictly between it and the king.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=i+1; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=7-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
White pieces listed on the last FEN row appear on rank 8.

Input: a FEN string. Return {"pieces": {square: piece}, "turn", "castling", "ep", "halfmove", "fullmove"} or "invalid". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is "-" or letters from KQkq (returned as "" when "-"); ep is "-" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=1
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)-1
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
"4k3" places the king on b8 and every rank fails the eight-file check.

Input: a FEN string. Return {"pieces": {square: piece}, "turn", "castling", "ep", "halfmove", "fullmove"} or "invalid". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is "-" or letters from KQkq (returned as "" when "-"); ep is "-" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast=parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2].upper()
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
Every FEN with "-" in the castling field is reported invalid.

Input: a FEN string. Return {"pieces": {square: piece}, "turn", "castling", "ep", "halfmove", "fullmove"} or "invalid". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is "-" or letters from KQkq (returned as "" when "-"); ep is "-" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:] not in ('3','6'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('3' if turn=='w' else '6'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid')],
 [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid')],
 [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
With white to move, an ep square on rank 3 is accepted.

Input: a FEN string. Return {"pieces": {square: piece}, "turn", "castling", "ep", "halfmove", "fullmove"} or "invalid". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is "-" or letters from KQkq (returned as "" when "-"); ep is "-" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<0: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    parts=x.split()
    if len(parts)!=6: return 'invalid'
    rows=parts[0].split('/')
    if len(rows)!=8: return 'invalid'
    board={}
    for i,row in enumerate(rows):
        rank=8-i; f=0
        for ch in row:
            if ch.isdigit(): f+=int(ch)
            elif ch in 'pnbrqkPNBRQK':
                if f>7: return 'invalid'
                board[chr(97+f)+str(rank)]=ch; f+=1
            else: return 'invalid'
        if f!=8: return 'invalid'
    vals=list(board.values())
    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'
    turn=parts[1]
    if turn not in ('w','b'): return 'invalid'
    cast='' if parts[2]=='-' else parts[2]
    if any(c not in 'KQkq' for c in cast): return 'invalid'
    ep=None if parts[3]=='-' else parts[3]
    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'
    if not parts[4].isdigit() or int(parts[5])<1: return 'invalid'
    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',
   {'castling': '',
    'ep': None,
    'fullmove': 20,
    'halfmove': 3,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'b'}),
  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',
   {'castling': 'kq',
    'ep': None,
    'fullmove': 5,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},
    'turn': 'w'}),
  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),
  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),
  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',
   {'castling': 'K',
    'ep': None,
    'fullmove': 30,
    'halfmove': 7,
    'pieces': {'a7': 'p',
               'a8': 'r',
               'b7': 'p',
               'b8': 'n',
               'e1': 'K',
               'e8': 'k',
               'g1': 'N',
               'g2': 'P',
               'h1': 'R',
               'h2': 'P'},
    'turn': 'w'}),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],
 [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',
   {'castling': 'Q',
    'ep': None,
    'fullmove': 1,
    'halfmove': 0,
    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},
    'turn': 'w'}),
  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',
   {'castling': '',
    'ep': 'd3',
    'fullmove': 12,
    'halfmove': 0,
    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},
    'turn': 'b'}),
  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',
   {'castling': '',
    'ep': 'd6',
    'fullmove': 9,
    'halfmove': 0,
    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},
    'turn': 'w'}),
  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),
  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),
  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),
  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),
  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, 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)

prompt:
A FEN ending in "0 0" parses as a valid position.

Input: a FEN string. Return {"pieces": {square: piece}, "turn", "castling", "ep", "halfmove", "fullmove"} or "invalid". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is "-" or letters from KQkq (returned as "" when "-"); ep is "-" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.

split: open-access