broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        x=-x
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative input', ['-1', [25, 1]], None), ('regression variant: negative input', ['-0.5', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [24, 1]], None), ('partial repair variant: negative input', ['-1', [30000, 1001]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: negative input', ['-1', [24000, 1001]], None), ('regression variant: negative input', ['-1', [50, 1]], None), ('partial repair probe: negative input', ['-0.5', [25, 1]], None), ('partial repair variant: negative input', ['-1', [25, 1]], None), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: negative input', ['-1', [24, 1]], None), ('regression variant: negative input', ['-0.5', [24000, 1001]], None), ('partial repair probe: negative input', ['-0.5', [50, 1]], None), ('partial repair variant: negative input', ['-1', [24000, 1001]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.02', [30000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [25, 1]], None), ('regression variant: negative input', ['-0.5', [24, 1]], None), ('partial repair probe: negative input', ['-0.5', [30000, 1001]], None), ('partial repair variant: negative input', ['-1', [24, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.04', [24000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [50, 1]], None), ('regression variant: negative input', ['-1', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [50, 1]], None), ('partial repair variant: negative input', ['-0.5', [25, 1]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.14', [30000, 1001]], [4, '00:00:00:04']), ('normal control', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('normal control', ['1.001', [50, 1]], [50, '00:00:01:00'])]]
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
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        x=0
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative input', ['-1', [25, 1]], None), ('regression variant: negative input', ['-0.5', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [24, 1]], None), ('partial repair variant: negative input', ['-1', [30000, 1001]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: negative input', ['-1', [24000, 1001]], None), ('regression variant: negative input', ['-1', [50, 1]], None), ('partial repair probe: negative input', ['-0.5', [25, 1]], None), ('partial repair variant: negative input', ['-1', [25, 1]], None), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: negative input', ['-1', [24, 1]], None), ('regression variant: negative input', ['-0.5', [24000, 1001]], None), ('partial repair probe: negative input', ['-0.5', [50, 1]], None), ('partial repair variant: negative input', ['-1', [24000, 1001]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.02', [30000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [25, 1]], None), ('regression variant: negative input', ['-0.5', [24, 1]], None), ('partial repair probe: negative input', ['-0.5', [30000, 1001]], None), ('partial repair variant: negative input', ['-1', [24, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.04', [24000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [50, 1]], None), ('regression variant: negative input', ['-1', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [50, 1]], None), ('partial repair variant: negative input', ['-0.5', [25, 1]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.14', [30000, 1001]], [4, '00:00:00:04']), ('normal control', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('normal control', ['1.001', [50, 1]], [50, '00:00:01:00'])]]
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 offsets are silently mirrored to positive frames.

Convert a decimal seconds string exactly (no binary floating point) at rate [N,D] to the nearest frame, halves rounding up, and a non-drop label using the nominal rate ceil(N/D). Negative input returns None.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
NTSC labels show frame fields in the thousands.

Convert a decimal seconds string exactly (no binary floating point) at rate [N,D] to the nearest frame, halves rounding up, and a non-drop label using the nominal rate ceil(N/D). Negative input returns None.

split: open-access


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

N = 1
observations = []
def solve(s, fps):
    s=s.replace(';',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: separator equivalence', ['1.2.3.4', 25], '01:02:03:04'), ('regression variant: separator equivalence', ['59.2', 24], '00:00:59:02'), ('partial repair probe: separator equivalence', ['30;24;61;30', 24], '06:25:02:06'), ('partial repair variant: separator equivalence', ['24;2;59', 30], '00:24:03:29'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['99', 24], '00:00:04:03'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: separator equivalence', ['59.10', 24], '00:00:59:10'), ('regression variant: separator equivalence', ['23.1', 30], '00:00:23:01'), ('partial repair probe: separator equivalence', ['30;24;61;1', 24], '06:25:01:01'), ('partial repair variant: separator equivalence', ['1;1;59', 25], '00:01:03:09'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['5959', 24], '00:01:01:11'), ('normal control', ['59:23', 24], '00:00:59:23'), ('normal control', ['', 25], None)], [('regression: separator equivalence', ['59.99', 24], '00:01:03:03'), ('regression variant: separator equivalence', ['59.99.23.24', 24], '12:39:24:00'), ('partial repair probe: separator equivalence', ['59;24;24', 30], '00:59:24:24'), ('partial repair variant: separator equivalence', ['61;1;10', 30], '01:01:01:10'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['10000', 25], '00:01:00:00'), ('normal control', ['61:59:59:24:0', 25], None), ('normal control', ['1000', 24], '00:00:10:00')], [('regression: separator equivalence', ['99.24.0', 24], '01:39:24:00'), ('regression variant: separator equivalence', ['10.59', 25], '00:00:12:09'), ('partial repair probe: separator equivalence', ['10;2;24;2', 25], '10:02:24:02'), ('partial repair variant: separator equivalence', ['59;23', 30], '00:00:59:23'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['2:23:61:99', 25], '02:24:04:24'), ('normal control', ['1:30:10', 30], '00:01:30:10'), ('normal control', ['1;1;1;99;2', 30], None)], [('regression: separator equivalence', ['59.23.99', 30], '00:59:26:09'), ('regression variant: separator equivalence', ['0.1.10', 24], '00:00:01:10'), ('partial repair probe: separator equivalence', ['2;30;61;24', 30], '02:31:01:24'), ('partial repair variant: separator equivalence', ['61;1;99', 30], '01:01:04:09'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['123456789', 25], None), ('normal control', ['10:30', 30], '00:00:11:00'), ('normal control', ['123456', 30], '00:12:35:26')]]
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(s, fps):
    s=s.replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: separator equivalence', ['1.2.3.4', 25], '01:02:03:04'), ('regression variant: separator equivalence', ['59.2', 24], '00:00:59:02'), ('partial repair probe: separator equivalence', ['30;24;61;30', 24], '06:25:02:06'), ('partial repair variant: separator equivalence', ['24;2;59', 30], '00:24:03:29'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['99', 24], '00:00:04:03'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: separator equivalence', ['59.10', 24], '00:00:59:10'), ('regression variant: separator equivalence', ['23.1', 30], '00:00:23:01'), ('partial repair probe: separator equivalence', ['30;24;61;1', 24], '06:25:01:01'), ('partial repair variant: separator equivalence', ['1;1;59', 25], '00:01:03:09'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['5959', 24], '00:01:01:11'), ('normal control', ['59:23', 24], '00:00:59:23'), ('normal control', ['', 25], None)], [('regression: separator equivalence', ['59.99', 24], '00:01:03:03'), ('regression variant: separator equivalence', ['59.99.23.24', 24], '12:39:24:00'), ('partial repair probe: separator equivalence', ['59;24;24', 30], '00:59:24:24'), ('partial repair variant: separator equivalence', ['61;1;10', 30], '01:01:01:10'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['10000', 25], '00:01:00:00'), ('normal control', ['61:59:59:24:0', 25], None), ('normal control', ['1000', 24], '00:00:10:00')], [('regression: separator equivalence', ['99.24.0', 24], '01:39:24:00'), ('regression variant: separator equivalence', ['10.59', 25], '00:00:12:09'), ('partial repair probe: separator equivalence', ['10;2;24;2', 25], '10:02:24:02'), ('partial repair variant: separator equivalence', ['59;23', 30], '00:00:59:23'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['2:23:61:99', 25], '02:24:04:24'), ('normal control', ['1:30:10', 30], '00:01:30:10'), ('normal control', ['1;1;1;99;2', 30], None)], [('regression: separator equivalence', ['59.23.99', 30], '00:59:26:09'), ('regression variant: separator equivalence', ['0.1.10', 24], '00:00:01:10'), ('partial repair probe: separator equivalence', ['2;30;61;24', 30], '02:31:01:24'), ('partial repair variant: separator equivalence', ['61;1;99', 30], '01:01:04:09'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['123456789', 25], None), ('normal control', ['10:30', 30], '00:00:11:00'), ('normal control', ['123456', 30], '00:12:35:26')]]
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:
Entries typed with periods on the numeric keypad are rejected.

