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

N = 1
observations = []
def solve(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=frame//fps*1000
        if cmd.startswith('TEXT:'):
            hidden+=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if shown:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame time conversion', [[[0, 'TEXT:A'], [10, 'EOC'], [20, 'TEXT:B'], [40, 'EOC'], [50, 'EOC']], 25], [[400, 1600, 'A'], [1600, 2000, 'B']]), ('regression variant: frame time conversion', [[[30, 'EDM'], [60, 'TEXT: there'], [67, 'EOC'], [112, 'EOC']], 24], [[2791, 4666, ' there']]), ('partial repair probe: frame time conversion', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT: there'], [32, 'EDM'], [62, 'TEXT: there'], [77, 'ENM'], [84, 'TEXT:Hi'], [114, 'EOC'], [121, 'EOC'], [121, 'TEXT: there']], 24], [[4750, 5041, 'Hi']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('normal control', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], [])], [('regression: frame time conversion', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('regression variant: frame time conversion', [[[3, 'EDM'], [48, 'EOC'], [93, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 29], [[4241, 4482, 'Bye']]), ('partial repair probe: frame time conversion', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('partial repair variant: frame time conversion', [[[30, 'TEXT:Hi'], [31, 'TEXT:Bye'], [61, 'EOC'], [91, 'TEXT:Bye'], [92, 'TEXT: there'], [93, 'ENM'], [93, 'TEXT:Hi'], [122, 'EOC']], 24], [[2541, 5083, 'HiBye']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('normal control', [[[3, 'EDM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [0, 'EOC'], [30, 'TEXT:Hi']], 24], []), ('normal control', [[[0, 'TEXT:Bye'], [1, 'EDM'], [31, 'TEXT: there'], [61, 'ENM'], [68, 'EOC'], [98, 'EOC'], [113, 'TEXT:Bye']], 25], [])], [('regression: frame time conversion', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('regression variant: frame time conversion', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('partial repair probe: frame time conversion', [[[3, 'ENM'], [3, 'TEXT:Bye'], [10, 'EOC'], [10, 'EOC'], [55, 'TEXT:Bye'], [56, 'EOC']], 29], [[344, 344, 'Bye']]), ('partial repair variant: frame time conversion', [[[0, 'TEXT: there'], [1, 'EOC'], [31, 'EDM'], [38, 'EOC'], [45, 'TEXT: there'], [46, 'ENM'], [76, 'TEXT: there']], 29], [[34, 1068, ' there']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'TEXT: there'], [31, 'EDM']], 24], []), ('normal control', [[[30, 'EOC'], [59, 'EOC'], [60, 'TEXT: there'], [89, 'TEXT: there'], [96, 'ENM'], [96, 'TEXT:Bye'], [96, 'TEXT:Bye'], [96, 'TEXT: there']], 30], []), ('normal control', [[[0, 'EOC'], [29, 'EOC'], [29, 'ENM'], [36, 'TEXT: there'], [37, 'TEXT: there'], [38, 'EOC']], 25], [])], [('regression: frame time conversion', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('regression variant: frame time conversion', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('partial repair probe: frame time conversion', [[[30, 'TEXT:Bye'], [31, 'ENM'], [76, 'EOC'], [106, 'TEXT:Hi'], [107, 'EDM'], [137, 'EOC'], [166, 'EDM'], [167, 'TEXT: there']], 24], [[5708, 6916, 'Hi']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT: there'], [4, 'EOC'], [11, 'EOC'], [12, 'TEXT:Hi'], [42, 'EOC'], [57, 'ENM']], 24], [[166, 458, ' there']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('normal control', [[[30, 'EDM'], [60, 'TEXT: there'], [90, 'TEXT:Bye']], 24], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [14, 'TEXT:Bye']], 25], []), ('normal control', [[[3, 'EDM'], [33, 'TEXT:Bye'], [63, 'TEXT:Hi'], [108, 'EOC'], [109, 'TEXT:Hi']], 30], [])], [('regression: frame time conversion', [[[30, 'TEXT:Bye'], [59, 'EOC'], [66, 'TEXT:Bye'], [111, 'EOC']], 24], [[2458, 4625, 'Bye']]), ('regression variant: frame time conversion', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('partial repair probe: frame time conversion', [[[30, 'TEXT: there'], [45, 'EOC'], [52, 'EOC'], [82, 'ENM'], [82, 'TEXT:Bye'], [127, 'EOC'], [127, 'EOC'], [156, 'TEXT:Hi']], 29], [[1551, 1793, ' there'], [4379, 4379, 'Bye']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT:Hi'], [33, 'TEXT: there'], [48, 'TEXT: there'], [93, 'EOC'], [100, 'EOC']], 29], [[3206, 3448, 'Hi there there']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'ENM'], [31, 'TEXT: there'], [60, 'EDM'], [89, 'ENM'], [96, 'EDM'], [111, 'EOC']], 30], []), ('normal control', [[[30, 'EOC'], [60, 'TEXT: there']], 29], []), ('normal control', [[[0, 'TEXT:Hi'], [45, 'ENM'], [60, 'EDM'], [89, 'TEXT:Hi'], [104, 'TEXT:Bye'], [119, 'EDM'], [126, 'TEXT: there']], 24], [])]]
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(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=round(frame*1000/fps)
        if cmd.startswith('TEXT:'):
            hidden+=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if shown:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame time conversion', [[[0, 'TEXT:A'], [10, 'EOC'], [20, 'TEXT:B'], [40, 'EOC'], [50, 'EOC']], 25], [[400, 1600, 'A'], [1600, 2000, 'B']]), ('regression variant: frame time conversion', [[[30, 'EDM'], [60, 'TEXT: there'], [67, 'EOC'], [112, 'EOC']], 24], [[2791, 4666, ' there']]), ('partial repair probe: frame time conversion', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT: there'], [32, 'EDM'], [62, 'TEXT: there'], [77, 'ENM'], [84, 'TEXT:Hi'], [114, 'EOC'], [121, 'EOC'], [121, 'TEXT: there']], 24], [[4750, 5041, 'Hi']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('normal control', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], [])], [('regression: frame time conversion', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('regression variant: frame time conversion', [[[3, 'EDM'], [48, 'EOC'], [93, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 29], [[4241, 4482, 'Bye']]), ('partial repair probe: frame time conversion', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('partial repair variant: frame time conversion', [[[30, 'TEXT:Hi'], [31, 'TEXT:Bye'], [61, 'EOC'], [91, 'TEXT:Bye'], [92, 'TEXT: there'], [93, 'ENM'], [93, 'TEXT:Hi'], [122, 'EOC']], 24], [[2541, 5083, 'HiBye']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('normal control', [[[3, 'EDM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [0, 'EOC'], [30, 'TEXT:Hi']], 24], []), ('normal control', [[[0, 'TEXT:Bye'], [1, 'EDM'], [31, 'TEXT: there'], [61, 'ENM'], [68, 'EOC'], [98, 'EOC'], [113, 'TEXT:Bye']], 25], [])], [('regression: frame time conversion', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('regression variant: frame time conversion', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('partial repair probe: frame time conversion', [[[3, 'ENM'], [3, 'TEXT:Bye'], [10, 'EOC'], [10, 'EOC'], [55, 'TEXT:Bye'], [56, 'EOC']], 29], [[344, 344, 'Bye']]), ('partial repair variant: frame time conversion', [[[0, 'TEXT: there'], [1, 'EOC'], [31, 'EDM'], [38, 'EOC'], [45, 'TEXT: there'], [46, 'ENM'], [76, 'TEXT: there']], 29], [[34, 1068, ' there']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'TEXT: there'], [31, 'EDM']], 24], []), ('normal control', [[[30, 'EOC'], [59, 'EOC'], [60, 'TEXT: there'], [89, 'TEXT: there'], [96, 'ENM'], [96, 'TEXT:Bye'], [96, 'TEXT:Bye'], [96, 'TEXT: there']], 30], []), ('normal control', [[[0, 'EOC'], [29, 'EOC'], [29, 'ENM'], [36, 'TEXT: there'], [37, 'TEXT: there'], [38, 'EOC']], 25], [])], [('regression: frame time conversion', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('regression variant: frame time conversion', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('partial repair probe: frame time conversion', [[[30, 'TEXT:Bye'], [31, 'ENM'], [76, 'EOC'], [106, 'TEXT:Hi'], [107, 'EDM'], [137, 'EOC'], [166, 'EDM'], [167, 'TEXT: there']], 24], [[5708, 6916, 'Hi']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT: there'], [4, 'EOC'], [11, 'EOC'], [12, 'TEXT:Hi'], [42, 'EOC'], [57, 'ENM']], 24], [[166, 458, ' there']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('normal control', [[[30, 'EDM'], [60, 'TEXT: there'], [90, 'TEXT:Bye']], 24], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [14, 'TEXT:Bye']], 25], []), ('normal control', [[[3, 'EDM'], [33, 'TEXT:Bye'], [63, 'TEXT:Hi'], [108, 'EOC'], [109, 'TEXT:Hi']], 30], [])], [('regression: frame time conversion', [[[30, 'TEXT:Bye'], [59, 'EOC'], [66, 'TEXT:Bye'], [111, 'EOC']], 24], [[2458, 4625, 'Bye']]), ('regression variant: frame time conversion', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('partial repair probe: frame time conversion', [[[30, 'TEXT: there'], [45, 'EOC'], [52, 'EOC'], [82, 'ENM'], [82, 'TEXT:Bye'], [127, 'EOC'], [127, 'EOC'], [156, 'TEXT:Hi']], 29], [[1551, 1793, ' there'], [4379, 4379, 'Bye']]), ('partial repair variant: frame time conversion', [[[3, 'TEXT:Hi'], [33, 'TEXT: there'], [48, 'TEXT: there'], [93, 'EOC'], [100, 'EOC']], 29], [[3206, 3448, 'Hi there there']]), ('boundary control', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'ENM'], [31, 'TEXT: there'], [60, 'EDM'], [89, 'ENM'], [96, 'EDM'], [111, 'EOC']], 30], []), ('normal control', [[[30, 'EOC'], [60, 'TEXT: there']], 29], []), ('normal control', [[[0, 'TEXT:Hi'], [45, 'ENM'], [60, 'EDM'], [89, 'TEXT:Hi'], [104, 'TEXT:Bye'], [119, 'EDM'], [126, 'TEXT: there']], 24], [])]]
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:
Caption times snap to whole seconds.

Commands [frame,cmd] at integer fps (time = frame*1000//fps). TEXT:x appends x to the non-displayed memory; ENM erases non-displayed memory; EOC swaps displayed and non-displayed memories; EDM erases displayed memory. Whenever non-empty displayed text is replaced (EOC) or erased (EDM), emit [shown_since_ms, now_ms, text].

split: open-access


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

N = 1
observations = []
def solve(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=frame*1000//fps
        if cmd.startswith('TEXT:'):
            hidden+=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if True:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flip emission guard', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('regression variant: flip emission guard', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('partial repair probe: flip emission guard', [[[3, 'EOC'], [32, 'EOC'], [77, 'TEXT:Bye']], 25], []), ('partial repair variant: flip emission guard', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('normal control', [[[0, 'EDM'], [7, 'TEXT: there'], [37, 'TEXT: there']], 29], []), ('normal control', [[[30, 'EDM'], [60, 'TEXT: there'], [90, 'TEXT:Bye']], 24], []), ('normal control', [[[3, 'EDM'], [32, 'TEXT:Bye'], [77, 'TEXT:Bye'], [106, 'TEXT:Hi'], [151, 'TEXT:Hi']], 29], [])], [('regression: flip emission guard', [[[0, 'TEXT:A'], [10, 'EOC'], [20, 'TEXT:B'], [40, 'EOC'], [50, 'EOC']], 25], [[400, 1600, 'A'], [1600, 2000, 'B']]), ('regression variant: flip emission guard', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('partial repair probe: flip emission guard', [[[0, 'TEXT:Bye'], [1, 'EDM'], [31, 'TEXT: there'], [61, 'ENM'], [68, 'EOC'], [98, 'EOC'], [113, 'TEXT:Bye']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'EOC'], [7, 'ENM'], [52, 'EOC'], [81, 'TEXT:Hi']], 30], []), ('normal control', [[[0, 'EDM'], [15, 'TEXT:Bye']], 29], []), ('normal control', [[[3, 'TEXT: there'], [32, 'EDM'], [32, 'TEXT: there']], 25], []), ('normal control', [[[0, 'EDM'], [29, 'TEXT: there'], [44, 'TEXT: there'], [89, 'TEXT:Bye'], [134, 'TEXT: there']], 30], [])], [('regression: flip emission guard', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('regression variant: flip emission guard', [[[30, 'TEXT:Hi'], [31, 'TEXT: there'], [61, 'EDM'], [106, 'TEXT: there'], [121, 'ENM'], [136, 'TEXT:Hi'], [166, 'EOC']], 24], []), ('partial repair probe: flip emission guard', [[[0, 'EOC'], [7, 'EDM'], [14, 'EOC'], [59, 'EOC'], [104, 'EOC'], [133, 'EOC'], [162, 'EOC'], [207, 'EOC']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'EOC'], [1, 'EOC'], [30, 'ENM'], [37, 'TEXT:Bye']], 30], []), ('normal control', [[[0, 'ENM'], [29, 'TEXT:Bye'], [59, 'TEXT: there']], 25], []), ('normal control', [[[3, 'TEXT: there'], [48, 'TEXT:Hi'], [49, 'TEXT:Bye'], [78, 'TEXT:Hi']], 29], []), ('normal control', [[[3, 'TEXT:Bye'], [18, 'TEXT:Bye'], [25, 'TEXT:Bye'], [40, 'TEXT: there']], 30], [])], [('regression: flip emission guard', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('regression variant: flip emission guard', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], []), ('partial repair probe: flip emission guard', [[[30, 'EOC'], [59, 'EOC'], [60, 'TEXT: there'], [89, 'TEXT: there'], [96, 'ENM'], [96, 'TEXT:Bye'], [96, 'TEXT:Bye'], [96, 'TEXT: there']], 30], []), ('partial repair variant: flip emission guard', [[[30, 'EOC'], [31, 'ENM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [7, 'TEXT: there'], [37, 'EDM']], 25], []), ('normal control', [[[3, 'ENM'], [10, 'TEXT:Bye']], 25], []), ('normal control', [[[0, 'TEXT: there'], [7, 'TEXT:Hi'], [22, 'TEXT:Bye']], 29], [])], [('regression: flip emission guard', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('regression variant: flip emission guard', [[[30, 'EDM'], [30, 'EOC'], [60, 'ENM'], [89, 'ENM']], 25], []), ('partial repair probe: flip emission guard', [[[0, 'EOC'], [29, 'EOC'], [29, 'ENM'], [36, 'TEXT: there'], [37, 'TEXT: there'], [38, 'EOC']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('normal control', [[[0, 'TEXT:Bye'], [30, 'TEXT: there'], [37, 'ENM'], [82, 'EDM'], [127, 'TEXT:Hi'], [128, 'TEXT: there'], [158, 'TEXT:Hi'], [187, 'TEXT: there']], 29], []), ('normal control', [[[3, 'TEXT:Bye'], [18, 'ENM']], 24], []), ('normal control', [[[3, 'TEXT: there'], [33, 'TEXT:Bye'], [62, 'EDM']], 29], [])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=frame*1000//fps
        if cmd.startswith('TEXT:'):
            hidden+=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if since is not None:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flip emission guard', [[[0, 'TEXT:Hi'], [30, 'EOC'], [60, 'EDM']], 30], [[1000, 2000, 'Hi']]), ('regression variant: flip emission guard', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('partial repair probe: flip emission guard', [[[3, 'EOC'], [32, 'EOC'], [77, 'TEXT:Bye']], 25], []), ('partial repair variant: flip emission guard', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('normal control', [[[0, 'EDM'], [7, 'TEXT: there'], [37, 'TEXT: there']], 29], []), ('normal control', [[[30, 'EDM'], [60, 'TEXT: there'], [90, 'TEXT:Bye']], 24], []), ('normal control', [[[3, 'EDM'], [32, 'TEXT:Bye'], [77, 'TEXT:Bye'], [106, 'TEXT:Hi'], [151, 'TEXT:Hi']], 29], [])], [('regression: flip emission guard', [[[0, 'TEXT:A'], [10, 'EOC'], [20, 'TEXT:B'], [40, 'EOC'], [50, 'EOC']], 25], [[400, 1600, 'A'], [1600, 2000, 'B']]), ('regression variant: flip emission guard', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('partial repair probe: flip emission guard', [[[0, 'TEXT:Bye'], [1, 'EDM'], [31, 'TEXT: there'], [61, 'ENM'], [68, 'EOC'], [98, 'EOC'], [113, 'TEXT:Bye']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'EOC'], [7, 'ENM'], [52, 'EOC'], [81, 'TEXT:Hi']], 30], []), ('normal control', [[[0, 'EDM'], [15, 'TEXT:Bye']], 29], []), ('normal control', [[[3, 'TEXT: there'], [32, 'EDM'], [32, 'TEXT: there']], 25], []), ('normal control', [[[0, 'EDM'], [29, 'TEXT: there'], [44, 'TEXT: there'], [89, 'TEXT:Bye'], [134, 'TEXT: there']], 30], [])], [('regression: flip emission guard', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('regression variant: flip emission guard', [[[30, 'TEXT:Hi'], [31, 'TEXT: there'], [61, 'EDM'], [106, 'TEXT: there'], [121, 'ENM'], [136, 'TEXT:Hi'], [166, 'EOC']], 24], []), ('partial repair probe: flip emission guard', [[[0, 'EOC'], [7, 'EDM'], [14, 'EOC'], [59, 'EOC'], [104, 'EOC'], [133, 'EOC'], [162, 'EOC'], [207, 'EOC']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'EOC'], [1, 'EOC'], [30, 'ENM'], [37, 'TEXT:Bye']], 30], []), ('normal control', [[[0, 'ENM'], [29, 'TEXT:Bye'], [59, 'TEXT: there']], 25], []), ('normal control', [[[3, 'TEXT: there'], [48, 'TEXT:Hi'], [49, 'TEXT:Bye'], [78, 'TEXT:Hi']], 29], []), ('normal control', [[[3, 'TEXT:Bye'], [18, 'TEXT:Bye'], [25, 'TEXT:Bye'], [40, 'TEXT: there']], 30], [])], [('regression: flip emission guard', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('regression variant: flip emission guard', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], []), ('partial repair probe: flip emission guard', [[[30, 'EOC'], [59, 'EOC'], [60, 'TEXT: there'], [89, 'TEXT: there'], [96, 'ENM'], [96, 'TEXT:Bye'], [96, 'TEXT:Bye'], [96, 'TEXT: there']], 30], []), ('partial repair variant: flip emission guard', [[[30, 'EOC'], [31, 'ENM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [7, 'TEXT: there'], [37, 'EDM']], 25], []), ('normal control', [[[3, 'ENM'], [10, 'TEXT:Bye']], 25], []), ('normal control', [[[0, 'TEXT: there'], [7, 'TEXT:Hi'], [22, 'TEXT:Bye']], 29], [])], [('regression: flip emission guard', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('regression variant: flip emission guard', [[[30, 'EDM'], [30, 'EOC'], [60, 'ENM'], [89, 'ENM']], 25], []), ('partial repair probe: flip emission guard', [[[0, 'EOC'], [29, 'EOC'], [29, 'ENM'], [36, 'TEXT: there'], [37, 'TEXT: there'], [38, 'EOC']], 25], []), ('partial repair variant: flip emission guard', [[[0, 'TEXT:Bye'], [7, 'EOC'], [14, 'EDM'], [43, 'ENM'], [88, 'EDM'], [95, 'EOC'], [95, 'EOC'], [125, 'TEXT:Bye']], 24], [[291, 583, 'Bye']]), ('normal control', [[[0, 'TEXT:Bye'], [30, 'TEXT: there'], [37, 'ENM'], [82, 'EDM'], [127, 'TEXT:Hi'], [128, 'TEXT: there'], [158, 'TEXT:Hi'], [187, 'TEXT: there']], 29], []), ('normal control', [[[3, 'TEXT:Bye'], [18, 'ENM']], 24], []), ('normal control', [[[3, 'TEXT: there'], [33, 'TEXT:Bye'], [62, 'EDM']], 29], [])]]
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:
Empty captions with unknown start time are emitted when the first caption flips on.

Commands [frame,cmd] at integer fps (time = frame*1000//fps). TEXT:x appends x to the non-displayed memory; ENM erases non-displayed memory; EOC swaps displayed and non-displayed memories; EDM erases displayed memory. Whenever non-empty displayed text is replaced (EOC) or erased (EDM), emit [shown_since_ms, now_ms, text].

split: open-access


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

N = 1
observations = []
def solve(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=frame*1000//fps
        if cmd.startswith('TEXT:'):
            hidden=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if shown:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: text load target', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('regression variant: text load target', [[[30, 'TEXT:Hi'], [75, 'TEXT:Hi'], [120, 'EOC'], [135, 'TEXT:Hi'], [164, 'EDM'], [193, 'TEXT:Hi'], [238, 'EOC'], [267, 'EOC']], 25], [[4800, 6560, 'HiHi'], [9520, 10680, 'HiHi']]), ('partial repair probe: text load target', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('partial repair variant: text load target', [[[30, 'TEXT: there'], [31, 'EDM']], 24], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('normal control', [[[3, 'EDM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [0, 'EOC'], [30, 'TEXT:Hi']], 24], [])], [('regression: text load target', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('regression variant: text load target', [[[30, 'TEXT:Hi'], [31, 'TEXT:Bye'], [61, 'EOC'], [91, 'TEXT:Bye'], [92, 'TEXT: there'], [93, 'ENM'], [93, 'TEXT:Hi'], [122, 'EOC']], 24], [[2541, 5083, 'HiBye']]), ('partial repair probe: text load target', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('partial repair variant: text load target', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EOC'], [7, 'EDM'], [14, 'EOC'], [59, 'EOC'], [104, 'EOC'], [133, 'EOC'], [162, 'EOC'], [207, 'EOC']], 25], []), ('normal control', [[[3, 'TEXT:Hi'], [10, 'TEXT:Bye']], 30], []), ('normal control', [[[3, 'EOC'], [18, 'EOC'], [19, 'EOC']], 25], [])], [('regression: text load target', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('regression variant: text load target', [[[30, 'EOC'], [45, 'TEXT: there'], [75, 'TEXT:Hi'], [105, 'EOC'], [105, 'EOC']], 24], [[4375, 4375, ' thereHi']]), ('partial repair probe: text load target', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('partial repair variant: text load target', [[[30, 'EOC'], [31, 'TEXT: there'], [31, 'EDM'], [76, 'TEXT:Bye'], [76, 'ENM'], [91, 'EDM']], 30], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [14, 'TEXT:Bye']], 25], []), ('normal control', [[[30, 'EOC'], [60, 'TEXT: there']], 29], []), ('normal control', [[[0, 'EOC'], [1, 'EOC'], [30, 'ENM'], [37, 'TEXT:Bye']], 30], [])], [('regression: text load target', [[[30, 'TEXT:Hi'], [30, 'TEXT:Bye'], [60, 'TEXT:Bye'], [105, 'EOC'], [120, 'EOC'], [165, 'EOC'], [180, 'TEXT: there'], [195, 'EDM']], 24], [[4375, 5000, 'HiByeBye'], [6875, 8125, 'HiByeBye']]), ('regression variant: text load target', [[[0, 'EOC'], [0, 'TEXT: there'], [45, 'TEXT:Hi'], [46, 'EOC'], [91, 'EDM'], [120, 'TEXT:Hi'], [127, 'TEXT: there']], 25], [[1840, 3640, ' thereHi']]), ('partial repair probe: text load target', [[[30, 'TEXT:Hi'], [31, 'TEXT: there'], [61, 'EDM'], [106, 'TEXT: there'], [121, 'ENM'], [136, 'TEXT:Hi'], [166, 'EOC']], 24], []), ('partial repair variant: text load target', [[[30, 'TEXT:Bye'], [59, 'EOC'], [66, 'TEXT:Bye'], [111, 'EOC']], 24], [[2458, 4625, 'Bye']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EDM'], [15, 'TEXT:Bye']], 29], []), ('normal control', [[[3, 'EOC'], [48, 'ENM']], 30], []), ('normal control', [[[3, 'TEXT:Bye'], [48, 'TEXT:Hi']], 24], [])], [('regression: text load target', [[[3, 'EOC'], [3, 'TEXT: there'], [4, 'TEXT: there'], [34, 'EDM'], [64, 'EOC'], [71, 'EOC'], [78, 'TEXT: there'], [78, 'TEXT: there']], 30], [[2133, 2366, ' there there']]), ('regression variant: text load target', [[[0, 'TEXT: there'], [29, 'TEXT:Bye'], [44, 'EDM'], [73, 'EOC'], [118, 'EOC'], [163, 'TEXT: there'], [192, 'ENM']], 25], [[2920, 4720, ' thereBye']]), ('partial repair probe: text load target', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], []), ('partial repair variant: text load target', [[[0, 'TEXT: there'], [7, 'ENM'], [8, 'EOC'], [9, 'ENM'], [16, 'TEXT:Hi']], 30], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[3, 'EOC'], [4, 'EOC'], [19, 'EOC'], [20, 'EOC'], [21, 'EOC'], [51, 'EDM'], [58, 'EDM'], [58, 'EOC']], 24], []), ('normal control', [[[0, 'TEXT:Bye'], [30, 'ENM'], [59, 'TEXT:Bye'], [104, 'ENM'], [119, 'ENM'], [148, 'TEXT:Bye'], [178, 'ENM']], 30], []), ('normal control', [[[3, 'EOC'], [48, 'EOC'], [55, 'TEXT: there']], 24], [])]]
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(events, fps):
    shown=''
    hidden=''
    since=None
    out=[]
    for frame,cmd in events:
        t=frame*1000//fps
        if cmd.startswith('TEXT:'):
            shown+=cmd[5:]
        elif cmd=='ENM':
            hidden=''
        elif cmd=='EOC':
            if shown:
                out.append([since,t,shown])
            shown,hidden=hidden,shown
            since=t
        elif cmd=='EDM':
            if shown: out.append([since,t,shown])
            shown=''
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: text load target', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('regression variant: text load target', [[[30, 'TEXT:Hi'], [75, 'TEXT:Hi'], [120, 'EOC'], [135, 'TEXT:Hi'], [164, 'EDM'], [193, 'TEXT:Hi'], [238, 'EOC'], [267, 'EOC']], 25], [[4800, 6560, 'HiHi'], [9520, 10680, 'HiHi']]), ('partial repair probe: text load target', [[[0, 'EOC'], [7, 'TEXT:Bye'], [52, 'EDM'], [59, 'TEXT:Bye'], [74, 'EOC']], 24], []), ('partial repair variant: text load target', [[[30, 'TEXT: there'], [31, 'EDM']], 24], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[30, 'EOC'], [30, 'TEXT:Hi'], [37, 'ENM']], 24], []), ('normal control', [[[3, 'EDM'], [32, 'EOC']], 29], []), ('normal control', [[[0, 'ENM'], [0, 'EOC'], [30, 'TEXT:Hi']], 24], [])], [('regression: text load target', [[[3, 'TEXT:Hi'], [48, 'EOC'], [49, 'EOC'], [49, 'TEXT:Hi'], [94, 'TEXT:Bye'], [123, 'EOC'], [130, 'EDM']], 25], [[1920, 1960, 'Hi'], [4920, 5200, 'HiHiBye']]), ('regression variant: text load target', [[[30, 'TEXT:Hi'], [31, 'TEXT:Bye'], [61, 'EOC'], [91, 'TEXT:Bye'], [92, 'TEXT: there'], [93, 'ENM'], [93, 'TEXT:Hi'], [122, 'EOC']], 24], [[2541, 5083, 'HiBye']]), ('partial repair probe: text load target', [[[30, 'TEXT:Bye'], [37, 'EOC'], [52, 'EDM'], [52, 'ENM'], [67, 'EDM']], 30], [[1233, 1733, 'Bye']]), ('partial repair variant: text load target', [[[3, 'TEXT: there'], [32, 'TEXT: there'], [33, 'TEXT: there'], [48, 'EOC'], [78, 'EOC'], [123, 'TEXT: there']], 25], [[1920, 3120, ' there there there']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EOC'], [7, 'EDM'], [14, 'EOC'], [59, 'EOC'], [104, 'EOC'], [133, 'EOC'], [162, 'EOC'], [207, 'EOC']], 25], []), ('normal control', [[[3, 'TEXT:Hi'], [10, 'TEXT:Bye']], 30], []), ('normal control', [[[3, 'EOC'], [18, 'EOC'], [19, 'EOC']], 25], [])], [('regression: text load target', [[[0, 'TEXT:Bye'], [29, 'TEXT: there'], [44, 'TEXT: there'], [44, 'EOC'], [51, 'EOC']], 29], [[1517, 1758, 'Bye there there']]), ('regression variant: text load target', [[[30, 'EOC'], [45, 'TEXT: there'], [75, 'TEXT:Hi'], [105, 'EOC'], [105, 'EOC']], 24], [[4375, 4375, ' thereHi']]), ('partial repair probe: text load target', [[[0, 'EOC'], [30, 'TEXT:Bye'], [31, 'EOC'], [46, 'EOC'], [91, 'TEXT:Hi'], [92, 'TEXT: there'], [99, 'EDM'], [129, 'ENM']], 30], [[1033, 1533, 'Bye']]), ('partial repair variant: text load target', [[[30, 'EOC'], [31, 'TEXT: there'], [31, 'EDM'], [76, 'TEXT:Bye'], [76, 'ENM'], [91, 'EDM']], 30], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EOC'], [7, 'TEXT:Bye'], [14, 'TEXT:Bye']], 25], []), ('normal control', [[[30, 'EOC'], [60, 'TEXT: there']], 29], []), ('normal control', [[[0, 'EOC'], [1, 'EOC'], [30, 'ENM'], [37, 'TEXT:Bye']], 30], [])], [('regression: text load target', [[[30, 'TEXT:Hi'], [30, 'TEXT:Bye'], [60, 'TEXT:Bye'], [105, 'EOC'], [120, 'EOC'], [165, 'EOC'], [180, 'TEXT: there'], [195, 'EDM']], 24], [[4375, 5000, 'HiByeBye'], [6875, 8125, 'HiByeBye']]), ('regression variant: text load target', [[[0, 'EOC'], [0, 'TEXT: there'], [45, 'TEXT:Hi'], [46, 'EOC'], [91, 'EDM'], [120, 'TEXT:Hi'], [127, 'TEXT: there']], 25], [[1840, 3640, ' thereHi']]), ('partial repair probe: text load target', [[[30, 'TEXT:Hi'], [31, 'TEXT: there'], [61, 'EDM'], [106, 'TEXT: there'], [121, 'ENM'], [136, 'TEXT:Hi'], [166, 'EOC']], 24], []), ('partial repair variant: text load target', [[[30, 'TEXT:Bye'], [59, 'EOC'], [66, 'TEXT:Bye'], [111, 'EOC']], 24], [[2458, 4625, 'Bye']]), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[0, 'EDM'], [15, 'TEXT:Bye']], 29], []), ('normal control', [[[3, 'EOC'], [48, 'ENM']], 30], []), ('normal control', [[[3, 'TEXT:Bye'], [48, 'TEXT:Hi']], 24], [])], [('regression: text load target', [[[3, 'EOC'], [3, 'TEXT: there'], [4, 'TEXT: there'], [34, 'EDM'], [64, 'EOC'], [71, 'EOC'], [78, 'TEXT: there'], [78, 'TEXT: there']], 30], [[2133, 2366, ' there there']]), ('regression variant: text load target', [[[0, 'TEXT: there'], [29, 'TEXT:Bye'], [44, 'EDM'], [73, 'EOC'], [118, 'EOC'], [163, 'TEXT: there'], [192, 'ENM']], 25], [[2920, 4720, ' thereBye']]), ('partial repair probe: text load target', [[[30, 'TEXT: there'], [30, 'EOC'], [59, 'ENM']], 30], []), ('partial repair variant: text load target', [[[0, 'TEXT: there'], [7, 'ENM'], [8, 'EOC'], [9, 'ENM'], [16, 'TEXT:Hi']], 30], []), ('boundary control', [[[0, 'EOC'], [5, 'EDM']], 30], []), ('normal control', [[[3, 'EOC'], [4, 'EOC'], [19, 'EOC'], [20, 'EOC'], [21, 'EOC'], [51, 'EDM'], [58, 'EDM'], [58, 'EOC']], 24], []), ('normal control', [[[0, 'TEXT:Bye'], [30, 'ENM'], [59, 'TEXT:Bye'], [104, 'ENM'], [119, 'ENM'], [148, 'TEXT:Bye'], [178, 'ENM']], 30], []), ('normal control', [[[3, 'EOC'], [48, 'EOC'], [55, 'TEXT: there']], 24], [])]]
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:
Multi-part caption loads keep only the last text fragment.

Commands [frame,cmd] at integer fps (time = frame*1000//fps). TEXT:x appends x to the non-displayed memory; ENM erases non-displayed memory; EOC swaps displayed and non-displayed memories; EDM erases displayed memory. Whenever non-empty displayed text is replaced (EOC) or erased (EDM), emit [shown_since_ms, now_ms, text].

split: open-access


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

N = 1
observations = []
def solve(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text)
    d=base+n*per
    d=max(lo,min(hi,d))
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,-((-fr*1000*den)//num)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: character counting', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('regression variant: character counting', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042]), ('partial repair probe: character counting', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair variant: character counting', ['Two\nlines here', [30000, 1001], [500, 60, 1000, 6000]], [37, 1235]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [25, 1], [700, 100, 1000, 2000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502])], [('regression: character counting', ['Hello world', [30, 1], [700, 100, 1000, 2000]], [51, 1700]), ('regression variant: character counting', ['Hello world', [24000, 1001], [500, 60, 1000, 6000]], [27, 1127]), ('partial repair probe: character counting', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('partial repair variant: character counting', ['Two\nlines here', [24, 1], [700, 100, 1000, 2000]], [46, 1917]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('normal control', ['ok', [30, 1], [700, 100, 1000, 2000]], [30, 1000]), ('normal control', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000])], [('regression: character counting', ['Two\nlines here', [30, 1], [700, 100, 1000, 2000]], [57, 1900]), ('regression variant: character counting', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('partial repair probe: character counting', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('partial repair variant: character counting', ['Two\nlines here', [25, 1], [700, 100, 1000, 2000]], [48, 1920]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['Hello world', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('normal control', ['ok', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('normal control', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209])], [('regression: character counting', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('regression variant: character counting', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('partial repair probe: character counting', ['Two\nlines here', [24, 1], [500, 60, 1000, 6000]], [30, 1250]), ('partial repair variant: character counting', ['Two\nlines here', [30, 1], [0, 70, 800, 7000]], [26, 867]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [30, 1], [300, 50, 1200, 1500]], [36, 1200]), ('normal control', ['ok', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('normal control', ['   ', [25, 1], [500, 60, 1000, 6000]], [25, 1000])], [('regression: character counting', ['Hello world', [30000, 1001], [500, 60, 1000, 6000]], [33, 1102]), ('regression variant: character counting', ['Hello world', [30, 1], [500, 60, 1000, 6000]], [33, 1100]), ('partial repair probe: character counting', ['Two\nlines here', [24000, 1001], [500, 60, 1000, 6000]], [30, 1252]), ('partial repair variant: character counting', ['Two\nlines here', [30000, 1001], [700, 100, 1000, 2000]], [57, 1902]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['ok', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['   ', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('normal control', ['Two\nlines here', [30, 1], [300, 50, 1200, 1500]], [36, 1200])]]
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(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text.replace(' ',''))
    d=base+n*per
    d=max(lo,min(hi,d))
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,-((-fr*1000*den)//num)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: character counting', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('regression variant: character counting', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042]), ('partial repair probe: character counting', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair variant: character counting', ['Two\nlines here', [30000, 1001], [500, 60, 1000, 6000]], [37, 1235]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [25, 1], [700, 100, 1000, 2000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502])], [('regression: character counting', ['Hello world', [30, 1], [700, 100, 1000, 2000]], [51, 1700]), ('regression variant: character counting', ['Hello world', [24000, 1001], [500, 60, 1000, 6000]], [27, 1127]), ('partial repair probe: character counting', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('partial repair variant: character counting', ['Two\nlines here', [24, 1], [700, 100, 1000, 2000]], [46, 1917]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('normal control', ['ok', [30, 1], [700, 100, 1000, 2000]], [30, 1000]), ('normal control', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000])], [('regression: character counting', ['Two\nlines here', [30, 1], [700, 100, 1000, 2000]], [57, 1900]), ('regression variant: character counting', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('partial repair probe: character counting', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('partial repair variant: character counting', ['Two\nlines here', [25, 1], [700, 100, 1000, 2000]], [48, 1920]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['Hello world', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('normal control', ['ok', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('normal control', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209])], [('regression: character counting', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('regression variant: character counting', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('partial repair probe: character counting', ['Two\nlines here', [24, 1], [500, 60, 1000, 6000]], [30, 1250]), ('partial repair variant: character counting', ['Two\nlines here', [30, 1], [0, 70, 800, 7000]], [26, 867]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [30, 1], [300, 50, 1200, 1500]], [36, 1200]), ('normal control', ['ok', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('normal control', ['   ', [25, 1], [500, 60, 1000, 6000]], [25, 1000])], [('regression: character counting', ['Hello world', [30000, 1001], [500, 60, 1000, 6000]], [33, 1102]), ('regression variant: character counting', ['Hello world', [30, 1], [500, 60, 1000, 6000]], [33, 1100]), ('partial repair probe: character counting', ['Two\nlines here', [24000, 1001], [500, 60, 1000, 6000]], [30, 1252]), ('partial repair variant: character counting', ['Two\nlines here', [30000, 1001], [700, 100, 1000, 2000]], [57, 1902]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['ok', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['   ', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('normal control', ['Two\nlines here', [30, 1], [300, 50, 1200, 1500]], [36, 1200])]]
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:
Multi-word subtitles get recommended durations that are too long.

rules [base,per_char,min,max]. Count characters other than spaces and line breaks; duration = base + count*per_char, clamped to [min,max]; then rounded up to whole frames at fps [N,D]. Return [frames, ceil(frames*1000*D/N)].

split: open-access


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

N = 1
observations = []
def solve(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text.replace(' ','').replace('\n',''))
    d=base+n*per
    d=max(lo,d)
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,-((-fr*1000*den)//num)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: duration clamp', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [30, 1], [300, 50, 1200, 1500]], [45, 1500]), ('partial repair probe: duration clamp', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('partial repair variant: duration clamp', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Hello world', [30, 1], [700, 100, 1000, 2000]], [51, 1700]), ('normal control', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('normal control', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042])], [('regression: duration clamp', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [24000, 1001], [700, 100, 1000, 2000]], [48, 2002]), ('partial repair probe: duration clamp', ['ok', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: duration clamp', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('normal control', ['Hello world', [30000, 1001], [700, 100, 1000, 2000]], [51, 1702]), ('normal control', ['A much longer subtitle line to read', [30, 1], [0, 70, 800, 7000]], [61, 2034])], [('regression: duration clamp', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [30000, 1001], [700, 100, 1000, 2000]], [60, 2002]), ('partial repair probe: duration clamp', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: duration clamp', ['Hello world', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [24, 1], [500, 60, 1000, 6000]], [30, 1250]), ('normal control', ['Two\nlines here', [24000, 1001], [500, 60, 1000, 6000]], [30, 1252]), ('normal control', ['A much longer subtitle line to read', [24000, 1001], [500, 60, 1000, 6000]], [54, 2253])], [('regression: duration clamp', ['A much longer subtitle line to read', [24, 1], [700, 100, 1000, 2000]], [48, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [25, 1], [300, 50, 1200, 1500]], [38, 1520]), ('partial repair probe: duration clamp', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('partial repair variant: duration clamp', ['Hello world', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [25, 1], [500, 60, 1000, 6000]], [31, 1240]), ('normal control', ['Hello world', [24, 1], [700, 100, 1000, 2000]], [41, 1709]), ('normal control', ['A much longer subtitle line to read', [30000, 1001], [0, 70, 800, 7000]], [61, 2036])], [('regression: duration clamp', ['A much longer subtitle line to read', [30000, 1001], [300, 50, 1200, 1500]], [45, 1502]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [24, 1], [300, 50, 1200, 1500]], [36, 1500]), ('partial repair probe: duration clamp', ['Hello world', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('partial repair variant: duration clamp', ['Hello world', [30, 1], [300, 50, 1200, 1500]], [36, 1200]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['A much longer subtitle line to read', [24, 1], [500, 60, 1000, 6000]], [54, 2250]), ('normal control', ['Two\nlines here', [30, 1], [0, 70, 800, 7000]], [26, 867]), ('normal control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 6000]], [56, 2240])]]
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(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text.replace(' ','').replace('\n',''))
    d=base+n*per
    d=min(hi,d)
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,-((-fr*1000*den)//num)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: duration clamp', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [30, 1], [300, 50, 1200, 1500]], [45, 1500]), ('partial repair probe: duration clamp', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('partial repair variant: duration clamp', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Hello world', [30, 1], [700, 100, 1000, 2000]], [51, 1700]), ('normal control', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('normal control', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042])], [('regression: duration clamp', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [24000, 1001], [700, 100, 1000, 2000]], [48, 2002]), ('partial repair probe: duration clamp', ['ok', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: duration clamp', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('normal control', ['Hello world', [30000, 1001], [700, 100, 1000, 2000]], [51, 1702]), ('normal control', ['A much longer subtitle line to read', [30, 1], [0, 70, 800, 7000]], [61, 2034])], [('regression: duration clamp', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [30000, 1001], [700, 100, 1000, 2000]], [60, 2002]), ('partial repair probe: duration clamp', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: duration clamp', ['Hello world', [30, 1], [0, 70, 800, 7000]], [24, 800]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [24, 1], [500, 60, 1000, 6000]], [30, 1250]), ('normal control', ['Two\nlines here', [24000, 1001], [500, 60, 1000, 6000]], [30, 1252]), ('normal control', ['A much longer subtitle line to read', [24000, 1001], [500, 60, 1000, 6000]], [54, 2253])], [('regression: duration clamp', ['A much longer subtitle line to read', [24, 1], [700, 100, 1000, 2000]], [48, 2000]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [25, 1], [300, 50, 1200, 1500]], [38, 1520]), ('partial repair probe: duration clamp', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000]), ('partial repair variant: duration clamp', ['Hello world', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['Two\nlines here', [25, 1], [500, 60, 1000, 6000]], [31, 1240]), ('normal control', ['Hello world', [24, 1], [700, 100, 1000, 2000]], [41, 1709]), ('normal control', ['A much longer subtitle line to read', [30000, 1001], [0, 70, 800, 7000]], [61, 2036])], [('regression: duration clamp', ['A much longer subtitle line to read', [30000, 1001], [300, 50, 1200, 1500]], [45, 1502]), ('regression variant: duration clamp', ['A much longer subtitle line to read', [24, 1], [300, 50, 1200, 1500]], [36, 1500]), ('partial repair probe: duration clamp', ['Hello world', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('partial repair variant: duration clamp', ['Hello world', [30, 1], [300, 50, 1200, 1500]], [36, 1200]), ('boundary control', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('normal control', ['A much longer subtitle line to read', [24, 1], [500, 60, 1000, 6000]], [54, 2250]), ('normal control', ['Two\nlines here', [30, 1], [0, 70, 800, 7000]], [26, 867]), ('normal control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 6000]], [56, 2240])]]
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:
Long subtitles are held on screen beyond the maximum duration.

rules [base,per_char,min,max]. Count characters other than spaces and line breaks; duration = base + count*per_char, clamped to [min,max]; then rounded up to whole frames at fps [N,D]. Return [frames, ceil(frames*1000*D/N)].

split: open-access


prompt:
Recommended durations fall short of the computed minimum by part of a frame.

rules [base,per_char,min,max]. Count characters other than spaces and line breaks; duration = base + count*per_char, clamped to [min,max]; then rounded up to whole frames at fps [N,D]. Return [frames, ceil(frames*1000*D/N)].

split: open-access


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

N = 1
observations = []
def solve(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text.replace(' ','').replace('\n',''))
    d=base+n*per
    d=max(lo,min(hi,d))
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,fr*1000*den//num]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame back-conversion', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('regression variant: frame back-conversion', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair probe: frame back-conversion', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('partial repair variant: frame back-conversion', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [25, 1], [700, 100, 1000, 2000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000])], [('regression: frame back-conversion', ['ok', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('regression variant: frame back-conversion', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair probe: frame back-conversion', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: frame back-conversion', ['Hi', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hello world', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000]), ('normal control', ['Hello world', [30, 1], [300, 50, 1200, 1500]], [36, 1200])], [('regression: frame back-conversion', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('regression variant: frame back-conversion', ['Hello world', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('partial repair probe: frame back-conversion', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('partial repair variant: frame back-conversion', ['', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [24, 1], [700, 100, 1000, 2000]], [24, 1000]), ('normal control', ['ok', [24, 1], [700, 100, 1000, 2000]], [24, 1000]), ('normal control', ['', [24000, 1001], [700, 100, 1000, 2000]], [24, 1001])], [('regression: frame back-conversion', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('regression variant: frame back-conversion', ['ok', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair probe: frame back-conversion', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair variant: frame back-conversion', ['Hello world', [30000, 1001], [500, 60, 1000, 6000]], [33, 1102]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [30000, 1001], [700, 100, 1000, 2000]], [30, 1001]), ('normal control', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('normal control', ['ok', [25, 1], [500, 60, 1000, 6000]], [25, 1000])], [('regression: frame back-conversion', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('regression variant: frame back-conversion', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209]), ('partial repair probe: frame back-conversion', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair variant: frame back-conversion', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('normal control', ['Hello world', [30, 1], [500, 60, 1000, 6000]], [33, 1100])]]
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(text, fps, rules):
    base,per,lo,hi=rules
    n=len(text.replace(' ','').replace('\n',''))
    d=base+n*per
    d=max(lo,min(hi,d))
    num,den=fps
    fr=-((-d*num)//(1000*den))
    return [fr,fr*1000//num*den]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame back-conversion', ['Two\nlines here', [30000, 1001], [0, 70, 800, 7000]], [26, 868]), ('regression variant: frame back-conversion', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair probe: frame back-conversion', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('partial repair variant: frame back-conversion', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [25, 1], [700, 100, 1000, 2000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['Hi', [24, 1], [500, 60, 1000, 6000]], [24, 1000])], [('regression: frame back-conversion', ['ok', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('regression variant: frame back-conversion', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair probe: frame back-conversion', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('partial repair variant: frame back-conversion', ['Hi', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hello world', [25, 1], [300, 50, 1200, 1500]], [30, 1200]), ('normal control', ['A much longer subtitle line to read', [30, 1], [700, 100, 1000, 2000]], [60, 2000]), ('normal control', ['Hello world', [30, 1], [300, 50, 1200, 1500]], [36, 1200])], [('regression: frame back-conversion', ['A much longer subtitle line to read', [24000, 1001], [300, 50, 1200, 1500]], [36, 1502]), ('regression variant: frame back-conversion', ['Hello world', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('partial repair probe: frame back-conversion', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('partial repair variant: frame back-conversion', ['', [30000, 1001], [0, 70, 800, 7000]], [24, 801]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['   ', [24, 1], [700, 100, 1000, 2000]], [24, 1000]), ('normal control', ['ok', [24, 1], [700, 100, 1000, 2000]], [24, 1000]), ('normal control', ['', [24000, 1001], [700, 100, 1000, 2000]], [24, 1001])], [('regression: frame back-conversion', ['Hi', [24, 1], [0, 70, 800, 7000]], [20, 834]), ('regression variant: frame back-conversion', ['ok', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair probe: frame back-conversion', ['Two\nlines here', [30000, 1001], [300, 50, 1200, 1500]], [36, 1202]), ('partial repair variant: frame back-conversion', ['Hello world', [30000, 1001], [500, 60, 1000, 6000]], [33, 1102]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Hi', [30000, 1001], [700, 100, 1000, 2000]], [30, 1001]), ('normal control', ['Two\nlines here', [24, 1], [0, 70, 800, 7000]], [21, 875]), ('normal control', ['ok', [25, 1], [500, 60, 1000, 6000]], [25, 1000])], [('regression: frame back-conversion', ['   ', [24000, 1001], [0, 70, 800, 7000]], [20, 835]), ('regression variant: frame back-conversion', ['', [24, 1], [300, 50, 1200, 1500]], [29, 1209]), ('partial repair probe: frame back-conversion', ['Two\nlines here', [24000, 1001], [700, 100, 1000, 2000]], [46, 1919]), ('partial repair variant: frame back-conversion', ['A much longer subtitle line to read', [24, 1], [0, 70, 800, 7000]], [49, 2042]), ('boundary control', ['Hi', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('boundary control', ['A much longer subtitle line to read', [25, 1], [500, 60, 1000, 2000]], [50, 2000]), ('normal control', ['', [25, 1], [500, 60, 1000, 6000]], [25, 1000]), ('normal control', ['Two\nlines here', [25, 1], [0, 70, 800, 7000]], [21, 840]), ('normal control', ['Hello world', [30, 1], [500, 60, 1000, 6000]], [33, 1100])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The reported millisecond duration is shorter than the frame count covers.

rules [base,per_char,min,max]. Count characters other than spaces and line breaks; duration = base + count*per_char, clamped to [min,max]; then rounded up to whole frames at fps [N,D]. Return [frames, ceil(frames*1000*D/N)].

split: open-access


prompt:
Short subtitles get barely any screen time.

rules [base,per_char,min,max]. Count characters other than spaces and line breaks; duration = base + count*per_char, clamped to [min,max]; then rounded up to whole frames at fps [N,D]. Return [frames, ceil(frames*1000*D/N)].

split: open-access


prompt:
A cue starting exactly at the query time is not shown.

cues [start,end] are sorted by start. Return the ascending indices of cues active at t (start <= t < end). The search bisects the starts and walks backwards while the running maximum end of the prefix exceeds t.

split: open-access


prompt:
A cue is still reported at the instant it ends.

cues [start,end] are sorted by start. Return the ascending indices of cues active at t (start <= t < end). The search bisects the starts and walks backwards while the running maximum end of the prefix exceeds t.

split: open-access


prompt:
A long cue that started earlier is missed when a short cue ends between it and the query.

cues [start,end] are sorted by start. Return the ascending indices of cues active at t (start <= t < end). The search bisects the starts and walks backwards while the running maximum end of the prefix exceeds t.

split: open-access


prompt:
Earlier long cues are skipped once a short cue follows them.

cues [start,end] are sorted by start. Return the ascending indices of cues active at t (start <= t < end). The search bisects the starts and walks backwards while the running maximum end of the prefix exceeds t.

split: open-access


prompt:
Active cues are returned from last to first.

cues [start,end] are sorted by start. Return the ascending indices of cues active at t (start <= t < end). The search bisects the starts and walks backwards while the running maximum end of the prefix exceeds t.

split: open-access


prompt:
Cues that start inside a removed section keep a start inside material that no longer exists.

Cuts [a,b) are removed from the programme (they may overlap or be unsorted and are merged first). A time after a cut shifts left by the removed length; a time inside a cut maps to the cut point. Cues [start,end,text] are mapped and dropped when the mapped end is not after the mapped start.

split: open-access


prompt:
Cues after two or more cuts are shifted by only the most recent cut.

Cuts [a,b) are removed from the programme (they may overlap or be unsorted and are merged first). A time after a cut shifts left by the removed length; a time inside a cut maps to the cut point. Cues [start,end,text] are mapped and dropped when the mapped end is not after the mapped start.

split: open-access


prompt:
Unordered cut lists produce wrong shifts after the first cut.

Cuts [a,b) are removed from the programme (they may overlap or be unsorted and are merged first). A time after a cut shifts left by the removed length; a time inside a cut maps to the cut point. Cues [start,end,text] are mapped and dropped when the mapped end is not after the mapped start.

split: open-access


prompt:
A cut nested inside a larger cut shortens the removed range.

Cuts [a,b) are removed from the programme (they may overlap or be unsorted and are merged first). A time after a cut shifts left by the removed length; a time inside a cut maps to the cut point. Cues [start,end,text] are mapped and dropped when the mapped end is not after the mapped start.

split: open-access


prompt:
Cues wholly inside a removed section survive as zero-length cues.

Cuts [a,b) are removed from the programme (they may overlap or be unsorted and are merged first). A time after a cut shifts left by the removed length; a time inside a cut maps to the cut point. Cues [start,end,text] are mapped and dropped when the mapped end is not after the mapped start.

split: open-access


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

N = 1
observations = []
def solve(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>23:
        return None
    if m>59 or s>59:
        return None
    if fr>fps:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field bound', ['00:00:00:25', 25], None), ('regression variant: frame field bound', ['01:59:00:24', 24], None), ('partial repair probe: frame field bound', ['00:59:00:29', 25], None), ('partial repair variant: frame field bound', ['23:00:59:25', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['1:59:59:24', 30], None), ('normal control', ['00:07:00.24', 25], None)], [('regression: frame field bound', ['00:59:59:24', 24], None), ('regression variant: frame field bound', ['00:07:59:30', 30], None), ('partial repair probe: frame field bound', ['23:07:00:24', 24], None), ('partial repair variant: frame field bound', ['23:00:00:25', 24], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['01:00:00.00', 24], None), ('normal control', ['00:59:00.25', 25], None), ('normal control', ['24:07:60:30', 30], None)], [('regression: frame field bound', ['23:07:00:24', 24], None), ('regression variant: frame field bound', ['23:00:00:24', 24], None), ('partial repair probe: frame field bound', ['01:00:59:29', 24], None), ('partial repair variant: frame field bound', ['01:07:59:24', 24], None), ('boundary control', ['24:00:00:00', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:07:60:30', 30], None), ('normal control', ['00:59:5:00', 25], None), ('normal control', ['01:59:59;25', 30], None)], [('regression: frame field bound', ['01:59:00:30', 30], None), ('regression variant: frame field bound', ['00:59:00:25', 25], None), ('partial repair probe: frame field bound', ['01:00:59:29', 24], None), ('partial repair variant: frame field bound', ['00:00:59:25', 24], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('normal control', ['00:00:59.29', 24], None), ('normal control', ['99:07:59;29', 30], None), ('normal control', ['23:59:5:29', 25], None)], [('regression: frame field bound', ['00:59:59:30', 30], None), ('regression variant: frame field bound', ['00:07:00:30', 30], None), ('partial repair probe: frame field bound', ['01:59:00:24', 24], None), ('partial repair variant: frame field bound', ['00:00:59:24', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['1:59:00;25', 25], None), ('normal control', ['1:60:00:24', 24], None), ('normal control', ['24:00:60:25', 30], 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(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>23:
        return None
    if m>59 or s>59:
        return None
    if fr>=30:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame field bound', ['00:00:00:25', 25], None), ('regression variant: frame field bound', ['01:59:00:24', 24], None), ('partial repair probe: frame field bound', ['00:59:00:29', 25], None), ('partial repair variant: frame field bound', ['23:00:59:25', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['1:59:59:24', 30], None), ('normal control', ['00:07:00.24', 25], None)], [('regression: frame field bound', ['00:59:59:24', 24], None), ('regression variant: frame field bound', ['00:07:59:30', 30], None), ('partial repair probe: frame field bound', ['23:07:00:24', 24], None), ('partial repair variant: frame field bound', ['23:00:00:25', 24], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['01:00:00.00', 24], None), ('normal control', ['00:59:00.25', 25], None), ('normal control', ['24:07:60:30', 30], None)], [('regression: frame field bound', ['23:07:00:24', 24], None), ('regression variant: frame field bound', ['23:00:00:24', 24], None), ('partial repair probe: frame field bound', ['01:00:59:29', 24], None), ('partial repair variant: frame field bound', ['01:07:59:24', 24], None), ('boundary control', ['24:00:00:00', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:07:60:30', 30], None), ('normal control', ['00:59:5:00', 25], None), ('normal control', ['01:59:59;25', 30], None)], [('regression: frame field bound', ['01:59:00:30', 30], None), ('regression variant: frame field bound', ['00:59:00:25', 25], None), ('partial repair probe: frame field bound', ['01:00:59:29', 24], None), ('partial repair variant: frame field bound', ['00:00:59:25', 24], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('normal control', ['00:00:59.29', 24], None), ('normal control', ['99:07:59;29', 30], None), ('normal control', ['23:59:5:29', 25], None)], [('regression: frame field bound', ['00:59:59:30', 30], None), ('regression variant: frame field bound', ['00:07:00:30', 30], None), ('partial repair probe: frame field bound', ['01:59:00:24', 24], None), ('partial repair variant: frame field bound', ['00:00:59:24', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['1:59:00;25', 25], None), ('normal control', ['1:60:00:24', 24], None), ('normal control', ['24:00:60:25', 30], None)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A PAL label ending in :25 is accepted and lands on the first frame of the next second.

Parse a non-drop label HH:MM:SS:FF (exactly two digits per field, colons only) at integer fps to a frame count from midnight. Hours 0-23, minutes and seconds 0-59, frames below fps; anything else, including drop-frame separators, returns None.

split: open-access


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

N = 1
observations = []
def solve(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>24:
        return None
    if m>59 or s>59:
        return None
    if fr>=fps:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hour field bound', ['24:00:00:00', 25], None), ('regression variant: hour field bound', ['24:00:59:25', 30], None), ('partial repair probe: hour field bound', ['24:59:59:24', 30], None), ('partial repair variant: hour field bound', ['24:59:59:23', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['1:59:59:24', 30], None), ('normal control', ['00:07:00.24', 25], None)], [('regression: hour field bound', ['24:59:59:23', 24], None), ('regression variant: hour field bound', ['24:59:00:00', 24], None), ('partial repair probe: hour field bound', ['24:00:00:00', 30], None), ('partial repair variant: hour field bound', ['24:59:59:24', 30], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['01:00:00.00', 24], None), ('normal control', ['00:59:00.25', 25], None), ('normal control', ['24:07:60:30', 30], None)], [('regression: hour field bound', ['24:59:59:24', 30], None), ('regression variant: hour field bound', ['24:07:59:29', 30], None), ('partial repair probe: hour field bound', ['24:07:59:25', 30], None), ('partial repair variant: hour field bound', ['24:00:00:00', 30], None), ('boundary control', ['00:00:00:25', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:07:60:30', 30], None), ('normal control', ['00:59:5:00', 25], None), ('normal control', ['01:59:59;25', 30], None)], [('regression: hour field bound', ['24:00:00:00', 30], None), ('regression variant: hour field bound', ['24:00:00:00', 25], None), ('partial repair probe: hour field bound', ['24:00:59:25', 30], None), ('partial repair variant: hour field bound', ['24:07:59:25', 30], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['00:00:00:25', 25], None), ('normal control', ['00:00:59.29', 24], None), ('normal control', ['01:00:60:29', 24], None), ('normal control', ['00:07:60:25', 24], None)], [('regression: hour field bound', ['24:07:59:25', 30], None), ('regression variant: hour field bound', ['24:59:59:23', 24], None), ('partial repair probe: hour field bound', ['24:59:00:00', 24], None), ('partial repair variant: hour field bound', ['24:00:59:25', 30], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['24:59:59:24', 24], None), ('normal control', ['99:60:59:25', 25], None), ('normal control', ['01:59:5.30', 30], 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(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>=99:
        return None
    if m>59 or s>59:
        return None
    if fr>=fps:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hour field bound', ['24:00:00:00', 25], None), ('regression variant: hour field bound', ['24:00:59:25', 30], None), ('partial repair probe: hour field bound', ['24:59:59:24', 30], None), ('partial repair variant: hour field bound', ['24:59:59:23', 24], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['1:59:59:24', 30], None), ('normal control', ['00:07:00.24', 25], None)], [('regression: hour field bound', ['24:59:59:23', 24], None), ('regression variant: hour field bound', ['24:59:00:00', 24], None), ('partial repair probe: hour field bound', ['24:00:00:00', 30], None), ('partial repair variant: hour field bound', ['24:59:59:24', 30], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['01:00:00.00', 24], None), ('normal control', ['00:59:00.25', 25], None), ('normal control', ['24:07:60:30', 30], None)], [('regression: hour field bound', ['24:59:59:24', 30], None), ('regression variant: hour field bound', ['24:07:59:29', 30], None), ('partial repair probe: hour field bound', ['24:07:59:25', 30], None), ('partial repair variant: hour field bound', ['24:00:00:00', 30], None), ('boundary control', ['00:00:00:25', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:07:60:30', 30], None), ('normal control', ['00:59:5:00', 25], None), ('normal control', ['01:59:59;25', 30], None)], [('regression: hour field bound', ['24:00:00:00', 30], None), ('regression variant: hour field bound', ['24:00:00:00', 25], None), ('partial repair probe: hour field bound', ['24:00:59:25', 30], None), ('partial repair variant: hour field bound', ['24:07:59:25', 30], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['00:00:00:25', 25], None), ('normal control', ['00:00:59.29', 24], None), ('normal control', ['01:00:60:29', 24], None), ('normal control', ['00:07:60:25', 24], None)], [('regression: hour field bound', ['24:07:59:25', 30], None), ('regression variant: hour field bound', ['24:59:59:23', 24], None), ('partial repair probe: hour field bound', ['24:59:00:00', 24], None), ('partial repair variant: hour field bound', ['24:00:59:25', 30], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['24:59:59:24', 24], None), ('normal control', ['99:60:59:25', 25], None), ('normal control', ['01:59:5.30', 30], 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:
Labels at hour 24 are accepted and alias the following day.

Parse a non-drop label HH:MM:SS:FF (exactly two digits per field, colons only) at integer fps to a frame count from midnight. Hours 0-23, minutes and seconds 0-59, frames below fps; anything else, including drop-frame separators, returns None.

split: open-access


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

N = 1
observations = []
def solve(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>23:
        return None
    if m>59 or s>60:
        return None
    if fr>=fps:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: sexagesimal bounds', ['01:00:60:00', 25], None), ('regression variant: sexagesimal bounds', ['23:59:60:25', 30], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:24', 30], None), ('partial repair variant: sexagesimal bounds', ['23:60:00:24', 30], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['00:00:00:25', 25], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['01:00:00;00', 30], None), ('normal control', ['1:59:59:24', 30], None)], [('regression: sexagesimal bounds', ['00:59:60:24', 25], None), ('regression variant: sexagesimal bounds', ['00:00:60:23', 24], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:00', 24], None), ('partial repair variant: sexagesimal bounds', ['00:60:59:23', 24], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:07:60.30', 30], None), ('normal control', ['24:07:59:30', 30], None), ('normal control', ['1:59:59:00', 24], None)], [('regression: sexagesimal bounds', ['01:00:60:23', 24], None), ('regression variant: sexagesimal bounds', ['01:00:60:00', 30], None), ('partial repair probe: sexagesimal bounds', ['23:60:59:29', 30], None), ('partial repair variant: sexagesimal bounds', ['01:60:59:24', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['00:60:5:30', 24], None), ('normal control', ['99:07:00:30', 25], None), ('normal control', ['00:00:5:00', 25], None)], [('regression: sexagesimal bounds', ['00:07:60:29', 30], None), ('regression variant: sexagesimal bounds', ['00:00:60:00', 24], None), ('partial repair probe: sexagesimal bounds', ['01:60:00:23', 24], None), ('partial repair variant: sexagesimal bounds', ['01:60:59:00', 24], None), ('boundary control', ['00:00:00:25', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:59:59:24', 25], 89999), ('normal control', ['1:07:59.29', 25], None), ('normal control', ['99:07:59;29', 30], None)], [('regression: sexagesimal bounds', ['00:07:60:00', 25], None), ('regression variant: sexagesimal bounds', ['00:07:60:24', 30], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:24', 25], None), ('partial repair variant: sexagesimal bounds', ['23:60:59:29', 30], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('normal control', ['23:59:5:29', 25], None), ('normal control', ['23:00:59;30', 30], None), ('normal control', ['1:60:00:24', 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(tc, fps):
    f=tc.split(':')
    if len(f)!=4 or not all(len(x)==2 and x.isdigit() for x in f):
        return None
    h,m,s,fr=map(int,f)
    if h>23:
        return None
    if m>60 or s>59:
        return None
    if fr>=fps:
        return None
    return ((h*60+m)*60+s)*fps+fr
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: sexagesimal bounds', ['01:00:60:00', 25], None), ('regression variant: sexagesimal bounds', ['23:59:60:25', 30], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:24', 30], None), ('partial repair variant: sexagesimal bounds', ['23:60:00:24', 30], None), ('boundary control', ['00:00:00:00', 25], 0), ('boundary control', ['00:00:00:25', 25], None), ('normal control', ['23:59:59:24', 25], 2159999), ('normal control', ['01:00:00;00', 30], None), ('normal control', ['1:59:59:24', 30], None)], [('regression: sexagesimal bounds', ['00:59:60:24', 25], None), ('regression variant: sexagesimal bounds', ['00:00:60:23', 24], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:00', 24], None), ('partial repair variant: sexagesimal bounds', ['00:60:59:23', 24], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('boundary control', ['01:00:00;00', 30], None), ('normal control', ['23:07:60.30', 30], None), ('normal control', ['24:07:59:30', 30], None), ('normal control', ['1:59:59:00', 24], None)], [('regression: sexagesimal bounds', ['01:00:60:23', 24], None), ('regression variant: sexagesimal bounds', ['01:00:60:00', 30], None), ('partial repair probe: sexagesimal bounds', ['23:60:59:29', 30], None), ('partial repair variant: sexagesimal bounds', ['01:60:59:24', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('boundary control', ['00:00:00:00', 25], 0), ('normal control', ['00:60:5:30', 24], None), ('normal control', ['99:07:00:30', 25], None), ('normal control', ['00:00:5:00', 25], None)], [('regression: sexagesimal bounds', ['00:07:60:29', 30], None), ('regression variant: sexagesimal bounds', ['00:00:60:00', 24], None), ('partial repair probe: sexagesimal bounds', ['01:60:00:23', 24], None), ('partial repair variant: sexagesimal bounds', ['01:60:59:00', 24], None), ('boundary control', ['00:00:00:25', 25], None), ('boundary control', ['23:59:59:24', 25], 2159999), ('normal control', ['00:59:59:24', 25], 89999), ('normal control', ['1:07:59.29', 25], None), ('normal control', ['99:07:59;29', 30], None)], [('regression: sexagesimal bounds', ['00:07:60:00', 25], None), ('regression variant: sexagesimal bounds', ['00:07:60:24', 30], None), ('partial repair probe: sexagesimal bounds', ['01:60:59:24', 25], None), ('partial repair variant: sexagesimal bounds', ['23:60:59:29', 30], None), ('boundary control', ['01:00:00;00', 30], None), ('boundary control', ['24:00:00:00', 25], None), ('normal control', ['23:59:5:29', 25], None), ('normal control', ['23:00:59;30', 30], None), ('normal control', ['1:60:00:24', 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:
Labels with a seconds field of 60 are accepted and roll into the next minute.

Parse a non-drop label HH:MM:SS:FF (exactly two digits per field, colons only) at integer fps to a frame count from midnight. Hours 0-23, minutes and seconds 0-59, frames below fps; anything else, including drop-frame separators, returns None.

split: open-access