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

N = 1
observations = []
def solve(x):
    b=x['board']; sq=x['from']; p=b[sq]; white=p=='P'
    f,r=ord(sq[0])-97,int(sq[1])-1
    d=1 if white else -1
    start=1 if white else 6
    last=7 if white else 0
    def at(ff,rr): return chr(97+ff)+str(rr+1)
    out=[]
    if 0<=r+d<8 and at(f,r+d) not in b:
        out.append(at(f,r+d))
        if r==start and at(f,r+2*d) not in b: out.append(at(f,r+2*d))
    for df in (-1,1):
        ff=f+df
        if not 0<=ff<8 or not 0<=r+d<8: continue
        t=at(ff,r+d); occ=b.get(t)
        if (occ and occ.isupper()!=white) or t==x.get('ep'): out.append(t)
    res=[]
    for t in out:
        if int(t[1])-1==last: res+=[t+c for c in 'q']
        else: res.append(t)
    return sorted(res)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r'])],
 [('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('en passant target', {'board': {'d5': 'p', 'e5': 'P'}, 'ep': 'd6', 'from': 'e5'}, ['d6', 'e6']),
  ('black on sixth rank', {'board': {'a6': 'p'}, 'ep': None, 'from': 'a6'}, ['a5']),
  ('white third rank', {'board': {'g3': 'P'}, 'ep': None, 'from': 'g3'}, ['g4'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('en passant target', {'board': {'d5': 'p', 'e5': 'P'}, 'ep': 'd6', 'from': 'e5'}, ['d6', 'e6']),
  ('black on sixth rank', {'board': {'a6': 'p'}, 'ep': None, 'from': 'a6'}, ['a5']),
  ('white third rank', {'board': {'g3': 'P'}, 'ep': None, 'from': 'g3'}, ['g4']),
  ('black blocked by own', {'board': {'a6': 'P', 'b6': 'p', 'b7': 'p'}, 'ep': None, 'from': 'b7'},
   ['a6'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('black blocked by own', {'board': {'a6': 'P', 'b6': 'p', 'b7': 'p'}, 'ep': None, 'from': 'b7'},
   ['a6'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r'])]]
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']; sq=x['from']; p=b[sq]; white=p=='P'
    f,r=ord(sq[0])-97,int(sq[1])-1
    d=1 if white else -1
    start=1 if white else 6
    last=7 if white else 0
    def at(ff,rr): return chr(97+ff)+str(rr+1)
    out=[]
    if 0<=r+d<8 and at(f,r+d) not in b:
        out.append(at(f,r+d))
        if r==start and at(f,r+2*d) not in b: out.append(at(f,r+2*d))
    for df in (-1,1):
        ff=f+df
        if not 0<=ff<8 or not 0<=r+d<8: continue
        t=at(ff,r+d); occ=b.get(t)
        if (occ and occ.isupper()!=white) or t==x.get('ep'): out.append(t)
    res=[]
    for t in out:
        if int(t[1])-1==last: res+=[t+c for c in 'qrb']
        else: res.append(t)
    return sorted(res)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r'])],
 [('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('en passant target', {'board': {'d5': 'p', 'e5': 'P'}, 'ep': 'd6', 'from': 'e5'}, ['d6', 'e6']),
  ('black on sixth rank', {'board': {'a6': 'p'}, 'ep': None, 'from': 'a6'}, ['a5']),
  ('white third rank', {'board': {'g3': 'P'}, 'ep': None, 'from': 'g3'}, ['g4'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('en passant target', {'board': {'d5': 'p', 'e5': 'P'}, 'ep': 'd6', 'from': 'e5'}, ['d6', 'e6']),
  ('black on sixth rank', {'board': {'a6': 'p'}, 'ep': None, 'from': 'a6'}, ['a5']),
  ('white third rank', {'board': {'g3': 'P'}, 'ep': None, 'from': 'g3'}, ['g4']),
  ('black blocked by own', {'board': {'a6': 'P', 'b6': 'p', 'b7': 'p'}, 'ep': None, 'from': 'b7'},
   ['a6'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r']),
  ('black blocked by own', {'board': {'a6': 'P', 'b6': 'p', 'b7': 'p'}, 'ep': None, 'from': 'b7'},
   ['a6'])],
 [('white double push', {'board': {'e2': 'P'}, 'ep': None, 'from': 'e2'}, ['e3', 'e4']),
  ('black double push', {'board': {'d7': 'p'}, 'ep': None, 'from': 'd7'}, ['d5', 'd6']),
  ('blocked jump', {'board': {'e2': 'P', 'e3': 'n'}, 'ep': None, 'from': 'e2'}, []),
  ('far square blocked', {'board': {'c5': 'P', 'c7': 'p'}, 'ep': None, 'from': 'c7'}, ['c6']),
  ('captures both colours', {'board': {'c5': 'p', 'd4': 'P', 'e5': 'B'}, 'ep': None, 'from': 'd4'},
   ['c5', 'd5']),
  ('black captures',
   {'board': {'e5': 'P', 'f5': 'P', 'f6': 'p', 'g5': 'n'}, 'ep': None, 'from': 'f6'}, ['e5']),
  ('white promotion', {'board': {'a8': 'r', 'b7': 'P'}, 'ep': None, 'from': 'b7'},
   ['a8b', 'a8n', 'a8q', 'a8r', 'b8b', 'b8n', 'b8q', 'b8r']),
  ('black promotion', {'board': {'h2': 'p'}, 'ep': None, 'from': 'h2'},
   ['h1b', 'h1n', 'h1q', 'h1r'])]]
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:
Underpromotion to rook, bishop or knight is never offered.

Input: {"board", "from": square of a pawn, "ep": en passant target square or null}. Return sorted pseudo-legal destinations: one step forward if empty; two steps from the starting rank if both squares are empty; diagonal captures of enemy pieces or onto the ep square. A destination on the last rank is expanded into four entries suffixed q, r, b, n.

split: open-access


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

N = 1
observations = []
def solve(x):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   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)

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):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=fr[0]+to[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   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:
Every en passant capture is rejected because the target square is empty.

Input: {"board", "move": [from, to], "ep": target square or null}. Return true when the move is a legal en passant capture: a pawn on its fifth rank moves diagonally forward onto the ep square, an enemy pawn stands beside it on the origin rank, and after removing both pawns from their squares and placing the capturer, no enemy rook, bishop or queen attacks the mover's king along an open line.

split: open-access


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

N = 1
observations = []
def solve(x):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)]]
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=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)]]
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 king and enemy rook on the fifth rank and only the two pawns between them, en passant is allowed.

Input: {"board", "move": [from, to], "ep": target square or null}. Return true when the move is a legal en passant capture: a pawn on its fifth rank moves diagonally forward onto the ep square, an enemy pawn stands beside it on the origin rank, and after removing both pawns from their squares and placing the capturer, no enemy rook, bishop or queen attacks the mover's king along an open line.

split: open-access


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

N = 1
observations = []
def solve(x):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=4: return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   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=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(3 if white else 4): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   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:
A black pawn on d4 cannot capture en passant on e3.

Input: {"board", "move": [from, to], "ep": target square or null}. Return true when the move is a legal en passant capture: a pawn on its fifth rank moves diagonally forward onto the ep square, an enemy pawn stands beside it on the origin rank, and after removing both pawns from their squares and placing the capturer, no enemy rook, bishop or queen attacks the mover's king along an open line.

split: open-access


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

N = 1
observations = []
def solve(x):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or x['ep'] is None: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)]]
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=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to[0]!=x['ep'][0]: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 or dr==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)],
 [('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False)]]
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 ep on d6, a pawn capturing diagonally onto an empty f6 is treated as en passant.

Input: {"board", "move": [from, to], "ep": target square or null}. Return true when the move is a legal en passant capture: a pawn on its fifth rank moves diagonally forward onto the ep square, an enemy pawn stands beside it on the origin rank, and after removing both pawns from their squares and placing the capturer, no enemy rook, bishop or queen attacks the mover's king along an open line.

split: open-access


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

N = 1
observations = []
def solve(x):
    b=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in ('r','q','b'): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)]]
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=dict(x['board']); fr,to=x['move']; p=b.get(fr)
    if p not in ('P','p') or to!=x['ep']: return False
    white=p=='P'
    d=1 if white else -1
    f0,r0=ord(fr[0])-97,int(fr[1])-1
    f1,r1=ord(to[0])-97,int(to[1])-1
    if r1-r0!=d or abs(f1-f0)!=1: return False
    if r0!=(4 if white else 3): return False
    victim=to[0]+fr[1]
    if b.get(victim)!=('p' if white else 'P'): return False
    del b[fr]; del b[victim]; b[to]=p
    ks=[s for s,v in b.items() if v==('K' if white else 'k')][0]
    kf,kr=ord(ks[0])-97,int(ks[1])-1
    for df,dr in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)):
        cf,cr=kf+df,kr+dr
        while 0<=cf<8 and 0<=cr<8:
            v=b.get(chr(97+cf)+str(cr+1))
            if v:
                if v.isupper()!=white and v.lower() in (('r','q') if df==0 else ('b','q')): return False
                break
            cf+=df; cr+=dr
    return True
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True)],
 [('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('wrong target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p'},
    'ep': 'd6',
    'move': ['e5', 'f6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('wrong rank for white',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'd5', 'move': ['e4', 'd5']},
   False),
  ('black wrong rank',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'e4', 'move': ['d5', 'e4']},
   False),
  ('file rook behind pawn',
   {'board': {'d1': 'K', 'd5': 'p', 'd8': 'r', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin both pawns',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False),
  ('same file ep target',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd3', 'move': ['e5', 'd6']},
   False),
  ('pin by own rook harmless',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'R'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)],
 [('plain ep',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': 'd6', 'move': ['e5', 'd6']},
   True),
  ('black ep',
   {'board': {'d4': 'p', 'e1': 'K', 'e4': 'P', 'e8': 'k'}, 'ep': 'e3', 'move': ['d4', 'e3']},
   True),
  ('rank pin black side',
   {'board': {'a4': 'Q', 'd4': 'p', 'e1': 'K', 'e4': 'P', 'h4': 'k'},
    'ep': 'e3',
    'move': ['d4', 'e3']},
   False),
  ('bishop diagonal after ep',
   {'board': {'c3': 'K', 'e5': 'P', 'e8': 'k', 'f5': 'p', 'f6': 'n', 'h8': 'b'},
    'ep': 'f6',
    'move': ['e5', 'f6']},
   True),
  ('no ep square',
   {'board': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'}, 'ep': None, 'move': ['e5', 'd6']},
   False),
  ('bishop on the rank',
   {'board': {'a5': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'h5': 'b'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on the diagonal',
   {'board': {'c3': 'K', 'd5': 'p', 'e5': 'P', 'e8': 'k', 'g7': 'r'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   True),
  ('rook on file of ep square',
   {'board': {'a1': 'K', 'd1': 'r', 'd5': 'p', 'e5': 'P', 'e8': 'k'},
    'ep': 'd6',
    'move': ['e5', 'd6']},
   False)]]
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:
En passant is rejected because a rook sits on a diagonal from the king.

Input: {"board", "move": [from, to], "ep": target square or null}. Return true when the move is a legal en passant capture: a pawn on its fifth rank moves diagonally forward onto the ep square, an enemy pawn stands beside it on the origin rank, and after removing both pawns from their squares and placing the capturer, no enemy rook, bishop or queen attacks the mover's king along an open line.

split: open-access