Normalize typed timecode. Separators ":", ";" and "." are equivalent. With separators, up to four numeric fields fill from the right (frames last). Without separators, up to eight digits are right-aligned into HH MM SS FF pairs. Field overflow carries through the total frame count, which wraps at 24 hours. Invalid entry returns None.

split: open-access


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

N = 1
observations = []
def solve(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.ljust(8,'0')
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: digit right alignment', ['100', 25], '00:00:01:00'), ('regression variant: digit right alignment', ['5959', 24], '00:01:01:11'), ('partial repair probe: digit right alignment', ['23595924', 25], '23:59:59:24'), ('partial repair variant: digit right alignment', ['100', 24], '00:00:01:00'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['59.99', 24], '00:01:03:03'), ('normal control', ['59:23', 24], '00:00:59:23')], [('regression: digit right alignment', ['99', 25], '00:00:03:24'), ('regression variant: digit right alignment', ['10', 24], '00:00:00:10'), ('partial repair probe: digit right alignment', ['99', 24], '00:00:04:03'), ('partial repair variant: digit right alignment', ['10000', 25], '00:01:00:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['99.24.0', 24], '01:39:24:00'), ('normal control', ['23:30:30', 24], '00:23:31:06'), ('normal control', ['59.2', 24], '00:00:59:02')], [('regression: digit right alignment', ['99', 24], '00:00:04:03'), ('regression variant: digit right alignment', ['100', 24], '00:00:01:00'), ('partial repair probe: digit right alignment', ['100', 30], '00:00:01:00'), ('partial repair variant: digit right alignment', ['5959', 30], '00:01:00:29'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1;1;1;99;2', 30], None), ('normal control', ['2;2;0;1;99', 30], None), ('normal control', ['23;1;1', 25], '00:23:01:01')], [('regression: digit right alignment', ['100', 30], '00:00:01:00'), ('regression variant: digit right alignment', ['10000', 25], '00:01:00:00'), ('partial repair probe: digit right alignment', ['10000', 24], '00:01:00:00'), ('partial repair variant: digit right alignment', ['30', 24], '00:00:01:06'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['x1', 24], None), ('normal control', ['23.1', 30], '00:00:23:01'), ('normal control', ['23;1;99', 30], '00:23:04:09')], [('regression: digit right alignment', ['10000', 24], '00:01:00:00'), ('regression variant: digit right alignment', ['5959', 30], '00:01:00:29'), ('partial repair probe: digit right alignment', ['5959', 24], '00:01:01:11'), ('partial repair variant: digit right alignment', ['30', 30], '00:00:01:00'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['59.99.23.24', 24], '12:39:24:00'), ('normal control', ['61:10:61', 24], '01:01:12:13'), ('normal control', ['30;24;61;30', 24], '06:25:02:06')]]
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(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=('0'*8+s)[:8]
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: digit right alignment', ['100', 25], '00:00:01:00'), ('regression variant: digit right alignment', ['5959', 24], '00:01:01:11'), ('partial repair probe: digit right alignment', ['23595924', 25], '23:59:59:24'), ('partial repair variant: digit right alignment', ['100', 24], '00:00:01:00'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['59.99', 24], '00:01:03:03'), ('normal control', ['59:23', 24], '00:00:59:23')], [('regression: digit right alignment', ['99', 25], '00:00:03:24'), ('regression variant: digit right alignment', ['10', 24], '00:00:00:10'), ('partial repair probe: digit right alignment', ['99', 24], '00:00:04:03'), ('partial repair variant: digit right alignment', ['10000', 25], '00:01:00:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['99.24.0', 24], '01:39:24:00'), ('normal control', ['23:30:30', 24], '00:23:31:06'), ('normal control', ['59.2', 24], '00:00:59:02')], [('regression: digit right alignment', ['99', 24], '00:00:04:03'), ('regression variant: digit right alignment', ['100', 24], '00:00:01:00'), ('partial repair probe: digit right alignment', ['100', 30], '00:00:01:00'), ('partial repair variant: digit right alignment', ['5959', 30], '00:01:00:29'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1;1;1;99;2', 30], None), ('normal control', ['2;2;0;1;99', 30], None), ('normal control', ['23;1;1', 25], '00:23:01:01')], [('regression: digit right alignment', ['100', 30], '00:00:01:00'), ('regression variant: digit right alignment', ['10000', 25], '00:01:00:00'), ('partial repair probe: digit right alignment', ['10000', 24], '00:01:00:00'), ('partial repair variant: digit right alignment', ['30', 24], '00:00:01:06'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['x1', 24], None), ('normal control', ['23.1', 30], '00:00:23:01'), ('normal control', ['23;1;99', 30], '00:23:04:09')], [('regression: digit right alignment', ['10000', 24], '00:01:00:00'), ('regression variant: digit right alignment', ['5959', 30], '00:01:00:29'), ('partial repair probe: digit right alignment', ['5959', 24], '00:01:01:11'), ('partial repair variant: digit right alignment', ['30', 30], '00:00:01:00'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['59.99.23.24', 24], '12:39:24:00'), ('normal control', ['61:10:61', 24], '01:01:12:13'), ('normal control', ['30;24;61;30', 24], '06:25:02:06')]]
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:
Typing 100 jumps to 10:00:00:00 instead of one second.

Normalize typed timecode. Separators ":", ";" and "." are equivalent. With separators, up to four numeric fields fill from the right (frames last). Without separators, up to eight digits are right-aligned into HH MM SS FF pairs. Field overflow carries through the total frame count, which wraps at 24 hours. Invalid entry returns None.

split: open-access


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

N = 1
observations = []
def solve(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>9:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: digit count limit', ['123456789', 25], None), ('regression variant: digit count limit', ['123456789', 30], None), ('partial repair probe: digit count limit', ['12345678', 30], '12:34:58:18'), ('partial repair variant: digit count limit', ['12345678', 25], '12:34:59:03'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['59.99', 24], '00:01:03:03')], [('regression: digit count limit', ['123456789', 24], None), ('regression variant: digit count limit', ['123456789', 25], None), ('partial repair probe: digit count limit', ['12345678', 24], '12:34:59:06'), ('partial repair variant: digit count limit', ['12345678', 30], '12:34:58:18'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['100', 30], '00:00:01:00'), ('normal control', ['0:23:23', 24], '00:00:23:23'), ('normal control', ['10', 24], '00:00:00:10')], [('regression: digit count limit', ['123456789', 30], None), ('regression variant: digit count limit', ['123456789', 24], None), ('partial repair probe: digit count limit', ['23595924', 25], '23:59:59:24'), ('partial repair variant: digit count limit', ['12345678', 24], '12:34:59:06'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['100', 24], '00:00:01:00'), ('normal control', ['30', 24], '00:00:01:06'), ('normal control', ['61:59:59:24:0', 25], None)], [('regression: digit count limit', ['123456789', 25], None), ('regression variant: digit count limit', ['123456789', 30], None), ('partial repair probe: digit count limit', ['12345678', 25], '12:34:59:03'), ('partial repair variant: digit count limit', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['1000', 24], '00:00:10:00'), ('normal control', ['23:30:30', 24], '00:23:31:06'), ('normal control', ['59.2', 24], '00:00:59:02')], [('regression: digit count limit', ['123456789', 24], None), ('regression variant: digit count limit', ['123456789', 25], None), ('partial repair probe: digit count limit', ['12345678', 30], '12:34:58:18'), ('partial repair variant: digit count limit', ['12345678', 25], '12:34:59:03'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1:30:10', 30], '00:01:30:10'), ('normal control', ['x1', 25], None), ('normal control', ['59:59:2', 30], '00:59:59:02')]]
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(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>=8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: digit count limit', ['123456789', 25], None), ('regression variant: digit count limit', ['123456789', 30], None), ('partial repair probe: digit count limit', ['12345678', 30], '12:34:58:18'), ('partial repair variant: digit count limit', ['12345678', 25], '12:34:59:03'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['59.99', 24], '00:01:03:03')], [('regression: digit count limit', ['123456789', 24], None), ('regression variant: digit count limit', ['123456789', 25], None), ('partial repair probe: digit count limit', ['12345678', 24], '12:34:59:06'), ('partial repair variant: digit count limit', ['12345678', 30], '12:34:58:18'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['100', 30], '00:00:01:00'), ('normal control', ['0:23:23', 24], '00:00:23:23'), ('normal control', ['10', 24], '00:00:00:10')], [('regression: digit count limit', ['123456789', 30], None), ('regression variant: digit count limit', ['123456789', 24], None), ('partial repair probe: digit count limit', ['23595924', 25], '23:59:59:24'), ('partial repair variant: digit count limit', ['12345678', 24], '12:34:59:06'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['100', 24], '00:00:01:00'), ('normal control', ['30', 24], '00:00:01:06'), ('normal control', ['61:59:59:24:0', 25], None)], [('regression: digit count limit', ['123456789', 25], None), ('regression variant: digit count limit', ['123456789', 30], None), ('partial repair probe: digit count limit', ['12345678', 25], '12:34:59:03'), ('partial repair variant: digit count limit', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['1000', 24], '00:00:10:00'), ('normal control', ['23:30:30', 24], '00:23:31:06'), ('normal control', ['59.2', 24], '00:00:59:02')], [('regression: digit count limit', ['123456789', 24], None), ('regression variant: digit count limit', ['123456789', 25], None), ('partial repair probe: digit count limit', ['12345678', 30], '12:34:58:18'), ('partial repair variant: digit count limit', ['12345678', 25], '12:34:59:03'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['1:30:10', 30], '00:01:30:10'), ('normal control', ['x1', 25], None), ('normal control', ['59:59:2', 30], '00:59:59:02')]]
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 nine-digit entry is accepted and truncated silently.

Normalize typed timecode. Separators ":", ";" and "." are equivalent. With separators, up to four numeric fields fill from the right (frames last). Without separators, up to eight digits are right-aligned into HH MM SS FF pairs. Field overflow carries through the total frame count, which wraps at 24 hours. Invalid entry returns None.

split: open-access


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

N = 1
observations = []
def solve(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[int(p) for p in parts]+[0]*(4-len(parts))
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field fill side', ['1:2', 25], '00:00:01:02'), ('regression variant: field fill side', ['99.24.0', 24], '01:39:24:00'), ('partial repair probe: field fill side', ['59.99', 24], '00:01:03:03'), ('partial repair variant: field fill side', ['1:30:10', 30], '00:01:30:10'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['99', 25], '00:00:03:24'), ('normal control', ['99', 24], '00:00:04:03'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: field fill side', ['59.10', 24], '00:00:59:10'), ('regression variant: field fill side', ['23:30:30', 24], '00:23:31:06'), ('partial repair probe: field fill side', ['0:23:23', 24], '00:00:23:23'), ('partial repair variant: field fill side', ['59:59:2', 30], '00:59:59:02'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['5959', 24], '00:01:01:11'), ('normal control', ['', 25], None), ('normal control', ['10000', 25], '00:01:00:00')], [('regression: field fill side', ['59.99', 24], '00:01:03:03'), ('regression variant: field fill side', ['59.23.99', 30], '00:59:26:09'), ('partial repair probe: field fill side', ['59:23', 24], '00:00:59:23'), ('partial repair variant: field fill side', ['23;1;1', 25], '00:23:01:01'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['30', 24], '00:00:01:06'), ('normal control', ['1000', 24], '00:00:10:00'), ('normal control', ['2:23:61:99', 25], '02:24:04:24')], [('regression: field fill side', ['0:23:23', 24], '00:00:23:23'), ('regression variant: field fill side', ['59.2', 24], '00:00:59:02'), ('partial repair probe: field fill side', ['99.24.0', 24], '01:39:24:00'), ('partial repair variant: field fill side', ['10:30', 30], '00:00:11:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['123456', 25], '00:12:36:06'), ('normal control', ['123456789', 25], None), ('normal control', ['x1', 24], None)], [('regression: field fill side', ['59:23', 24], '00:00:59:23'), ('regression variant: field fill side', ['1:30:10', 30], '00:01:30:10'), ('partial repair probe: field fill side', ['23:30:30', 24], '00:23:31:06'), ('partial repair variant: field fill side', ['23:59', 25], '00:00:25:09'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['0:61:99:1:0', 30], None), ('normal control', ['59:23:23:10:10', 30], None), ('normal control', ['59.99.23.24', 24], '12:39:24:00')]]
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(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[int(p) for p in parts[:-1]]+[0]*(4-len(parts))+[int(parts[-1])]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,n%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field fill side', ['1:2', 25], '00:00:01:02'), ('regression variant: field fill side', ['99.24.0', 24], '01:39:24:00'), ('partial repair probe: field fill side', ['59.99', 24], '00:01:03:03'), ('partial repair variant: field fill side', ['1:30:10', 30], '00:01:30:10'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['99', 25], '00:00:03:24'), ('normal control', ['99', 24], '00:00:04:03'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: field fill side', ['59.10', 24], '00:00:59:10'), ('regression variant: field fill side', ['23:30:30', 24], '00:23:31:06'), ('partial repair probe: field fill side', ['0:23:23', 24], '00:00:23:23'), ('partial repair variant: field fill side', ['59:59:2', 30], '00:59:59:02'), ('boundary control', ['99', 25], '00:00:03:24'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['5959', 24], '00:01:01:11'), ('normal control', ['', 25], None), ('normal control', ['10000', 25], '00:01:00:00')], [('regression: field fill side', ['59.99', 24], '00:01:03:03'), ('regression variant: field fill side', ['59.23.99', 30], '00:59:26:09'), ('partial repair probe: field fill side', ['59:23', 24], '00:00:59:23'), ('partial repair variant: field fill side', ['23;1;1', 25], '00:23:01:01'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['99', 25], '00:00:03:24'), ('normal control', ['30', 24], '00:00:01:06'), ('normal control', ['1000', 24], '00:00:10:00'), ('normal control', ['2:23:61:99', 25], '02:24:04:24')], [('regression: field fill side', ['0:23:23', 24], '00:00:23:23'), ('regression variant: field fill side', ['59.2', 24], '00:00:59:02'), ('partial repair probe: field fill side', ['99.24.0', 24], '01:39:24:00'), ('partial repair variant: field fill side', ['10:30', 30], '00:00:11:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['123456', 25], '00:12:36:06'), ('normal control', ['123456789', 25], None), ('normal control', ['x1', 24], None)], [('regression: field fill side', ['59:23', 24], '00:00:59:23'), ('regression variant: field fill side', ['1:30:10', 30], '00:01:30:10'), ('partial repair probe: field fill side', ['23:30:30', 24], '00:23:31:06'), ('partial repair variant: field fill side', ['23:59', 25], '00:00:25:09'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['0:61:99:1:0', 30], None), ('normal control', ['59:23:23:10:10', 30], None), ('normal control', ['59.99.23.24', 24], '12:39:24:00')]]
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:
Typing 1:2 gives one hour and two minutes instead of one second and two frames.

Normalize typed timecode. Separators ":", ";" and "." are equivalent. With separators, up to four numeric fields fill from the right (frames last). Without separators, up to eight digits are right-aligned into HH MM SS FF pairs. Field overflow carries through the total frame count, which wraps at 24 hours. Invalid entry returns None.

split: open-access


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

N = 1
observations = []
def solve(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,f)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field carry', ['99', 25], '00:00:03:24'), ('regression variant: frame field carry', ['5959', 30], '00:01:00:29'), ('partial repair probe: frame field carry', ['5959', 24], '00:01:01:11'), ('partial repair variant: frame field carry', ['10:30', 30], '00:00:11:00'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: frame field carry', ['59.99', 24], '00:01:03:03'), ('regression variant: frame field carry', ['30', 24], '00:00:01:06'), ('partial repair probe: frame field carry', ['12345678', 25], '12:34:59:03'), ('partial repair variant: frame field carry', ['123456', 30], '00:12:35:26'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['0:23:23', 24], '00:00:23:23'), ('normal control', ['', 25], None), ('normal control', ['10000', 25], '00:01:00:00')], [('regression: frame field carry', ['99', 24], '00:00:04:03'), ('regression variant: frame field carry', ['30', 30], '00:00:01:00'), ('partial repair probe: frame field carry', ['30', 24], '00:00:01:06'), ('partial repair variant: frame field carry', ['23:59', 25], '00:00:25:09'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['61:59:59:24:0', 25], None), ('normal control', ['59.2', 24], '00:00:59:02'), ('normal control', ['1:30:10', 30], '00:01:30:10')], [('regression: frame field carry', ['5959', 24], '00:01:01:11'), ('regression variant: frame field carry', ['2:23:61:99', 25], '02:24:04:24'), ('partial repair probe: frame field carry', ['30', 30], '00:00:01:00'), ('partial repair variant: frame field carry', ['23;1;99', 30], '00:23:04:09'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['x1', 25], None), ('normal control', ['59:59:2', 30], '00:59:59:02'), ('normal control', ['x1', 24], None)], [('regression: frame field carry', ['12345678', 25], '12:34:59:03'), ('regression variant: frame field carry', ['23:30:30', 24], '00:23:31:06'), ('partial repair probe: frame field carry', ['59.23.99', 30], '00:59:26:09'), ('partial repair variant: frame field carry', ['59.99.23.24', 24], '12:39:24:00'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1000000', 30], '01:00:00:00'), ('normal control', ['59:23:23:10:10', 30], None), ('normal control', ['0.30.59.10.1', 24], 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(s, fps):
    s=s.replace(';',':').replace('.',':')
    if ':' in s:
        parts=s.split(':')
        if len(parts)>4 or not all(p.isdigit() for p in parts):
            return None
        vals=[0]*(4-len(parts))+[int(p) for p in parts]
    else:
        if not s.isdigit() or len(s)>8:
            return None
        d=s.zfill(8)
        vals=[int(d[i:i+2]) for i in range(0,8,2)]
    h,m,sec,f=vals
    n=((h*60+m)*60+sec)*fps+f
    n%=86400*fps
    return '%02d:%02d:%02d:%02d'%(n//(3600*fps),n//(60*fps)%60,n//fps%60,min(f,fps-1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field carry', ['99', 25], '00:00:03:24'), ('regression variant: frame field carry', ['5959', 30], '00:01:00:29'), ('partial repair probe: frame field carry', ['5959', 24], '00:01:01:11'), ('partial repair variant: frame field carry', ['10:30', 30], '00:00:11:00'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1:2', 25], '00:00:01:02'), ('normal control', ['59.10', 24], '00:00:59:10'), ('normal control', ['100', 30], '00:00:01:00')], [('regression: frame field carry', ['59.99', 24], '00:01:03:03'), ('regression variant: frame field carry', ['30', 24], '00:00:01:06'), ('partial repair probe: frame field carry', ['12345678', 25], '12:34:59:03'), ('partial repair variant: frame field carry', ['123456', 30], '00:12:35:26'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('boundary control', ['100', 25], '00:00:01:00'), ('normal control', ['0:23:23', 24], '00:00:23:23'), ('normal control', ['', 25], None), ('normal control', ['10000', 25], '00:01:00:00')], [('regression: frame field carry', ['99', 24], '00:00:04:03'), ('regression variant: frame field carry', ['30', 30], '00:00:01:00'), ('partial repair probe: frame field carry', ['30', 24], '00:00:01:06'), ('partial repair variant: frame field carry', ['23:59', 25], '00:00:25:09'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('boundary control', ['1:2', 25], '00:00:01:02'), ('normal control', ['61:59:59:24:0', 25], None), ('normal control', ['59.2', 24], '00:00:59:02'), ('normal control', ['1:30:10', 30], '00:01:30:10')], [('regression: frame field carry', ['5959', 24], '00:01:01:11'), ('regression variant: frame field carry', ['2:23:61:99', 25], '02:24:04:24'), ('partial repair probe: frame field carry', ['30', 30], '00:00:01:00'), ('partial repair variant: frame field carry', ['23;1;99', 30], '00:23:04:09'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('boundary control', ['1.2.3.4', 25], '01:02:03:04'), ('normal control', ['x1', 25], None), ('normal control', ['59:59:2', 30], '00:59:59:02'), ('normal control', ['x1', 24], None)], [('regression: frame field carry', ['12345678', 25], '12:34:59:03'), ('regression variant: frame field carry', ['23:30:30', 24], '00:23:31:06'), ('partial repair probe: frame field carry', ['59.23.99', 30], '00:59:26:09'), ('partial repair variant: frame field carry', ['59.99.23.24', 24], '12:39:24:00'), ('boundary control', ['100', 25], '00:00:01:00'), ('boundary control', ['23595924', 25], '23:59:59:24'), ('normal control', ['1000000', 30], '01:00:00:00'), ('normal control', ['59:23:23:10:10', 30], None), ('normal control', ['0.30.59.10.1', 24], 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:
An entry of 99 frames shows frame field 99.

Normalize typed timecode. Separators ":", ";" and "." are equivalent. With separators, up to four numeric fields fill from the right (frames last). Without separators, up to eight digits are right-aligned into HH MM SS FF pairs. Field overflow carries through the total frame count, which wraps at 24 hours. Invalid entry returns None.

split: open-access


prompt:
Small negative offsets are reported as almost a full day.

Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.

split: open-access


prompt:
A lag of 1.5 frames is reported as -2 frames and +50 subframes.

Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.

split: open-access


prompt:
Negative offsets carry a positive subframe part.

Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.

split: open-access


prompt:
A label ending in .5 contributes 5 hundredths instead of 50.

Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.

split: open-access


prompt:
Offsets across midnight are wrapped at a fraction of the day.

Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.

split: open-access


prompt:
Streams that pass the PTS rollover jump backwards by more than 13 hours.

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

split: open-access


prompt:
Timestamps that legitimately wrapped past 2^33 are discarded.

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

split: open-access


prompt:
Frames after a PTS rollover get negative frame numbers.

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

split: open-access


prompt:
Timestamps a few ticks before a frame boundary map to the previous frame.

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

split: open-access


prompt:
NTSC labels count only 29 frames per second.

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

split: open-access


prompt:
Portrait phone photos tagged 6 are baked upside down relative to what every viewer shows.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Images tagged 8 come out mirrored after baking even though their dimensions look right.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Selfies saved with tag 5 are baked rotated 180 degrees from the intended upright view.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Tag-7 images keep swapped dimensions but their content is a 180 degree turn instead of an anti-diagonal flip.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Horizontally mirrored scans come out vertically flipped.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Tag 5 and 7 images are cropped or indexed out of shape because output width and height are not exchanged.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Photos rotated 90 degrees counter-clockwise are baked unrotated.

Bake an EXIF-style orientation tag (1..8) into a row-major pixel grid so the result displays upright. Tags 2/4 mirror horizontally/vertically, 3 rotates 180, 6 rotates 90 clockwise, 8 rotates 90 counter-clockwise, 5 transposes and 7 transverses; tags outside 1..8 are treated as 1. Tags 5..8 swap the output width and height.

split: open-access


prompt:
Detected faces on portrait phone shots are highlighted on the opposite side of the frame.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
Crop rectangles on mirrored images are off by one column and can start at -1.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
Boxes on rotated photos are mirrored or pushed outside the displayed frame.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
A face box partly above or left of the frame becomes larger after clipping.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
Boxes entirely outside the image or of zero width are returned as degenerate rectangles.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
Corrupt orientation values silently produce boxes as though the image were unrotated.

Map a half-open face/crop region [x, y, width, height] given in stored pixel space of an image of size [w, h] into displayed space for orientation tag 1..8. The region is first clipped to the stored image; an empty clipped region returns None, and an unknown tag returns None. Mirroring a half-open interval [a, b) over extent e gives [e-b, e-a); tags 5..8 exchange axes after the flips.

split: open-access


prompt:
Photos from big-endian (MM) writers always display unrotated while little-endian files work.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Payloads that merely begin with the letters "Exif" are parsed as TIFF data with a shifted header.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Every file fails to parse, or the parser reads IFD0 from a wild offset.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Big-endian EXIF blocks are rejected as malformed.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
A malformed LONG orientation entry shadows a later valid SHORT entry.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Minimal EXIF blocks whose last entry ends at the payload end are reported as malformed.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Files that write orientation 0 propagate an invalid tag to renderers.

Parse the orientation from an APP1 Exif payload given as a list of byte values: a 6-byte "Exif\0\0" header, then a TIFF header (II little-endian or MM big-endian, magic 42 as a 16-bit value, 32-bit IFD0 offset relative to the TIFF header). Scan IFD0 12-byte entries; the first entry with tag 0x0112, type SHORT (3) and count 1 supplies the value from the first two bytes of its value field. Values outside 1..8 and a missing entry yield 1; structural problems (short payload, bad header, byte order, magic, truncated entry) yield "malformed".

split: open-access


prompt:
Rotating a tag-5 selfie in the editor lands on a tag that shows it upside down.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
Mirroring a portrait photo in the editor leaves it lying on its side.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
Flip top-bottom on a rotated image flips it left-right on screen.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
Both rotate buttons turn the photo the same way.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
Photos whose orientation value is 0 cannot be rotated at all.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
A typo in a batch edit script produces a plausible but wrong orientation with no error.

A photo editor rotates and flips losslessly by rewriting only the orientation tag. An orientation is modelled as (k, m): mirror horizontally m times, then rotate k quarter turns clockwise (tag table 1:(0,0) 2:(0,1) 3:(2,0) 4:(2,1) 5:(3,1) 6:(1,0) 7:(1,1) 8:(3,0)). Editor operations act on the displayed image: cw, ccw, r180, flip_h (mirror left-right) and flip_v (mirror top-bottom). Invalid starting tags count as 1; an unknown operation returns {"error": "unknown-op", "op": op}. Return the final tag.

split: open-access


prompt:
Portrait thumbnails come back with landscape dimensions for rotated photos.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


prompt:
Tag 5 and 7 thumbnails are sized as landscape when the photo displays as portrait.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


prompt:
Tiny icons are blown up to the full thumbnail size.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


prompt:
Thumbnails are one pixel narrower than expected whenever the exact width has a fractional part of one half or more.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


prompt:
Very wide panoramas produce thumbnails with zero height that break the layout.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


prompt:
Thumbnails overflow a non-square box when the image and box aspect ratios differ.

Input [stored_w, stored_h, tag, box_w, box_h]. Compute the displayed thumbnail size: tags 5..8 swap the displayed dimensions (other values, including invalid tags, do not). Scale = min(box_w/dw, box_h/dh, 1) exactly (never upscale); each side is rounded half up and is at least 1 pixel.

split: open-access


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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif' and meta.get('exif') is None:
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'exif': 8, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 2, 'xmp': '6'}, 1], [{'container': 'heif', 'exif': 0, 'irot': 0, 'imir': 0}, 2], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'heif', 'exif': True, 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'heif', 'exif': 7, 'xmp': '2', 'irot': 0, 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'xmp': '\t5', 'irot': 0, 'imir': 1}, 4], [{'container': 'heif', 'exif': 3, 'irot': 3, 'imir': 1}, 7]], [[{'container': 'heif', 'exif': 8, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'heif', 'exif': 6, 'xmp': '6'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'heif', 'exif': 3, 'xmp': '2', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': True, 'xmp': '0', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 5, 'xmp': '7 '}, 1], [{'container': 'heif', 'exif': 0, 'xmp': 'x', 'irot': 0, 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 5}, 5], [{'container': 'tiff', 'exif': 3, 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3]], [[{'container': 'heif', 'exif': 7, 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'heif', 'exif': 3, 'irot': 0}, 1], [{'container': 'heif', 'exif': 6, 'xmp': 'x', 'irot': 0, 'imir': 0}, 2], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'png', 'exif': 7}, 7], [{'container': 'heif', 'exif': 8, 'xmp': 'x'}, 1]]]
labels = ["regression: HEIF container authority", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif' and (meta.get('irot') or meta.get('imir')):
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'exif': 8, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 2, 'xmp': '6'}, 1], [{'container': 'heif', 'exif': 0, 'irot': 0, 'imir': 0}, 2], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'heif', 'exif': True, 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'heif', 'exif': 7, 'xmp': '2', 'irot': 0, 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'xmp': '\t5', 'irot': 0, 'imir': 1}, 4], [{'container': 'heif', 'exif': 3, 'irot': 3, 'imir': 1}, 7]], [[{'container': 'heif', 'exif': 8, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'heif', 'exif': 6, 'xmp': '6'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'heif', 'exif': 3, 'xmp': '2', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': True, 'xmp': '0', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 5, 'xmp': '7 '}, 1], [{'container': 'heif', 'exif': 0, 'xmp': 'x', 'irot': 0, 'imir': 0}, 2], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 5}, 5], [{'container': 'tiff', 'exif': 3, 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3]], [[{'container': 'heif', 'exif': 7, 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'heif', 'exif': 3, 'irot': 0}, 1], [{'container': 'heif', 'exif': 6, 'xmp': 'x', 'irot': 0, 'imir': 0}, 2], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'png', 'exif': 7}, 7], [{'container': 'heif', 'exif': 8, 'xmp': 'x'}, 1]]]
labels = ["regression: HEIF container authority", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
HEIC photos with both EXIF and irot are rotated twice or not at all depending on the camera.

Resolve the displayed orientation tag from metadata sources. For HEIF, the container transforms are authoritative and EXIF/XMP are ignored: irot is anticlockwise quarter turns (default 0) applied first, then imir mirrors about the vertical axis (0, left-right) or the horizontal axis (1, top-bottom); the result is mapped to a tag through (k clockwise quarter turns after m mirrors) = {(0,0):1, (0,1):2, (2,0):3, (2,1):4, (3,1):5, (1,0):6, (1,1):7, (3,0):8}. For other containers a valid integer EXIF value 1..8 wins; otherwise an XMP string that is a single digit 1..8 after trimming whitespace; otherwise 1.

split: open-access


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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[(rot, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'heif', 'exif': 2, 'xmp': '6'}, 1], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': True}, 1], [{'container': 'heif', 'xmp': '3\n', 'irot': 3}, 6]], [[{'container': 'heif', 'exif': 6, 'irot': 1}, 8], [{'container': 'heif', 'irot': 0}, 1], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 6, 'xmp': ' 8', 'irot': 3}, 6]], [[{'container': 'heif', 'exif': 2, 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'heif', 'exif': 1, 'xmp': 'x'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'heif', 'exif': 7, 'xmp': '\t5', 'irot': 3}, 6]], [[{'container': 'heif', 'irot': 1}, 8], [{'container': 'heif', 'exif': True, 'irot': 0}, 1], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 5}, 5], [{'container': 'tiff', 'exif': 3, 'xmp': '3\n'}, 3], [{'container': 'tiff', 'exif': 7}, 7], [{'container': 'heif', 'xmp': 'x', 'irot': 1}, 8]], [[{'container': 'heif', 'irot': 3}, 6], [{'container': 'heif', 'exif': 7, 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'png', 'exif': 7}, 7], [{'container': 'jpeg', 'exif': 7}, 7], [{'container': 'jpeg', 'exif': 2}, 2], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 5, 'xmp': '6'}, 5], [{'container': 'heif', 'xmp': '7 ', 'irot': 3}, 6]]]
labels = ["regression: irot rotation direction", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((rot + 2) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'heif', 'exif': 2, 'xmp': '6'}, 1], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': True}, 1], [{'container': 'heif', 'xmp': '3\n', 'irot': 3}, 6]], [[{'container': 'heif', 'exif': 6, 'irot': 1}, 8], [{'container': 'heif', 'irot': 0}, 1], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 6, 'xmp': ' 8', 'irot': 3}, 6]], [[{'container': 'heif', 'exif': 2, 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'heif', 'exif': 1, 'xmp': 'x'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'heif', 'exif': 7, 'xmp': '\t5', 'irot': 3}, 6]], [[{'container': 'heif', 'irot': 1}, 8], [{'container': 'heif', 'exif': True, 'irot': 0}, 1], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 5}, 5], [{'container': 'tiff', 'exif': 3, 'xmp': '3\n'}, 3], [{'container': 'tiff', 'exif': 7}, 7], [{'container': 'heif', 'xmp': 'x', 'irot': 1}, 8]], [[{'container': 'heif', 'irot': 3}, 6], [{'container': 'heif', 'exif': 7, 'xmp': ' 8', 'irot': 0}, 1], [{'container': 'png', 'exif': 7}, 7], [{'container': 'jpeg', 'exif': 7}, 7], [{'container': 'jpeg', 'exif': 2}, 2], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 5, 'xmp': '6'}, 5], [{'container': 'heif', 'xmp': '7 ', 'irot': 3}, 6]]]
labels = ["regression: irot rotation direction", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
HEIC photos stored with a quarter-turn irot display rotated the opposite way from other viewers.

Resolve the displayed orientation tag from metadata sources. For HEIF, the container transforms are authoritative and EXIF/XMP are ignored: irot is anticlockwise quarter turns (default 0) applied first, then imir mirrors about the vertical axis (0, left-right) or the horizontal axis (1, top-bottom); the result is mapped to a tag through (k clockwise quarter turns after m mirrors) = {(0,0):1, (0,1):2, (2,0):3, (2,1):4, (3,1):5, (1,0):6, (1,1):7, (3,0):8}. For other containers a valid integer EXIF value 1..8 wins; otherwise an XMP string that is a single digit 1..8 after trimming whitespace; otherwise 1.

split: open-access


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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 1:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'exif': 8, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 1, 'irot': 1, 'imir': 0}, 7], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'heif', 'exif': True, 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': '0', 'irot': 1, 'imir': 0}, 7], [{'container': 'heif', 'irot': 1, 'imir': 0}, 7], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'heif', 'xmp': '\t5', 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 8, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 8, 'xmp': '\t5', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 6, 'xmp': '\t5', 'irot': 3, 'imir': 0}, 5], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'heif', 'exif': 3, 'xmp': '2', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': '3\n', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 8, 'xmp': '6', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'xmp': '0', 'irot': 1, 'imir': 0}, 7], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'heif', 'exif': 0, 'xmp': '7 ', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': 6, 'xmp': ' 8', 'irot': 1, 'imir': 1}, 5], [{'container': 'heif', 'exif': 7, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 5, 'xmp': '2', 'irot': 1, 'imir': 0}, 7], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'heif', 'exif': 7, 'xmp': 'x', 'imir': 1}, 4]]]
labels = ["regression: imir axis meaning", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[((-rot) % 4, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool) and 1 <= e <= 8:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'heif', 'exif': 8, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 1, 'irot': 1, 'imir': 0}, 7], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'heif', 'exif': True, 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': '0', 'irot': 1, 'imir': 0}, 7], [{'container': 'heif', 'irot': 1, 'imir': 0}, 7], [{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'heif', 'xmp': '\t5', 'irot': 0, 'imir': 1}, 4]], [[{'container': 'heif', 'exif': 8, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 8, 'xmp': '\t5', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 6, 'xmp': '\t5', 'irot': 3, 'imir': 0}, 5], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'heif', 'exif': 3, 'xmp': '2', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': 5, 'xmp': '3\n', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 8, 'xmp': '6', 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'xmp': '0', 'irot': 1, 'imir': 0}, 7], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'heif', 'exif': 0, 'xmp': '7 ', 'irot': 2, 'imir': 0}, 4]], [[{'container': 'heif', 'exif': 6, 'xmp': ' 8', 'irot': 1, 'imir': 1}, 5], [{'container': 'heif', 'exif': 7, 'irot': 3, 'imir': 0}, 5], [{'container': 'heif', 'exif': 5, 'xmp': '2', 'irot': 1, 'imir': 0}, 7], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'heif', 'exif': 7, 'xmp': 'x', 'imir': 1}, 4]]]
labels = ["regression: imir axis meaning", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Mirrored HEIC selfies are flipped top-bottom instead of left-right.

Resolve the displayed orientation tag from metadata sources. For HEIF, the container transforms are authoritative and EXIF/XMP are ignored: irot is anticlockwise quarter turns (default 0) applied first, then imir mirrors about the vertical axis (0, left-right) or the horizontal axis (1, top-bottom); the result is mapped to a tag through (k clockwise quarter turns after m mirrors) = {(0,0):1, (0,1):2, (2,0):3, (2,1):4, (3,1):5, (1,0):6, (1,1):7, (3,0):8}. For other containers a valid integer EXIF value 1..8 wins; otherwise an XMP string that is a single digit 1..8 after trimming whitespace; otherwise 1.

split: open-access


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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if isinstance(e, int) and not isinstance(e, bool):
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 9, 'xmp': '6'}, 6], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'jpeg', 'exif': 9}, 1]], [[{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': True, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 9, 'irot': 2}, 1], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'jpeg', 'exif': 0, 'xmp': '6'}, 6]], [[{'container': 'jpeg', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': True, 'xmp': '3\n', 'irot': 3, 'imir': 0}, 3], [{'container': 'png', 'exif': 9, 'xmp': '2'}, 2], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'heif', 'exif': 6, 'xmp': 'x', 'irot': 2}, 3], [{'container': 'png', 'exif': 1}, 1], [{'container': 'jpeg', 'exif': 0}, 1]], [[{'container': 'jpeg', 'exif': 9, 'xmp': '0', 'irot': 0}, 1], [{'container': 'png', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': 9}, 1], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'jpeg', 'exif': 0, 'xmp': '6'}, 6]], [[{'container': 'tiff', 'exif': 9}, 1], [{'container': 'jpeg', 'exif': 9}, 1], [{'container': 'png', 'exif': 9, 'irot': 3, 'imir': 1}, 1], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'jpeg', 'exif': 9, 'xmp': '2'}, 2]]]
labels = ["regression: EXIF value validation", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(meta):
    from_km = {(0, 0): 1, (0, 1): 2, (2, 0): 3, (2, 1): 4, (3, 1): 5, (1, 0): 6, (1, 1): 7, (3, 0): 8}
    c = meta.get('container')
    if c == 'heif':
        rot = meta.get('irot')
        mir = meta.get('imir')
        rot = 0 if rot is None else rot % 4
        if mir is None:
            return from_km[((-rot) % 4, 0)]
        if mir == 0:
            return from_km[(rot, 1)]
        return from_km[((rot + 2) % 4, 1)]
    e = meta.get('exif')
    if e:
        return e
    x = meta.get('xmp')
    if isinstance(x, str):
        s = x.strip()
        if s in ('1', '2', '3', '4', '5', '6', '7', '8'):
            return int(s)
    return 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[{'container': 'jpeg', 'exif': 0, 'xmp': '\t5'}, 5], [{'container': 'tiff', 'exif': True, 'xmp': '7 '}, 7], [{'container': 'tiff', 'exif': 9, 'xmp': '6'}, 6], [{'container': 'png'}, 1], [{'container': 'jpeg', 'xmp': '2'}, 2], [{'container': 'heif', 'xmp': '\t5', 'irot': 3}, 6], [{'container': 'tiff'}, 1], [{'container': 'jpeg', 'exif': 9}, 1]], [[{'container': 'jpeg', 'exif': 0}, 1], [{'container': 'jpeg', 'exif': True, 'xmp': '\t5'}, 5], [{'container': 'jpeg', 'exif': 9, 'irot': 2}, 1], [{'container': 'png', 'xmp': '3\n'}, 3], [{'container': 'jpeg', 'xmp': '3\n'}, 3], [{'container': 'heif', 'exif': 5, 'xmp': ' 8', 'imir': 0}, 2], [{'container': 'heif', 'exif': 3, 'xmp': 'x', 'irot': 0}, 1], [{'container': 'jpeg', 'exif': 0, 'xmp': '6'}, 6]], [[{'container': 'jpeg', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': True, 'xmp': '3\n', 'irot': 3, 'imir': 0}, 3], [{'container': 'png', 'exif': 9, 'xmp': '2'}, 2], [{'container': 'tiff'}, 1], [{'container': 'jpeg'}, 1], [{'container': 'heif', 'exif': 6, 'xmp': 'x', 'irot': 2}, 3], [{'container': 'png', 'exif': 1}, 1], [{'container': 'jpeg', 'exif': 0}, 1]], [[{'container': 'jpeg', 'exif': 9, 'xmp': '0', 'irot': 0}, 1], [{'container': 'png', 'exif': 9, 'xmp': ' 8'}, 8], [{'container': 'jpeg', 'exif': 9}, 1], [{'container': 'jpeg', 'exif': 1}, 1], [{'container': 'heif', 'exif': 1, 'xmp': '7 ', 'irot': 2}, 3], [{'container': 'heif', 'xmp': '\t5'}, 1], [{'container': 'jpeg', 'xmp': '7 '}, 7], [{'container': 'jpeg', 'exif': 0, 'xmp': '6'}, 6]], [[{'container': 'tiff', 'exif': 9}, 1], [{'container': 'jpeg', 'exif': 9}, 1], [{'container': 'png', 'exif': 9, 'irot': 3, 'imir': 1}, 1], [{'container': 'png', 'xmp': '7 '}, 7], [{'container': 'heif', 'irot': 2}, 3], [{'container': 'heif', 'xmp': ' 8', 'irot': 1}, 8], [{'container': 'jpeg', 'xmp': 'x'}, 1], [{'container': 'jpeg', 'exif': 9, 'xmp': '2'}, 2]]]
labels = ["regression: EXIF value validation", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An EXIF value of 0 or 9 is passed to the renderer even though a valid XMP orientation exists.

Resolve the displayed orientation tag from metadata sources. For HEIF, the container transforms are authoritative and EXIF/XMP are ignored: irot is anticlockwise quarter turns (default 0) applied first, then imir mirrors about the vertical axis (0, left-right) or the horizontal axis (1, top-bottom); the result is mapped to a tag through (k clockwise quarter turns after m mirrors) = {(0,0):1, (0,1):2, (2,0):3, (2,1):4, (3,1):5, (1,0):6, (1,1):7, (3,0):8}. For other containers a valid integer EXIF value 1..8 wins; otherwise an XMP string that is a single digit 1..8 after trimming whitespace; otherwise 1.

split: open-access