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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign=''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative sign emission', [-1, '35mm4'], '-0+01'), ('regression variant: negative sign emission', [-32, '35mm2'], '-1+00'), ('partial repair probe: negative sign emission', [0, '35mm4'], '0+00'), ('partial repair variant: negative sign emission', [0, '16mm'], '0+00'), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', ['-0+05', '35mm4'], -5), ('normal control', ['2+39', '16mm'], 119), ('normal control', ['0+01', '35mm4'], 1)], [('regression: negative sign emission', [-1, '35mm2'], '-0+01'), ('regression variant: negative sign emission', [-5, '35mm2'], '-0+05'), ('partial repair probe: negative sign emission', [0, '16mm'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm2'], '0+00'), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', ['100+31', '35mm2'], 3231), ('normal control', ['100+16', '16mm'], 4016), ('normal control', ['-0+40', '16mm'], None)], [('regression: negative sign emission', [-43, '16mm'], '-1+03'), ('regression variant: negative sign emission', [-5, '35mm4'], '-0+05'), ('partial repair probe: negative sign emission', [0, '35mm2'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm4'], '0+00'), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', ['1+00', '35mm4'], 16), ('normal control', ['1+20', '16mm'], 60)], [('regression: negative sign emission', [-5, '16mm'], '-0+05'), ('regression variant: negative sign emission', [-16, '35mm4'], '-1+00'), ('partial repair probe: negative sign emission', [0, '35mm4'], '0+00'), ('partial repair variant: negative sign emission', [0, '16mm'], '0+00'), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', ['-0+05', '35mm4'], -5), ('normal control', ['0+20', '35mm4'], None), ('normal control', [1, '35mm2'], '0+01'), ('normal control', ['0+15', '35mm4'], 15)], [('regression: negative sign emission', [-40, '16mm'], '-1+00'), ('regression variant: negative sign emission', [-35, '35mm2'], '-1+03'), ('partial repair probe: negative sign emission', [0, '16mm'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm2'], '0+00'), ('boundary control', ['2+39', '16mm'], 119), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', ['-0+15', '35mm4'], -15), ('normal control', ['-3+00', '35mm2'], -96), ('normal control', [999, '16mm'], '24+39')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<=0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative sign emission', [-1, '35mm4'], '-0+01'), ('regression variant: negative sign emission', [-32, '35mm2'], '-1+00'), ('partial repair probe: negative sign emission', [0, '35mm4'], '0+00'), ('partial repair variant: negative sign emission', [0, '16mm'], '0+00'), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', ['-0+05', '35mm4'], -5), ('normal control', ['2+39', '16mm'], 119), ('normal control', ['0+01', '35mm4'], 1)], [('regression: negative sign emission', [-1, '35mm2'], '-0+01'), ('regression variant: negative sign emission', [-5, '35mm2'], '-0+05'), ('partial repair probe: negative sign emission', [0, '16mm'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm2'], '0+00'), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', ['100+31', '35mm2'], 3231), ('normal control', ['100+16', '16mm'], 4016), ('normal control', ['-0+40', '16mm'], None)], [('regression: negative sign emission', [-43, '16mm'], '-1+03'), ('regression variant: negative sign emission', [-5, '35mm4'], '-0+05'), ('partial repair probe: negative sign emission', [0, '35mm2'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm4'], '0+00'), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', ['1+00', '35mm4'], 16), ('normal control', ['1+20', '16mm'], 60)], [('regression: negative sign emission', [-5, '16mm'], '-0+05'), ('regression variant: negative sign emission', [-16, '35mm4'], '-1+00'), ('partial repair probe: negative sign emission', [0, '35mm4'], '0+00'), ('partial repair variant: negative sign emission', [0, '16mm'], '0+00'), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', ['-0+05', '35mm4'], -5), ('normal control', ['0+20', '35mm4'], None), ('normal control', [1, '35mm2'], '0+01'), ('normal control', ['0+15', '35mm4'], 15)], [('regression: negative sign emission', [-40, '16mm'], '-1+00'), ('regression variant: negative sign emission', [-35, '35mm2'], '-1+03'), ('partial repair probe: negative sign emission', [0, '16mm'], '0+00'), ('partial repair variant: negative sign emission', [0, '35mm2'], '0+00'), ('boundary control', ['2+39', '16mm'], 119), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', ['-0+15', '35mm4'], -15), ('normal control', ['-3+00', '35mm2'], -96), ('normal control', [999, '16mm'], '24+39')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative footage counts print as positive footage.

Frames per foot: 35mm4 16, 35mm2 32, 16mm 40. An int frame count converts to "[-]F+ff" (feet, two-digit frames, sign in front for negatives); a string "[-]F+ff" converts to a signed frame count, with ff below frames per foot (else None). "-0+05" means -5.

split: open-access


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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field bound', ['0+16', '35mm4'], None), ('regression variant: frame field bound', ['-0+32', '35mm2'], None), ('partial repair probe: frame field bound', ['100+16', '16mm'], 4016), ('partial repair variant: frame field bound', ['-3+16', '16mm'], -136), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+01', '35mm4'], 1), ('normal control', [-1, '35mm2'], '-0+01')], [('regression: frame field bound', ['-0+40', '16mm'], None), ('regression variant: frame field bound', ['0+32', '35mm2'], None), ('partial repair probe: frame field bound', ['100+16', '35mm2'], 3216), ('partial repair variant: frame field bound', ['-1+20', '16mm'], -60), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', [1, '16mm'], '0+01'), ('normal control', [0, '16mm'], '0+00'), ('normal control', [-43, '16mm'], '-1+03')], [('regression: frame field bound', ['-3+32', '35mm2'], None), ('regression variant: frame field bound', ['12+16', '35mm4'], None), ('partial repair probe: frame field bound', ['-3+20', '35mm2'], -116), ('partial repair variant: frame field bound', ['-0+31', '16mm'], -31), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['-3+31', '35mm4'], None), ('normal control', [-32, '35mm2'], '-1+00'), ('normal control', [39, '16mm'], '0+39')], [('regression: frame field bound', ['-0+16', '35mm4'], None), ('regression variant: frame field bound', ['12+40', '16mm'], None), ('partial repair probe: frame field bound', ['1+20', '16mm'], 60), ('partial repair variant: frame field bound', ['-1+32', '16mm'], -72), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', ['-0+05', '35mm4'], -5), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [33, '35mm2'], '1+01'), ('normal control', ['-0+00', '35mm4'], 0)], [('regression: frame field bound', ['-3+16', '35mm4'], None), ('regression variant: frame field bound', ['100+16', '35mm4'], None), ('partial repair probe: frame field bound', ['1+16', '35mm2'], 48), ('partial repair variant: frame field bound', ['100+39', '16mm'], 4039), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [999, '16mm'], '24+39'), ('normal control', ['-3+40', '35mm4'], None), ('normal control', ['100+31', '35mm4'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=16:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field bound', ['0+16', '35mm4'], None), ('regression variant: frame field bound', ['-0+32', '35mm2'], None), ('partial repair probe: frame field bound', ['100+16', '16mm'], 4016), ('partial repair variant: frame field bound', ['-3+16', '16mm'], -136), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+01', '35mm4'], 1), ('normal control', [-1, '35mm2'], '-0+01')], [('regression: frame field bound', ['-0+40', '16mm'], None), ('regression variant: frame field bound', ['0+32', '35mm2'], None), ('partial repair probe: frame field bound', ['100+16', '35mm2'], 3216), ('partial repair variant: frame field bound', ['-1+20', '16mm'], -60), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', [1, '16mm'], '0+01'), ('normal control', [0, '16mm'], '0+00'), ('normal control', [-43, '16mm'], '-1+03')], [('regression: frame field bound', ['-3+32', '35mm2'], None), ('regression variant: frame field bound', ['12+16', '35mm4'], None), ('partial repair probe: frame field bound', ['-3+20', '35mm2'], -116), ('partial repair variant: frame field bound', ['-0+31', '16mm'], -31), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['-3+31', '35mm4'], None), ('normal control', [-32, '35mm2'], '-1+00'), ('normal control', [39, '16mm'], '0+39')], [('regression: frame field bound', ['-0+16', '35mm4'], None), ('regression variant: frame field bound', ['12+40', '16mm'], None), ('partial repair probe: frame field bound', ['1+20', '16mm'], 60), ('partial repair variant: frame field bound', ['-1+32', '16mm'], -72), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', ['-0+05', '35mm4'], -5), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [33, '35mm2'], '1+01'), ('normal control', ['-0+00', '35mm4'], 0)], [('regression: frame field bound', ['-3+16', '35mm4'], None), ('regression variant: frame field bound', ['100+16', '35mm4'], None), ('partial repair probe: frame field bound', ['1+16', '35mm2'], 48), ('partial repair variant: frame field bound', ['100+39', '16mm'], 4039), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [999, '16mm'], '24+39'), ('normal control', ['-3+40', '35mm4'], None), ('normal control', ['100+31', '35mm4'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A frame field equal to the frames per foot is accepted.

Frames per foot: 35mm4 16, 35mm2 32, 16mm 40. An int frame count converts to "[-]F+ff" (feet, two-digit frames, sign in front for negatives); a string "[-]F+ff" converts to a signed frame count, with ff below frames per foot (else None). "-0+05" means -5.

split: open-access


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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if int(ft)<0 else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative zero feet', ['-0+05', '35mm4'], -5), ('regression variant: negative zero feet', ['-0+01', '16mm'], -1), ('partial repair probe: negative zero feet', ['-0+01', '35mm4'], -1), ('partial repair variant: negative zero feet', ['-0+15', '35mm4'], -15), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['2+39', '16mm'], 119), ('normal control', ['0+01', '35mm4'], 1)], [('regression: negative zero feet', ['-0+15', '35mm4'], -15), ('regression variant: negative zero feet', ['-0+20', '16mm'], -20), ('partial repair probe: negative zero feet', ['-0+31', '16mm'], -31), ('partial repair variant: negative zero feet', ['-0+01', '35mm4'], -1), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['2+39', '16mm'], 119), ('normal control', ['-3+20', '35mm4'], None), ('normal control', ['12+32', '35mm4'], None), ('normal control', [15, '35mm4'], '0+15')], [('regression: negative zero feet', ['-0+01', '35mm4'], -1), ('regression variant: negative zero feet', ['-0+15', '16mm'], -15), ('partial repair probe: negative zero feet', ['-0+01', '35mm2'], -1), ('partial repair variant: negative zero feet', ['-0+31', '16mm'], -31), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['-0+40', '16mm'], None), ('normal control', [-43, '16mm'], '-1+03'), ('normal control', ['-3+31', '35mm4'], None)], [('regression: negative zero feet', ['-0+31', '16mm'], -31), ('regression variant: negative zero feet', ['-0+16', '16mm'], -16), ('partial repair probe: negative zero feet', ['-0+01', '16mm'], -1), ('partial repair variant: negative zero feet', ['-0+01', '35mm2'], -1), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['-3+20', '35mm2'], -116), ('normal control', ['-3+32', '35mm2'], None), ('normal control', ['-0+16', '35mm4'], None)], [('regression: negative zero feet', ['-0+01', '35mm2'], -1), ('regression variant: negative zero feet', ['-0+05', '35mm4'], -5), ('partial repair probe: negative zero feet', ['-0+20', '16mm'], -20), ('partial repair variant: negative zero feet', ['-0+01', '16mm'], -1), ('boundary control', ['2+39', '16mm'], 119), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [39, '16mm'], '0+39'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [-5, '35mm2'], '-0+05')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if int(ft)<0 or n<0 else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative zero feet', ['-0+05', '35mm4'], -5), ('regression variant: negative zero feet', ['-0+01', '16mm'], -1), ('partial repair probe: negative zero feet', ['-0+01', '35mm4'], -1), ('partial repair variant: negative zero feet', ['-0+15', '35mm4'], -15), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['2+39', '16mm'], 119), ('normal control', ['0+01', '35mm4'], 1)], [('regression: negative zero feet', ['-0+15', '35mm4'], -15), ('regression variant: negative zero feet', ['-0+20', '16mm'], -20), ('partial repair probe: negative zero feet', ['-0+31', '16mm'], -31), ('partial repair variant: negative zero feet', ['-0+01', '35mm4'], -1), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['2+39', '16mm'], 119), ('normal control', ['-3+20', '35mm4'], None), ('normal control', ['12+32', '35mm4'], None), ('normal control', [15, '35mm4'], '0+15')], [('regression: negative zero feet', ['-0+01', '35mm4'], -1), ('regression variant: negative zero feet', ['-0+15', '16mm'], -15), ('partial repair probe: negative zero feet', ['-0+01', '35mm2'], -1), ('partial repair variant: negative zero feet', ['-0+31', '16mm'], -31), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['-0+40', '16mm'], None), ('normal control', [-43, '16mm'], '-1+03'), ('normal control', ['-3+31', '35mm4'], None)], [('regression: negative zero feet', ['-0+31', '16mm'], -31), ('regression variant: negative zero feet', ['-0+16', '16mm'], -16), ('partial repair probe: negative zero feet', ['-0+01', '16mm'], -1), ('partial repair variant: negative zero feet', ['-0+01', '35mm2'], -1), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['-3+20', '35mm2'], -116), ('normal control', ['-3+32', '35mm2'], None), ('normal control', ['-0+16', '35mm4'], None)], [('regression: negative zero feet', ['-0+01', '35mm2'], -1), ('regression variant: negative zero feet', ['-0+05', '35mm4'], -5), ('partial repair probe: negative zero feet', ['-0+20', '16mm'], -20), ('partial repair variant: negative zero feet', ['-0+01', '16mm'], -1), ('boundary control', ['2+39', '16mm'], 119), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [39, '16mm'], '0+39'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [-5, '35mm2'], '-0+05')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative footage within the first foot, such as -0+05, is read as positive.

Frames per foot: 35mm4 16, 35mm2 32, 16mm 40. An int frame count converts to "[-]F+ff" (feet, two-digit frames, sign in front for negatives); a string "[-]F+ff" converts to a signed frame count, with ff below frames per foot (else None). "-0+05" means -5.

split: open-access


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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=int(ft)*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: magnitude composition', ['-3+20', '35mm2'], -116), ('regression variant: magnitude composition', ['-1+20', '16mm'], -60), ('partial repair probe: magnitude composition', ['-3+16', '16mm'], -136), ('partial repair variant: magnitude composition', ['-3+01', '35mm4'], -49), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+16', '35mm4'], None), ('normal control', ['2+39', '16mm'], 119)], [('regression: magnitude composition', ['-3+00', '35mm2'], -96), ('regression variant: magnitude composition', ['-1+32', '16mm'], -72), ('partial repair probe: magnitude composition', ['-3+15', '16mm'], -135), ('partial repair variant: magnitude composition', ['-1+31', '35mm2'], -63), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm2'], '-0+01'), ('normal control', [1, '16mm'], '0+01'), ('normal control', ['100+16', '16mm'], 4016)], [('regression: magnitude composition', ['-3+01', '35mm2'], -97), ('regression variant: magnitude composition', ['-3+15', '35mm2'], -111), ('partial repair probe: magnitude composition', ['-1+20', '16mm'], -60), ('partial repair variant: magnitude composition', ['-1+20', '35mm2'], -52), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', [0, '16mm'], '0+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', [-5, '16mm'], '-0+05')], [('regression: magnitude composition', ['-3+16', '16mm'], -136), ('regression variant: magnitude composition', ['-1+15', '35mm4'], -31), ('partial repair probe: magnitude composition', ['-1+32', '16mm'], -72), ('partial repair variant: magnitude composition', ['-3+31', '16mm'], -151), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', [-40, '16mm'], '-1+00'), ('normal control', ['-3+32', '35mm2'], None), ('normal control', ['-0+16', '35mm4'], None)], [('regression: magnitude composition', ['-3+15', '16mm'], -135), ('regression variant: magnitude composition', ['-3+00', '35mm4'], -48), ('partial repair probe: magnitude composition', ['-3+15', '35mm2'], -111), ('partial repair variant: magnitude composition', ['-3+20', '16mm'], -140), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', [39, '16mm'], '0+39'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [-5, '35mm2'], '-0+05')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%per)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft)*per+int(fr))
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: magnitude composition', ['-3+20', '35mm2'], -116), ('regression variant: magnitude composition', ['-1+20', '16mm'], -60), ('partial repair probe: magnitude composition', ['-3+16', '16mm'], -136), ('partial repair variant: magnitude composition', ['-3+01', '35mm4'], -49), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+16', '35mm4'], None), ('normal control', ['2+39', '16mm'], 119)], [('regression: magnitude composition', ['-3+00', '35mm2'], -96), ('regression variant: magnitude composition', ['-1+32', '16mm'], -72), ('partial repair probe: magnitude composition', ['-3+15', '16mm'], -135), ('partial repair variant: magnitude composition', ['-1+31', '35mm2'], -63), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm2'], '-0+01'), ('normal control', [1, '16mm'], '0+01'), ('normal control', ['100+16', '16mm'], 4016)], [('regression: magnitude composition', ['-3+01', '35mm2'], -97), ('regression variant: magnitude composition', ['-3+15', '35mm2'], -111), ('partial repair probe: magnitude composition', ['-1+20', '16mm'], -60), ('partial repair variant: magnitude composition', ['-1+20', '35mm2'], -52), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', [0, '16mm'], '0+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', [-5, '16mm'], '-0+05')], [('regression: magnitude composition', ['-3+16', '16mm'], -136), ('regression variant: magnitude composition', ['-1+15', '35mm4'], -31), ('partial repair probe: magnitude composition', ['-1+32', '16mm'], -72), ('partial repair variant: magnitude composition', ['-3+31', '16mm'], -151), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', [-40, '16mm'], '-1+00'), ('normal control', ['-3+32', '35mm2'], None), ('normal control', ['-0+16', '35mm4'], None)], [('regression: magnitude composition', ['-3+15', '16mm'], -135), ('regression variant: magnitude composition', ['-3+00', '35mm4'], -48), ('partial repair probe: magnitude composition', ['-3+15', '35mm2'], -111), ('partial repair variant: magnitude composition', ['-3+20', '16mm'], -140), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', [39, '16mm'], '0+39'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', [-5, '35mm2'], '-0+05')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative footage with frames converts to a count several frames too small.

Frames per foot: 35mm4 16, 35mm2 32, 16mm 40. An int frame count converts to "[-]F+ff" (feet, two-digit frames, sign in front for negatives); a string "[-]F+ff" converts to a signed frame count, with ff below frames per foot (else None). "-0+05" means -5.

split: open-access


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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//16,v%16)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: foot divisor', [-43, '16mm'], '-1+03'), ('regression variant: foot divisor', [999, '16mm'], '24+39'), ('partial repair probe: foot divisor', [39, '16mm'], '0+39'), ('partial repair variant: foot divisor', [4080, '35mm2'], '127+16'), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+16', '35mm4'], None), ('normal control', ['2+39', '16mm'], 119)], [('regression: foot divisor', [-40, '16mm'], '-1+00'), ('regression variant: foot divisor', [31, '35mm2'], '0+31'), ('partial repair probe: foot divisor', [999, '16mm'], '24+39'), ('partial repair variant: foot divisor', [40, '16mm'], '1+00'), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm2'], '-0+01'), ('normal control', [1, '16mm'], '0+01'), ('normal control', ['100+16', '16mm'], 4016)], [('regression: foot divisor', [-32, '35mm2'], '-1+00'), ('regression variant: foot divisor', [41, '16mm'], '1+01'), ('partial repair probe: foot divisor', [31, '35mm2'], '0+31'), ('partial repair variant: foot divisor', [1422, '16mm'], '35+22'), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', [0, '16mm'], '0+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', ['-3+31', '35mm4'], None)], [('regression: foot divisor', [39, '16mm'], '0+39'), ('regression variant: foot divisor', [999, '35mm2'], '31+07'), ('partial repair probe: foot divisor', [41, '16mm'], '1+01'), ('partial repair variant: foot divisor', [2711, '16mm'], '67+31'), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['1+00', '35mm4'], 16), ('normal control', ['-0+16', '35mm4'], None), ('normal control', ['1+16', '35mm2'], 48)], [('regression: foot divisor', [33, '35mm2'], '1+01'), ('regression variant: foot divisor', [-35, '35mm2'], '-1+03'), ('partial repair probe: foot divisor', [2612, '35mm2'], '81+20'), ('partial repair variant: foot divisor', [3865, '16mm'], '96+25'), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', ['-0+15', '35mm4'], -15), ('normal control', ['-3+16', '35mm4'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(value, gauge):
    per={'35mm4':16,'35mm2':32,'16mm':40}[gauge]
    if isinstance(value,int):
        sign='-' if value<0 else ''
        v=abs(value)
        return '%s%d+%02d'%(sign,v//per,v%16)
    ft,fr=value.split('+')
    if int(fr)>=per:
        return None
    n=abs(int(ft))*per+int(fr)
    return -n if ft.startswith('-') else n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: foot divisor', [-43, '16mm'], '-1+03'), ('regression variant: foot divisor', [999, '16mm'], '24+39'), ('partial repair probe: foot divisor', [39, '16mm'], '0+39'), ('partial repair variant: foot divisor', [4080, '35mm2'], '127+16'), ('boundary control', [16, '35mm4'], '1+00'), ('boundary control', ['1+15', '35mm4'], 31), ('normal control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+16', '35mm4'], None), ('normal control', ['2+39', '16mm'], 119)], [('regression: foot divisor', [-40, '16mm'], '-1+00'), ('regression variant: foot divisor', [31, '35mm2'], '0+31'), ('partial repair probe: foot divisor', [999, '16mm'], '24+39'), ('partial repair variant: foot divisor', [40, '16mm'], '1+00'), ('boundary control', [-1, '35mm4'], '-0+01'), ('boundary control', ['0+16', '35mm4'], None), ('normal control', [-1, '35mm2'], '-0+01'), ('normal control', [1, '16mm'], '0+01'), ('normal control', ['100+16', '16mm'], 4016)], [('regression: foot divisor', [-32, '35mm2'], '-1+00'), ('regression variant: foot divisor', [41, '16mm'], '1+01'), ('partial repair probe: foot divisor', [31, '35mm2'], '0+31'), ('partial repair variant: foot divisor', [1422, '16mm'], '35+22'), ('boundary control', ['-0+05', '35mm4'], -5), ('boundary control', ['2+39', '16mm'], 119), ('normal control', [0, '16mm'], '0+00'), ('normal control', ['100+16', '35mm2'], 3216), ('normal control', ['-3+31', '35mm4'], None)], [('regression: foot divisor', [39, '16mm'], '0+39'), ('regression variant: foot divisor', [999, '35mm2'], '31+07'), ('partial repair probe: foot divisor', [41, '16mm'], '1+01'), ('partial repair variant: foot divisor', [2711, '16mm'], '67+31'), ('boundary control', ['1+15', '35mm4'], 31), ('boundary control', [16, '35mm4'], '1+00'), ('normal control', ['1+00', '35mm4'], 16), ('normal control', ['-0+16', '35mm4'], None), ('normal control', ['1+16', '35mm2'], 48)], [('regression: foot divisor', [33, '35mm2'], '1+01'), ('regression variant: foot divisor', [-35, '35mm2'], '-1+03'), ('partial repair probe: foot divisor', [2612, '35mm2'], '81+20'), ('partial repair variant: foot divisor', [3865, '16mm'], '96+25'), ('boundary control', ['0+16', '35mm4'], None), ('boundary control', [-1, '35mm4'], '-0+01'), ('normal control', ['0+00', '35mm2'], 0), ('normal control', ['-0+15', '35mm4'], -15), ('normal control', ['-3+16', '35mm4'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Converted 16mm footage shows three times too many feet.

Frames per foot: 35mm4 16, 35mm2 32, 16mm 40. An int frame count converts to "[-]F+ff" (feet, two-digit frames, sign in front for negatives); a string "[-]F+ff" converts to a signed frame count, with ff below frames per foot (else None). "-0+05" means -5.

split: open-access


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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 5*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cadence group size', [4, 0], [5, 'upper', 2]), ('regression variant: cadence group size', [34, 2], [42, 'lower', 2]), ('partial repair probe: cadence group size', [8, 0], [10, 'upper', 2]), ('partial repair variant: cadence group size', [26, 2], [32, 'lower', 2]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [1, 0], [1, 'upper', 3]), ('normal control', [-3, 2], None), ('normal control', [-4, 2], None)], [('regression: cadence group size', [2, 3], [2, 'lower', 3]), ('regression variant: cadence group size', [9, 3], [11, 'lower', 2]), ('partial repair probe: cadence group size', [9, 1], [11, 'lower', 2]), ('partial repair variant: cadence group size', [36, 1], [45, 'upper', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-2, 3], None), ('normal control', [-6, 1], None), ('normal control', [-3, 0], None)], [('regression: cadence group size', [8, 0], [10, 'upper', 2]), ('regression variant: cadence group size', [10, 1], [12, 'lower', 3]), ('partial repair probe: cadence group size', [35, 1], [44, 'upper', 2]), ('partial repair variant: cadence group size', [38, 3], [47, 'lower', 3]), ('boundary control', [3, 0], [3, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('normal control', [-1, 1], None), ('normal control', [-3, 3], None), ('normal control', [-5, 3], None)], [('regression: cadence group size', [9, 1], [11, 'lower', 2]), ('regression variant: cadence group size', [22, 2], [27, 'lower', 2]), ('partial repair probe: cadence group size', [34, 2], [42, 'lower', 2]), ('partial repair variant: cadence group size', [1, 3], [1, 'lower', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('boundary control', [3, 0], [3, 'lower', 3]), ('normal control', [-1, 0], None), ('normal control', [1, 2], [1, 'upper', 3]), ('normal control', [2, 1], [2, 'lower', 3])], [('regression: cadence group size', [35, 1], [44, 'upper', 2]), ('regression variant: cadence group size', [26, 2], [32, 'lower', 2]), ('partial repair probe: cadence group size', [9, 3], [11, 'lower', 2]), ('partial repair variant: cadence group size', [3, 2], [3, 'lower', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [-1, 2], None), ('normal control', [0, 3], [0, 'upper', 3]), ('normal control', [1, 0], [1, 'upper', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 8*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cadence group size', [4, 0], [5, 'upper', 2]), ('regression variant: cadence group size', [34, 2], [42, 'lower', 2]), ('partial repair probe: cadence group size', [8, 0], [10, 'upper', 2]), ('partial repair variant: cadence group size', [26, 2], [32, 'lower', 2]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [1, 0], [1, 'upper', 3]), ('normal control', [-3, 2], None), ('normal control', [-4, 2], None)], [('regression: cadence group size', [2, 3], [2, 'lower', 3]), ('regression variant: cadence group size', [9, 3], [11, 'lower', 2]), ('partial repair probe: cadence group size', [9, 1], [11, 'lower', 2]), ('partial repair variant: cadence group size', [36, 1], [45, 'upper', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-2, 3], None), ('normal control', [-6, 1], None), ('normal control', [-3, 0], None)], [('regression: cadence group size', [8, 0], [10, 'upper', 2]), ('regression variant: cadence group size', [10, 1], [12, 'lower', 3]), ('partial repair probe: cadence group size', [35, 1], [44, 'upper', 2]), ('partial repair variant: cadence group size', [38, 3], [47, 'lower', 3]), ('boundary control', [3, 0], [3, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('normal control', [-1, 1], None), ('normal control', [-3, 3], None), ('normal control', [-5, 3], None)], [('regression: cadence group size', [9, 1], [11, 'lower', 2]), ('regression variant: cadence group size', [22, 2], [27, 'lower', 2]), ('partial repair probe: cadence group size', [34, 2], [42, 'lower', 2]), ('partial repair variant: cadence group size', [1, 3], [1, 'lower', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('boundary control', [3, 0], [3, 'lower', 3]), ('normal control', [-1, 0], None), ('normal control', [1, 2], [1, 'upper', 3]), ('normal control', [2, 1], [2, 'lower', 3])], [('regression: cadence group size', [35, 1], [44, 'upper', 2]), ('regression variant: cadence group size', [26, 2], [32, 'lower', 2]), ('partial repair probe: cadence group size', [9, 3], [11, 'lower', 2]), ('partial repair variant: cadence group size', [3, 2], [3, 'lower', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [-1, 2], None), ('normal control', [0, 3], [0, 'upper', 3]), ('normal control', [1, 0], [1, 'upper', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Film frames after the first cadence group map to video frames far too early.

Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].

split: open-access


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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,4,6][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field offset table', [3, 0], [3, 'lower', 3]), ('regression variant: field offset table', [10, 1], [12, 'lower', 3]), ('partial repair probe: field offset table', [9, 1], [11, 'lower', 2]), ('partial repair variant: field offset table', [21, 2], [26, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [0, 1], [0, 'upper', 3]), ('normal control', [8, 0], [10, 'upper', 2]), ('normal control', [36, 1], [45, 'upper', 3])], [('regression: field offset table', [2, 3], [2, 'lower', 3]), ('regression variant: field offset table', [22, 2], [27, 'lower', 2]), ('partial repair probe: field offset table', [35, 1], [44, 'upper', 2]), ('partial repair variant: field offset table', [19, 2], [23, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [-6, 0], None), ('normal control', [-2, 3], None), ('normal control', [-3, 1], None)], [('regression: field offset table', [9, 1], [11, 'lower', 2]), ('regression variant: field offset table', [26, 2], [32, 'lower', 2]), ('partial repair probe: field offset table', [9, 3], [11, 'lower', 2]), ('partial repair variant: field offset table', [17, 1], [21, 'lower', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-6, 1], None), ('normal control', [-3, 0], None), ('normal control', [8, 3], [10, 'upper', 3])], [('regression: field offset table', [34, 2], [42, 'lower', 2]), ('regression variant: field offset table', [38, 3], [47, 'lower', 3]), ('partial repair probe: field offset table', [1, 3], [1, 'lower', 2]), ('partial repair variant: field offset table', [5, 2], [6, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [-1, 1], None), ('normal control', [36, 0], [45, 'upper', 2]), ('normal control', [-3, 3], None)], [('regression: field offset table', [9, 3], [11, 'lower', 2]), ('regression variant: field offset table', [1, 3], [1, 'lower', 2]), ('partial repair probe: field offset table', [3, 2], [3, 'lower', 3]), ('partial repair variant: field offset table', [7, 2], [8, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [28, 0], [35, 'upper', 2]), ('normal control', [28, 3], [35, 'upper', 3]), ('normal control', [24, 1], [30, 'upper', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,3,5,8][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field offset table', [3, 0], [3, 'lower', 3]), ('regression variant: field offset table', [10, 1], [12, 'lower', 3]), ('partial repair probe: field offset table', [9, 1], [11, 'lower', 2]), ('partial repair variant: field offset table', [21, 2], [26, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [0, 1], [0, 'upper', 3]), ('normal control', [8, 0], [10, 'upper', 2]), ('normal control', [36, 1], [45, 'upper', 3])], [('regression: field offset table', [2, 3], [2, 'lower', 3]), ('regression variant: field offset table', [22, 2], [27, 'lower', 2]), ('partial repair probe: field offset table', [35, 1], [44, 'upper', 2]), ('partial repair variant: field offset table', [19, 2], [23, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [-6, 0], None), ('normal control', [-2, 3], None), ('normal control', [-3, 1], None)], [('regression: field offset table', [9, 1], [11, 'lower', 2]), ('regression variant: field offset table', [26, 2], [32, 'lower', 2]), ('partial repair probe: field offset table', [9, 3], [11, 'lower', 2]), ('partial repair variant: field offset table', [17, 1], [21, 'lower', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-6, 1], None), ('normal control', [-3, 0], None), ('normal control', [8, 3], [10, 'upper', 3])], [('regression: field offset table', [34, 2], [42, 'lower', 2]), ('regression variant: field offset table', [38, 3], [47, 'lower', 3]), ('partial repair probe: field offset table', [1, 3], [1, 'lower', 2]), ('partial repair variant: field offset table', [5, 2], [6, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [-1, 1], None), ('normal control', [36, 0], [45, 'upper', 2]), ('normal control', [-3, 3], None)], [('regression: field offset table', [9, 3], [11, 'lower', 2]), ('regression variant: field offset table', [1, 3], [1, 'lower', 2]), ('partial repair probe: field offset table', [3, 2], [3, 'lower', 3]), ('partial repair variant: field offset table', [7, 2], [8, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [0, 1], [0, 'upper', 3]), ('normal control', [28, 0], [35, 'upper', 2]), ('normal control', [28, 3], [35, 'upper', 3]), ('normal control', [24, 1], [30, 'upper', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
B-frames are placed as if every film frame had two fields.

Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].

split: open-access


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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: phase alignment', [0, 1], [0, 'upper', 3]), ('regression variant: phase alignment', [9, 3], [11, 'lower', 2]), ('partial repair probe: phase alignment', [9, 1], [11, 'lower', 2]), ('partial repair variant: phase alignment', [36, 1], [45, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [1, 0], [1, 'upper', 3]), ('normal control', [8, 0], [10, 'upper', 2]), ('normal control', [-3, 2], None)], [('regression: phase alignment', [2, 3], [2, 'lower', 3]), ('regression variant: phase alignment', [10, 1], [12, 'lower', 3]), ('partial repair probe: phase alignment', [35, 1], [44, 'upper', 2]), ('partial repair variant: phase alignment', [38, 3], [47, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-6, 0], None), ('normal control', [-3, 1], None), ('normal control', [-6, 1], None)], [('regression: phase alignment', [9, 1], [11, 'lower', 2]), ('regression variant: phase alignment', [22, 2], [27, 'lower', 2]), ('partial repair probe: phase alignment', [34, 2], [42, 'lower', 2]), ('partial repair variant: phase alignment', [1, 3], [1, 'lower', 2]), ('boundary control', [3, 0], [3, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None), ('normal control', [-5, 2], None)], [('regression: phase alignment', [35, 1], [44, 'upper', 2]), ('regression variant: phase alignment', [26, 2], [32, 'lower', 2]), ('partial repair probe: phase alignment', [9, 3], [11, 'lower', 2]), ('partial repair variant: phase alignment', [3, 2], [3, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [3, 0], [3, 'lower', 3]), ('normal control', [33, 0], [41, 'upper', 3]), ('normal control', [24, 0], [30, 'upper', 2]), ('normal control', [-4, 1], None)], [('regression: phase alignment', [34, 2], [42, 'lower', 2]), ('regression variant: phase alignment', [36, 1], [45, 'upper', 3]), ('partial repair probe: phase alignment', [10, 1], [12, 'lower', 3]), ('partial repair variant: phase alignment', [39, 2], [48, 'lower', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [31, 0], [38, 'lower', 3]), ('normal control', [37, 0], [46, 'upper', 3]), ('normal control', [11, 0], [13, 'lower', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-phase
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: phase alignment', [0, 1], [0, 'upper', 3]), ('regression variant: phase alignment', [9, 3], [11, 'lower', 2]), ('partial repair probe: phase alignment', [9, 1], [11, 'lower', 2]), ('partial repair variant: phase alignment', [36, 1], [45, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [1, 0], [1, 'upper', 3]), ('normal control', [8, 0], [10, 'upper', 2]), ('normal control', [-3, 2], None)], [('regression: phase alignment', [2, 3], [2, 'lower', 3]), ('regression variant: phase alignment', [10, 1], [12, 'lower', 3]), ('partial repair probe: phase alignment', [35, 1], [44, 'upper', 2]), ('partial repair variant: phase alignment', [38, 3], [47, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('normal control', [-6, 0], None), ('normal control', [-3, 1], None), ('normal control', [-6, 1], None)], [('regression: phase alignment', [9, 1], [11, 'lower', 2]), ('regression variant: phase alignment', [22, 2], [27, 'lower', 2]), ('partial repair probe: phase alignment', [34, 2], [42, 'lower', 2]), ('partial repair variant: phase alignment', [1, 3], [1, 'lower', 2]), ('boundary control', [3, 0], [3, 'lower', 3]), ('boundary control', [1, 0], [1, 'upper', 3]), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None), ('normal control', [-5, 2], None)], [('regression: phase alignment', [35, 1], [44, 'upper', 2]), ('regression variant: phase alignment', [26, 2], [32, 'lower', 2]), ('partial repair probe: phase alignment', [9, 3], [11, 'lower', 2]), ('partial repair variant: phase alignment', [3, 2], [3, 'lower', 3]), ('boundary control', [4, 0], [5, 'upper', 2]), ('boundary control', [3, 0], [3, 'lower', 3]), ('normal control', [33, 0], [41, 'upper', 3]), ('normal control', [24, 0], [30, 'upper', 2]), ('normal control', [-4, 1], None)], [('regression: phase alignment', [34, 2], [42, 'lower', 2]), ('regression variant: phase alignment', [36, 1], [45, 'upper', 3]), ('partial repair probe: phase alignment', [10, 1], [12, 'lower', 3]), ('partial repair variant: phase alignment', [39, 2], [48, 'lower', 3]), ('boundary control', [0, 0], [0, 'upper', 2]), ('boundary control', [4, 0], [5, 'upper', 2]), ('normal control', [31, 0], [38, 'lower', 3]), ('normal control', [37, 0], [46, 'upper', 3]), ('normal control', [11, 0], [13, 'lower', 3])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
With a non-zero cadence phase the first film frame does not start at field 0.

Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].

split: open-access


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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][n%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field count lookup', [0, 1], [0, 'upper', 3]), ('regression variant: field count lookup', [10, 1], [12, 'lower', 3]), ('partial repair probe: field count lookup', [3, 0], [3, 'lower', 3]), ('partial repair variant: field count lookup', [34, 2], [42, 'lower', 2]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field count lookup', [2, 3], [2, 'lower', 3]), ('regression variant: field count lookup', [36, 1], [45, 'upper', 3]), ('partial repair probe: field count lookup', [4, 0], [5, 'upper', 2]), ('partial repair variant: field count lookup', [9, 3], [11, 'lower', 2]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field count lookup', [9, 1], [11, 'lower', 2]), ('regression variant: field count lookup', [38, 3], [47, 'lower', 3]), ('partial repair probe: field count lookup', [0, 1], [0, 'upper', 3]), ('partial repair variant: field count lookup', [10, 1], [12, 'lower', 3]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field count lookup', [35, 1], [44, 'upper', 2]), ('regression variant: field count lookup', [1, 3], [1, 'lower', 2]), ('partial repair probe: field count lookup', [2, 3], [2, 'lower', 3]), ('partial repair variant: field count lookup', [22, 2], [27, 'lower', 2]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field count lookup', [9, 3], [11, 'lower', 2]), ('regression variant: field count lookup', [30, 3], [37, 'lower', 3]), ('partial repair probe: field count lookup', [8, 0], [10, 'upper', 2]), ('partial repair variant: field count lookup', [26, 2], [32, 'lower', 2]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[3,2,3,2][a%4]
    return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field count lookup', [0, 1], [0, 'upper', 3]), ('regression variant: field count lookup', [10, 1], [12, 'lower', 3]), ('partial repair probe: field count lookup', [3, 0], [3, 'lower', 3]), ('partial repair variant: field count lookup', [34, 2], [42, 'lower', 2]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field count lookup', [2, 3], [2, 'lower', 3]), ('regression variant: field count lookup', [36, 1], [45, 'upper', 3]), ('partial repair probe: field count lookup', [4, 0], [5, 'upper', 2]), ('partial repair variant: field count lookup', [9, 3], [11, 'lower', 2]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field count lookup', [9, 1], [11, 'lower', 2]), ('regression variant: field count lookup', [38, 3], [47, 'lower', 3]), ('partial repair probe: field count lookup', [0, 1], [0, 'upper', 3]), ('partial repair variant: field count lookup', [10, 1], [12, 'lower', 3]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field count lookup', [35, 1], [44, 'upper', 2]), ('regression variant: field count lookup', [1, 3], [1, 'lower', 2]), ('partial repair probe: field count lookup', [2, 3], [2, 'lower', 3]), ('partial repair variant: field count lookup', [22, 2], [27, 'lower', 2]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field count lookup', [9, 3], [11, 'lower', 2]), ('regression variant: field count lookup', [30, 3], [37, 'lower', 3]), ('partial repair probe: field count lookup', [8, 0], [10, 'upper', 2]), ('partial repair variant: field count lookup', [26, 2], [32, 'lower', 2]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Field counts are wrong whenever the cadence phase is not zero.

Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].

split: open-access


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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if start%2==1 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field parity', [0, 0], [0, 'upper', 2]), ('regression variant: field parity', [2, 3], [2, 'lower', 3]), ('partial repair probe: field parity', [34, 2], [42, 'lower', 2]), ('partial repair variant: field parity', [20, 1], [25, 'upper', 3]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field parity', [1, 0], [1, 'upper', 3]), ('regression variant: field parity', [8, 0], [10, 'upper', 2]), ('partial repair probe: field parity', [34, 2], [42, 'lower', 2]), ('partial repair variant: field parity', [18, 3], [22, 'lower', 3]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field parity', [3, 0], [3, 'lower', 3]), ('regression variant: field parity', [9, 1], [11, 'lower', 2]), ('partial repair probe: field parity', [10, 1], [12, 'lower', 3]), ('partial repair variant: field parity', [20, 0], [25, 'upper', 2]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field parity', [4, 0], [5, 'upper', 2]), ('regression variant: field parity', [35, 1], [44, 'upper', 2]), ('partial repair probe: field parity', [26, 2], [32, 'lower', 2]), ('partial repair variant: field parity', [18, 1], [22, 'lower', 3]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field parity', [0, 1], [0, 'upper', 3]), ('regression variant: field parity', [34, 2], [42, 'lower', 2]), ('partial repair probe: field parity', [36, 1], [45, 'upper', 3]), ('partial repair variant: field parity', [7, 2], [8, 'lower', 3]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(n, phase):
    if n<0:
        return None
    def sf(a):
        return 10*(a//4)+[0,2,5,7][a%4]
    a=n+phase
    start=sf(a)-sf(phase)
    count=[2,3,2,3][a%4]
    return [start//2,'upper' if (start//2)%2==0 else 'lower',count]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field parity', [0, 0], [0, 'upper', 2]), ('regression variant: field parity', [2, 3], [2, 'lower', 3]), ('partial repair probe: field parity', [34, 2], [42, 'lower', 2]), ('partial repair variant: field parity', [20, 1], [25, 'upper', 3]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field parity', [1, 0], [1, 'upper', 3]), ('regression variant: field parity', [8, 0], [10, 'upper', 2]), ('partial repair probe: field parity', [34, 2], [42, 'lower', 2]), ('partial repair variant: field parity', [18, 3], [22, 'lower', 3]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field parity', [3, 0], [3, 'lower', 3]), ('regression variant: field parity', [9, 1], [11, 'lower', 2]), ('partial repair probe: field parity', [10, 1], [12, 'lower', 3]), ('partial repair variant: field parity', [20, 0], [25, 'upper', 2]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field parity', [4, 0], [5, 'upper', 2]), ('regression variant: field parity', [35, 1], [44, 'upper', 2]), ('partial repair probe: field parity', [26, 2], [32, 'lower', 2]), ('partial repair variant: field parity', [18, 1], [22, 'lower', 3]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field parity', [0, 1], [0, 'upper', 3]), ('regression variant: field parity', [34, 2], [42, 'lower', 2]), ('partial repair probe: field parity', [36, 1], [45, 'upper', 3]), ('partial repair variant: field parity', [7, 2], [8, 'lower', 3]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Frames starting on the second field of a video frame are reported as upper field first.

Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].

split: open-access


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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,1,1,1,2,2,2,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field to frame table', [30, 3, 'lower'], [24, 24, 'clean']), ('regression variant: field to frame table', [11, 2, 'upper'], [9, 9, 'clean']), ('partial repair probe: field to frame table', [15, 1, 'upper'], [12, 12, 'clean']), ('partial repair variant: field to frame table', [6, 0, 'upper'], [5, 5, 'clean']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [16, 3, 'upper'], [12, 13, 'mixed']), ('normal control', [10, 2, 'upper'], [8, 8, 'clean'])], [('regression: field to frame table', [23, 0, 'lower'], [19, 18, 'mixed']), ('regression variant: field to frame table', [6, 2, 'upper'], [5, 5, 'clean']), ('partial repair probe: field to frame table', [1, 0, 'upper'], [1, 1, 'clean']), ('partial repair variant: field to frame table', [2, 3, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [0, 0, 'lower'], [0, 0, 'clean']), ('normal control', [-3, 2, 'lower'], None), ('normal control', [28, 1, 'upper'], [22, 22, 'clean'])], [('regression: field to frame table', [17, 1, 'upper'], [13, 14, 'mixed']), ('regression variant: field to frame table', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair probe: field to frame table', [28, 2, 'lower'], [23, 22, 'mixed']), ('partial repair variant: field to frame table', [16, 0, 'upper'], [13, 13, 'clean']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [-4, 3, 'upper'], None), ('normal control', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [17, 2, 'upper'], [13, 14, 'mixed'])], [('regression: field to frame table', [12, 1, 'upper'], [9, 10, 'mixed']), ('regression variant: field to frame table', [21, 2, 'lower'], [17, 17, 'clean']), ('partial repair probe: field to frame table', [22, 3, 'upper'], [17, 18, 'mixed']), ('partial repair variant: field to frame table', [21, 0, 'lower'], [17, 17, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [-5, 0, 'lower'], None), ('normal control', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [9, 3, 'lower'], [7, 7, 'clean'])], [('regression: field to frame table', [16, 2, 'lower'], [13, 13, 'clean']), ('regression variant: field to frame table', [5, 3, 'upper'], [4, 4, 'clean']), ('partial repair probe: field to frame table', [11, 0, 'upper'], [9, 9, 'clean']), ('partial repair variant: field to frame table', [17, 3, 'upper'], [13, 14, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [-5, 1, 'lower'], None), ('normal control', [21, 3, 'upper'], [16, 17, 'mixed']), ('normal control', [22, 2, 'lower'], [18, 17, 'mixed'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,0,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field to frame table', [30, 3, 'lower'], [24, 24, 'clean']), ('regression variant: field to frame table', [11, 2, 'upper'], [9, 9, 'clean']), ('partial repair probe: field to frame table', [15, 1, 'upper'], [12, 12, 'clean']), ('partial repair variant: field to frame table', [6, 0, 'upper'], [5, 5, 'clean']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [16, 3, 'upper'], [12, 13, 'mixed']), ('normal control', [10, 2, 'upper'], [8, 8, 'clean'])], [('regression: field to frame table', [23, 0, 'lower'], [19, 18, 'mixed']), ('regression variant: field to frame table', [6, 2, 'upper'], [5, 5, 'clean']), ('partial repair probe: field to frame table', [1, 0, 'upper'], [1, 1, 'clean']), ('partial repair variant: field to frame table', [2, 3, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [0, 0, 'lower'], [0, 0, 'clean']), ('normal control', [-3, 2, 'lower'], None), ('normal control', [28, 1, 'upper'], [22, 22, 'clean'])], [('regression: field to frame table', [17, 1, 'upper'], [13, 14, 'mixed']), ('regression variant: field to frame table', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair probe: field to frame table', [28, 2, 'lower'], [23, 22, 'mixed']), ('partial repair variant: field to frame table', [16, 0, 'upper'], [13, 13, 'clean']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [-4, 3, 'upper'], None), ('normal control', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [17, 2, 'upper'], [13, 14, 'mixed'])], [('regression: field to frame table', [12, 1, 'upper'], [9, 10, 'mixed']), ('regression variant: field to frame table', [21, 2, 'lower'], [17, 17, 'clean']), ('partial repair probe: field to frame table', [22, 3, 'upper'], [17, 18, 'mixed']), ('partial repair variant: field to frame table', [21, 0, 'lower'], [17, 17, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [-5, 0, 'lower'], None), ('normal control', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [9, 3, 'lower'], [7, 7, 'clean'])], [('regression: field to frame table', [16, 2, 'lower'], [13, 13, 'clean']), ('regression variant: field to frame table', [5, 3, 'upper'], [4, 4, 'clean']), ('partial repair probe: field to frame table', [11, 0, 'upper'], [9, 9, 'clean']), ('partial repair variant: field to frame table', [17, 3, 'upper'], [13, 14, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [-5, 1, 'lower'], None), ('normal control', [21, 3, 'upper'], [16, 17, 'mixed']), ('normal control', [22, 2, 'lower'], [18, 17, 'mixed'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Mixed frames are reported at the wrong video frames.

Fields carry film frames in A2 B3 C2 D3 cadence; film frame 0 has cadence position phase and starts at field 0. Video frame v consists of fields 2v and 2v+1. For order "upper" field 2v is the top field; for "lower" field 2v is the bottom field. Return [film frame in top field, film frame in bottom field, "clean" or "mixed"]; a negative v returns None.

split: open-access


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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v-1)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: second field index', [0, 0, 'upper'], [0, 0, 'clean']), ('regression variant: second field index', [16, 3, 'upper'], [12, 13, 'mixed']), ('partial repair probe: second field index', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair variant: second field index', [4, 1, 'upper'], [3, 3, 'clean']), ('normal control', [-3, 2, 'lower'], None), ('normal control', [-5, 0, 'lower'], None), ('normal control', [-4, 2, 'lower'], None)], [('regression: second field index', [2, 0, 'upper'], [1, 2, 'mixed']), ('regression variant: second field index', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair probe: second field index', [24, 0, 'upper'], [19, 19, 'clean']), ('partial repair variant: second field index', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [-5, 3, 'lower'], None), ('normal control', [-3, 0, 'lower'], None), ('normal control', [-1, 2, 'upper'], None)], [('regression: second field index', [2, 0, 'lower'], [2, 1, 'mixed']), ('regression variant: second field index', [30, 3, 'lower'], [24, 24, 'clean']), ('partial repair probe: second field index', [0, 0, 'lower'], [0, 0, 'clean']), ('partial repair variant: second field index', [25, 2, 'lower'], [20, 20, 'clean']), ('normal control', [-3, 3, 'upper'], None), ('normal control', [-2, 2, 'upper'], None), ('normal control', [-4, 3, 'lower'], None)], [('regression: second field index', [0, 1, 'upper'], [0, 0, 'clean']), ('regression variant: second field index', [0, 0, 'lower'], [0, 0, 'clean']), ('partial repair probe: second field index', [20, 2, 'upper'], [16, 16, 'clean']), ('partial repair variant: second field index', [19, 2, 'upper'], [15, 15, 'clean']), ('normal control', [-2, 2, 'lower'], None), ('normal control', [-5, 1, 'upper'], None), ('normal control', [-2, 3, 'lower'], None)], [('regression: second field index', [4, 3, 'lower'], [3, 3, 'clean']), ('regression variant: second field index', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair probe: second field index', [29, 1, 'lower'], [23, 23, 'clean']), ('partial repair variant: second field index', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [-3, 3, 'lower'], None), ('normal control', [-1, 0, 'upper'], None), ('normal control', [-3, 0, 'upper'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+2)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: second field index', [0, 0, 'upper'], [0, 0, 'clean']), ('regression variant: second field index', [16, 3, 'upper'], [12, 13, 'mixed']), ('partial repair probe: second field index', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair variant: second field index', [4, 1, 'upper'], [3, 3, 'clean']), ('normal control', [-3, 2, 'lower'], None), ('normal control', [-5, 0, 'lower'], None), ('normal control', [-4, 2, 'lower'], None)], [('regression: second field index', [2, 0, 'upper'], [1, 2, 'mixed']), ('regression variant: second field index', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair probe: second field index', [24, 0, 'upper'], [19, 19, 'clean']), ('partial repair variant: second field index', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [-5, 3, 'lower'], None), ('normal control', [-3, 0, 'lower'], None), ('normal control', [-1, 2, 'upper'], None)], [('regression: second field index', [2, 0, 'lower'], [2, 1, 'mixed']), ('regression variant: second field index', [30, 3, 'lower'], [24, 24, 'clean']), ('partial repair probe: second field index', [0, 0, 'lower'], [0, 0, 'clean']), ('partial repair variant: second field index', [25, 2, 'lower'], [20, 20, 'clean']), ('normal control', [-3, 3, 'upper'], None), ('normal control', [-2, 2, 'upper'], None), ('normal control', [-4, 3, 'lower'], None)], [('regression: second field index', [0, 1, 'upper'], [0, 0, 'clean']), ('regression variant: second field index', [0, 0, 'lower'], [0, 0, 'clean']), ('partial repair probe: second field index', [20, 2, 'upper'], [16, 16, 'clean']), ('partial repair variant: second field index', [19, 2, 'upper'], [15, 15, 'clean']), ('normal control', [-2, 2, 'lower'], None), ('normal control', [-5, 1, 'upper'], None), ('normal control', [-2, 3, 'lower'], None)], [('regression: second field index', [4, 3, 'lower'], [3, 3, 'clean']), ('regression variant: second field index', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair probe: second field index', [29, 1, 'lower'], [23, 23, 'clean']), ('partial repair variant: second field index', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [-3, 3, 'lower'], None), ('normal control', [-1, 0, 'upper'], None), ('normal control', [-3, 0, 'upper'], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The second field is taken from the previous video frame.

Fields carry film frames in A2 B3 C2 D3 cadence; film frame 0 has cadence position phase and starts at field 0. Video frame v consists of fields 2v and 2v+1. For order "upper" field 2v is the top field; for "lower" field 2v is the bottom field. Return [film frame in top field, film frame in bottom field, "clean" or "mixed"]; a negative v returns None.

split: open-access


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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        top=bottom
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field order swap', [2, 0, 'lower'], [2, 1, 'mixed']), ('regression variant: field order swap', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair probe: field order swap', [23, 0, 'lower'], [19, 18, 'mixed']), ('partial repair variant: field order swap', [1, 3, 'lower'], [1, 0, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [16, 3, 'upper'], [12, 13, 'mixed']), ('normal control', [10, 2, 'upper'], [8, 8, 'clean'])], [('regression: field order swap', [12, 3, 'lower'], [10, 9, 'mixed']), ('regression variant: field order swap', [21, 3, 'lower'], [17, 16, 'mixed']), ('partial repair probe: field order swap', [28, 2, 'lower'], [23, 22, 'mixed']), ('partial repair variant: field order swap', [2, 1, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [30, 3, 'lower'], [24, 24, 'clean']), ('normal control', [20, 2, 'upper'], [16, 16, 'clean']), ('normal control', [29, 1, 'lower'], [23, 23, 'clean'])], [('regression: field order swap', [23, 0, 'lower'], [19, 18, 'mixed']), ('regression variant: field order swap', [22, 2, 'lower'], [18, 17, 'mixed']), ('partial repair probe: field order swap', [3, 2, 'lower'], [3, 2, 'mixed']), ('partial repair variant: field order swap', [27, 2, 'lower'], [22, 21, 'mixed']), ('boundary control', [0, 1, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [1, 0, 'upper'], [1, 1, 'clean']), ('normal control', [25, 0, 'upper'], [20, 20, 'clean']), ('normal control', [22, 3, 'upper'], [17, 18, 'mixed'])], [('regression: field order swap', [28, 2, 'lower'], [23, 22, 'mixed']), ('regression variant: field order swap', [2, 3, 'lower'], [2, 1, 'mixed']), ('partial repair probe: field order swap', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair variant: field order swap', [11, 3, 'lower'], [9, 8, 'mixed']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('boundary control', [0, 1, 'upper'], [0, 0, 'clean']), ('normal control', [16, 2, 'lower'], [13, 13, 'clean']), ('normal control', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [17, 2, 'upper'], [13, 14, 'mixed'])], [('regression: field order swap', [3, 2, 'lower'], [3, 2, 'mixed']), ('regression variant: field order swap', [1, 3, 'lower'], [1, 0, 'mixed']), ('partial repair probe: field order swap', [21, 3, 'lower'], [17, 16, 'mixed']), ('partial repair variant: field order swap', [27, 3, 'lower'], [22, 21, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [25, 2, 'lower'], [20, 20, 'clean']), ('normal control', [6, 2, 'upper'], [5, 5, 'clean']), ('normal control', [19, 2, 'upper'], [15, 15, 'clean'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+base,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        bottom,top=top,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field order swap', [2, 0, 'lower'], [2, 1, 'mixed']), ('regression variant: field order swap', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair probe: field order swap', [23, 0, 'lower'], [19, 18, 'mixed']), ('partial repair variant: field order swap', [1, 3, 'lower'], [1, 0, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [16, 3, 'upper'], [12, 13, 'mixed']), ('normal control', [10, 2, 'upper'], [8, 8, 'clean'])], [('regression: field order swap', [12, 3, 'lower'], [10, 9, 'mixed']), ('regression variant: field order swap', [21, 3, 'lower'], [17, 16, 'mixed']), ('partial repair probe: field order swap', [28, 2, 'lower'], [23, 22, 'mixed']), ('partial repair variant: field order swap', [2, 1, 'lower'], [2, 1, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [30, 3, 'lower'], [24, 24, 'clean']), ('normal control', [20, 2, 'upper'], [16, 16, 'clean']), ('normal control', [29, 1, 'lower'], [23, 23, 'clean'])], [('regression: field order swap', [23, 0, 'lower'], [19, 18, 'mixed']), ('regression variant: field order swap', [22, 2, 'lower'], [18, 17, 'mixed']), ('partial repair probe: field order swap', [3, 2, 'lower'], [3, 2, 'mixed']), ('partial repair variant: field order swap', [27, 2, 'lower'], [22, 21, 'mixed']), ('boundary control', [0, 1, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [1, 0, 'upper'], [1, 1, 'clean']), ('normal control', [25, 0, 'upper'], [20, 20, 'clean']), ('normal control', [22, 3, 'upper'], [17, 18, 'mixed'])], [('regression: field order swap', [28, 2, 'lower'], [23, 22, 'mixed']), ('regression variant: field order swap', [2, 3, 'lower'], [2, 1, 'mixed']), ('partial repair probe: field order swap', [13, 0, 'lower'], [11, 10, 'mixed']), ('partial repair variant: field order swap', [11, 3, 'lower'], [9, 8, 'mixed']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('boundary control', [0, 1, 'upper'], [0, 0, 'clean']), ('normal control', [16, 2, 'lower'], [13, 13, 'clean']), ('normal control', [19, 1, 'lower'], [15, 15, 'clean']), ('normal control', [17, 2, 'upper'], [13, 14, 'mixed'])], [('regression: field order swap', [3, 2, 'lower'], [3, 2, 'mixed']), ('regression variant: field order swap', [1, 3, 'lower'], [1, 0, 'mixed']), ('partial repair probe: field order swap', [21, 3, 'lower'], [17, 16, 'mixed']), ('partial repair variant: field order swap', [27, 3, 'lower'], [22, 21, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [4, 3, 'lower'], [3, 3, 'clean']), ('normal control', [25, 2, 'lower'], [20, 20, 'clean']), ('normal control', [6, 2, 'upper'], [5, 5, 'clean']), ('normal control', [19, 2, 'upper'], [15, 15, 'clean'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Lower-field-first material reports the same film frame for both fields.

Fields carry film frames in A2 B3 C2 D3 cadence; film frame 0 has cadence position phase and starts at field 0. Video frame v consists of fields 2v and 2v+1. For order "upper" field 2v is the top field; for "lower" field 2v is the bottom field. Return [film frame in top field, film frame in bottom field, "clean" or "mixed"]; a negative v returns None.

split: open-access


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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cadence base offset', [0, 1, 'upper'], [0, 0, 'clean']), ('regression variant: cadence base offset', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair probe: cadence base offset', [16, 3, 'upper'], [12, 13, 'mixed']), ('partial repair variant: cadence base offset', [15, 1, 'upper'], [12, 12, 'clean']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [24, 0, 'upper'], [19, 19, 'clean']), ('normal control', [23, 0, 'lower'], [19, 18, 'mixed'])], [('regression: cadence base offset', [4, 3, 'lower'], [3, 3, 'clean']), ('regression variant: cadence base offset', [26, 3, 'upper'], [20, 21, 'mixed']), ('partial repair probe: cadence base offset', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair variant: cadence base offset', [17, 1, 'upper'], [13, 14, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [1, 0, 'upper'], [1, 1, 'clean']), ('normal control', [-4, 0, 'upper'], None), ('normal control', [-5, 0, 'lower'], None)], [('regression: cadence base offset', [16, 3, 'upper'], [12, 13, 'mixed']), ('regression variant: cadence base offset', [20, 2, 'upper'], [16, 16, 'clean']), ('partial repair probe: cadence base offset', [30, 3, 'lower'], [24, 24, 'clean']), ('partial repair variant: cadence base offset', [28, 2, 'lower'], [23, 22, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [6, 0, 'upper'], [5, 5, 'clean']), ('normal control', [25, 0, 'lower'], [20, 20, 'clean'])], [('regression: cadence base offset', [10, 2, 'upper'], [8, 8, 'clean']), ('regression variant: cadence base offset', [29, 1, 'lower'], [23, 23, 'clean']), ('partial repair probe: cadence base offset', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair variant: cadence base offset', [12, 1, 'upper'], [9, 10, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [-5, 3, 'lower'], None), ('normal control', [28, 0, 'upper'], [22, 23, 'mixed']), ('normal control', [8, 0, 'upper'], [6, 7, 'mixed'])], [('regression: cadence base offset', [30, 3, 'lower'], [24, 24, 'clean']), ('regression variant: cadence base offset', [15, 1, 'upper'], [12, 12, 'clean']), ('partial repair probe: cadence base offset', [26, 3, 'upper'], [20, 21, 'mixed']), ('partial repair variant: cadence base offset', [22, 3, 'upper'], [17, 18, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [-2, 1, 'upper'], None), ('normal control', [19, 0, 'lower'], [15, 15, 'clean']), ('normal control', [22, 0, 'upper'], [17, 18, 'mixed'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(v, phase, order):
    if v<0:
        return None
    base=[0,2,5,7][phase]
    def film(f):
        g,w=divmod(f+phase,10)
        return 4*g+[0,0,1,1,1,2,2,3,3,3][w]-phase
    top,bottom=film(2*v),film(2*v+1)
    if order=='lower':
        top,bottom=bottom,top
    return [top,bottom,'clean' if top==bottom else 'mixed']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cadence base offset', [0, 1, 'upper'], [0, 0, 'clean']), ('regression variant: cadence base offset', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair probe: cadence base offset', [16, 3, 'upper'], [12, 13, 'mixed']), ('partial repair variant: cadence base offset', [15, 1, 'upper'], [12, 12, 'clean']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [24, 0, 'upper'], [19, 19, 'clean']), ('normal control', [23, 0, 'lower'], [19, 18, 'mixed'])], [('regression: cadence base offset', [4, 3, 'lower'], [3, 3, 'clean']), ('regression variant: cadence base offset', [26, 3, 'upper'], [20, 21, 'mixed']), ('partial repair probe: cadence base offset', [10, 2, 'upper'], [8, 8, 'clean']), ('partial repair variant: cadence base offset', [17, 1, 'upper'], [13, 14, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [1, 0, 'upper'], [1, 1, 'clean']), ('normal control', [-4, 0, 'upper'], None), ('normal control', [-5, 0, 'lower'], None)], [('regression: cadence base offset', [16, 3, 'upper'], [12, 13, 'mixed']), ('regression variant: cadence base offset', [20, 2, 'upper'], [16, 16, 'clean']), ('partial repair probe: cadence base offset', [30, 3, 'lower'], [24, 24, 'clean']), ('partial repair variant: cadence base offset', [28, 2, 'lower'], [23, 22, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('normal control', [4, 0, 'upper'], [3, 3, 'clean']), ('normal control', [6, 0, 'upper'], [5, 5, 'clean']), ('normal control', [25, 0, 'lower'], [20, 20, 'clean'])], [('regression: cadence base offset', [10, 2, 'upper'], [8, 8, 'clean']), ('regression variant: cadence base offset', [29, 1, 'lower'], [23, 23, 'clean']), ('partial repair probe: cadence base offset', [12, 3, 'lower'], [10, 9, 'mixed']), ('partial repair variant: cadence base offset', [12, 1, 'upper'], [9, 10, 'mixed']), ('boundary control', [0, 0, 'upper'], [0, 0, 'clean']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('normal control', [-5, 3, 'lower'], None), ('normal control', [28, 0, 'upper'], [22, 23, 'mixed']), ('normal control', [8, 0, 'upper'], [6, 7, 'mixed'])], [('regression: cadence base offset', [30, 3, 'lower'], [24, 24, 'clean']), ('regression variant: cadence base offset', [15, 1, 'upper'], [12, 12, 'clean']), ('partial repair probe: cadence base offset', [26, 3, 'upper'], [20, 21, 'mixed']), ('partial repair variant: cadence base offset', [22, 3, 'upper'], [17, 18, 'mixed']), ('boundary control', [2, 0, 'upper'], [1, 2, 'mixed']), ('boundary control', [2, 0, 'lower'], [2, 1, 'mixed']), ('normal control', [-2, 1, 'upper'], None), ('normal control', [19, 0, 'lower'], [15, 15, 'clean']), ('normal control', [22, 0, 'upper'], [17, 18, 'mixed'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
With a non-zero phase, fields are attributed as if the cadence started at A.

Fields carry film frames in A2 B3 C2 D3 cadence; film frame 0 has cadence position phase and starts at field 0. Video frame v consists of fields 2v and 2v+1. For order "upper" field 2v is the top field; for "lower" field 2v is the bottom field. Return [film frame in top field, film frame in bottom field, "clean" or "mixed"]; a negative v returns None.

split: open-access