broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if init > limit:
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init >= limit) or (step < 0 and init <= limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[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:
for i = 10, 1, -3 never runs.

Numeric for-loop preparation (Lua-style FORPREP/FORLOOP). A zero step is an error. With integer init and step, a float limit is floored for positive steps and ceiled for negative ones; the loop is skipped when init is already past the limit in the step direction; otherwise the iteration count (limit - init) // step is precomputed (for negative steps (init - limit) // -step) and the loop runs count + 1 times. Otherwise the loop uses floats and re-tests v <= limit (v >= limit for negative steps). Return at most the first 20 control values.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // step
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[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
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else -((init - limit) // step)
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[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:
Descending loops run zero times or stop early.

Numeric for-loop preparation (Lua-style FORPREP/FORLOOP). A zero step is an error. With integer init and step, a float limit is floored for positive steps and ceiled for negative ones; the loop is skipped when init is already past the limit in the step direction; otherwise the iteration count (limit - init) // step is precomputed (for negative steps (init - limit) // -step) and the loop runs count + 1 times. Otherwise the loop uses floats and re-tests v <= limit (v >= limit for negative steps). Return at most the first 20 control values.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count, 19)):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count + 1, 19)):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v >= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[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:
for i = 1, 4 yields 1, 2, 3.

Numeric for-loop preparation (Lua-style FORPREP/FORLOOP). A zero step is an error. With integer init and step, a float limit is floored for positive steps and ceiled for negative ones; the loop is skipped when init is already past the limit in the step direction; otherwise the iteration count (limit - init) // step is precomputed (for negative steps (init - limit) // -step) and the loop runs count + 1 times. Otherwise the loop uses floats and re-tests v <= limit (v >= limit for negative steps). Return at most the first 20 control values.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(init, limit, step):
    if step == 0:
        return 'error: for step is zero'
    if isinstance(init, int) and isinstance(step, int):
        if isinstance(limit, float):
            limit = math.floor(limit) if step > 0 else math.ceil(limit)
        if (step > 0 and init > limit) or (step < 0 and init < limit):
            return []
        count = (limit - init) // step if step > 0 else (init - limit) // (-step)
        out = []
        v = init
        for _ in range(min(count, 19) + 1):
            out.append(v)
            v += step
        return out
    out = []
    v = float(init)
    while (v <= limit if step > 0 else v > limit) and len(out) < 20:
        out.append(v)
        v += step
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: ascending integer loop', (1, 4, 1), [1, 2, 3, 4]),
  ('descending loop with remainder', (11, 1, -3), [11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -3.5, 1), [-5, -4]),
  ('float limit ceils for descending loops', (6, 2.5, -1), [6, 5, 4, 3]),
  ('init equal to limit runs once', (1, 1, 1), [1]),
  ('descending init equal to limit runs once', (1, 1, -1), [1]),
  ('long loop is capped at 20 values',
   (0, 101, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 6, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 5, 1), [1, 2, 3, 4, 5]),
  ('descending loop with remainder', (12, 1, -3), [12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -4.5, 1), [-5]),
  ('float limit ceils for descending loops', (7, 2.5, -1), [7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (2, 2, 1), [2]),
  ('descending init equal to limit runs once', (2, 2, -1), [2]),
  ('long loop is capped at 20 values',
   (0, 102, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 7, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 6, 1), [1, 2, 3, 4, 5, 6]),
  ('descending loop with remainder', (13, 1, -3), [13, 10, 7, 4, 1]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -5.5, 1), []),
  ('float limit ceils for descending loops', (8, 2.5, -1), [8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (3, 3, 1), [3]),
  ('descending init equal to limit runs once', (3, 3, -1), [3]),
  ('long loop is capped at 20 values',
   (0, 103, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 8, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 7, 1), [1, 2, 3, 4, 5, 6, 7]),
  ('descending loop with remainder', (14, 1, -3), [14, 11, 8, 5, 2]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -6.5, 1), []),
  ('float limit ceils for descending loops', (9, 2.5, -1), [9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (4, 4, 1), [4]),
  ('descending init equal to limit runs once', (4, 4, -1), [4]),
  ('long loop is capped at 20 values',
   (0, 104, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 9, 0), 'error: for step is zero')],
 [('regression: ascending integer loop', (1, 8, 1), [1, 2, 3, 4, 5, 6, 7, 8]),
  ('descending loop with remainder', (15, 1, -3), [15, 12, 9, 6, 3]),
  ('descending loop with odd step', (7, 0, -2), [7, 5, 3, 1]),
  ('float limit floors for ascending loops', (-5, -7.5, 1), []),
  ('float limit ceils for descending loops', (10, 2.5, -1), [10, 9, 8, 7, 6, 5, 4, 3]),
  ('init equal to limit runs once', (5, 5, 1), [5]),
  ('descending init equal to limit runs once', (5, 5, -1), [5]),
  ('long loop is capped at 20 values',
   (0, 105, 1),
   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),
  ('float loop reaches its limit exactly', (1.0, 0.0, -0.25), [1.0, 0.75, 0.5, 0.25, 0.0]),
  ('control: zero step', (1, 10, 0), 'error: for step is zero')]]
for label, args, expected in cases[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:
Descending float loops execute zero iterations.

Numeric for-loop preparation (Lua-style FORPREP/FORLOOP). A zero step is an error. With integer init and step, a float limit is floored for positive steps and ceiled for negative ones; the loop is skipped when init is already past the limit in the step direction; otherwise the iteration count (limit - init) // step is precomputed (for negative steps (init - limit) // -step) and the loop runs count + 1 times. Otherwise the loop uses floats and re-tests v <= limit (v >= limit for negative steps). Return at most the first 20 control values.

split: open-access


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

N = 1
observations = []
def solve(code, addr, key):
    def s32(p):
        v = (code[p] << 24) | (code[p + 1] << 16) | (code[p + 2] << 8) | code[p + 3]
        return v - (1 << 32) if v & 0x80000000 else v
    def dispatch():
        op = code[addr]
        p = addr + 1
        p += 4 - p % 4
        default = s32(p)
        if op == 0xAA:
            low, high = s32(p + 4), s32(p + 8)
            if low > high:
                return ['VerifyError', 'low>high']
            if low <= key <= high:
                return addr + s32(p + 12 + 4 * (key - low))
            return addr + default
        if op == 0xAB:
            npairs = s32(p + 4)
            if npairs < 0:
                return ['VerifyError', 'npairs']
            pairs = [(s32(p + 8 + 8 * i), s32(p + 12 + 8 * i)) for i in range(npairs)]
            if any(pairs[i][0] >= pairs[i + 1][0] for i in range(npairs - 1)):
                return ['VerifyError', 'unsorted']
            lo, hi = 0, npairs - 1
            while lo <= hi:
                mid = (lo + hi) // 2
                if pairs[mid][0] == key:
                    return addr + pairs[mid][1]
                if pairs[mid][0] < key:
                    lo = mid + 1
                else:
                    hi = mid - 1
            return addr + default
        return ['VerifyError', 'opcode']
    try:
        return dispatch()
    except IndexError:
        return ['VerifyError', 'truncated']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    7,
    0),
   47),
  ('tableswitch hit at the high bound',
   ([0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    1,
    1),
   51),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    -2),
   22),
  ('tableswitch miss takes the backward default',
   ([0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    1,
    5),
   -7),
  ('lookupswitch hit with negative offset',
   ([0,
     171,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    1,
    100),
   -3),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    7,
    3),
   19),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 171, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 1, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 170, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 1, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    11,
    0),
   51),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    1),
   52),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    -2),
   23),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    5),
   -6),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     171,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    2,
    100),
   -2),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    11,
    3),
   23),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 171, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 2, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 170, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 2, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    15,
    0),
   55),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    1),
   53),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    -2),
   24),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    5),
   -5),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    3,
    100),
   -1),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    15,
    3),
   27),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 171, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 3, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 170, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 3, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    19,
    0),
   59),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    1),
   54),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    -2),
   25),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    5),
   -4),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     36,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    4,
    100),
   0),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     36,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    19,
    3),
   31),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 0, 171, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177],
    4,
    1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 4, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    23,
    0),
   63),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    1),
   55),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    6,
    -2),
   26),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    5),
   -3),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     37,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    5,
    100),
   1),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     37,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    23,
    3),
   35),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 0, 0, 171, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177],
    5,
    1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 5, 3),
   ['VerifyError', 'low>high'])]]
for label, args, expected in cases[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(code, addr, key):
    def s32(p):
        v = (code[p] << 24) | (code[p + 1] << 16) | (code[p + 2] << 8) | code[p + 3]
        return v - (1 << 32) if v & 0x80000000 else v
    def dispatch():
        op = code[addr]
        p = addr + 1
        p += (4 - addr % 4) % 4
        default = s32(p)
        if op == 0xAA:
            low, high = s32(p + 4), s32(p + 8)
            if low > high:
                return ['VerifyError', 'low>high']
            if low <= key <= high:
                return addr + s32(p + 12 + 4 * (key - low))
            return addr + default
        if op == 0xAB:
            npairs = s32(p + 4)
            if npairs < 0:
                return ['VerifyError', 'npairs']
            pairs = [(s32(p + 8 + 8 * i), s32(p + 12 + 8 * i)) for i in range(npairs)]
            if any(pairs[i][0] >= pairs[i + 1][0] for i in range(npairs - 1)):
                return ['VerifyError', 'unsorted']
            lo, hi = 0, npairs - 1
            while lo <= hi:
                mid = (lo + hi) // 2
                if pairs[mid][0] == key:
                    return addr + pairs[mid][1]
                if pairs[mid][0] < key:
                    lo = mid + 1
                else:
                    hi = mid - 1
            return addr + default
        return ['VerifyError', 'opcode']
    try:
        return dispatch()
    except IndexError:
        return ['VerifyError', 'truncated']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    7,
    0),
   47),
  ('tableswitch hit at the high bound',
   ([0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    1,
    1),
   51),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    -2),
   22),
  ('tableswitch miss takes the backward default',
   ([0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     31,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    1,
    5),
   -7),
  ('lookupswitch hit with negative offset',
   ([0,
     171,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    1,
    100),
   -3),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    7,
    3),
   19),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 171, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 1, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 170, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 1, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    11,
    0),
   51),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    1),
   52),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    -2),
   23),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     32,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    2,
    5),
   -6),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     171,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    2,
    100),
   -2),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    11,
    3),
   23),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 171, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 2, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 170, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 2, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    15,
    0),
   55),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    1),
   53),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    -2),
   24),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     33,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    3,
    5),
   -5),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    3,
    100),
   -1),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    15,
    3),
   27),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 171, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177], 3, 1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 170, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 3, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    19,
    0),
   59),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    1),
   54),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    -2),
   25),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     0,
     170,
     0,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     34,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    4,
    5),
   -4),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     36,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    4,
    100),
   0),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     36,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    19,
    3),
   31),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 0, 171, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177],
    4,
    1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 4, 3),
   ['VerifyError', 'low>high'])],
 [('regression: tableswitch hit with aligned operands',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     170,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    23,
    0),
   63),
  ('tableswitch hit at the high bound',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    1),
   55),
  ('tableswitch hit at the low bound',
   ([0,
     0,
     0,
     0,
     0,
     0,
     170,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    6,
    -2),
   26),
  ('tableswitch miss takes the backward default',
   ([0,
     0,
     0,
     0,
     0,
     170,
     0,
     0,
     255,
     255,
     255,
     248,
     255,
     255,
     255,
     254,
     0,
     0,
     0,
     1,
     0,
     0,
     0,
     20,
     0,
     0,
     0,
     35,
     0,
     0,
     0,
     40,
     0,
     0,
     0,
     50,
     177],
    5,
    5),
   -3),
  ('lookupswitch hit with negative offset',
   ([0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     37,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    5,
    100),
   1),
  ('lookupswitch miss',
   ([0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     171,
     0,
     0,
     0,
     12,
     0,
     0,
     0,
     4,
     255,
     255,
     255,
     251,
     0,
     0,
     0,
     16,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     24,
     0,
     0,
     0,
     7,
     0,
     0,
     0,
     37,
     0,
     0,
     0,
     100,
     255,
     255,
     255,
     252,
     177],
    23,
    3),
   35),
  ('lookupswitch with duplicate keys is rejected',
   ([0, 0, 0, 0, 0, 171, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 12, 177],
    5,
    1),
   ['VerifyError', 'unsorted']),
  ('control: low greater than high',
   ([0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 2, 177], 5, 3),
   ['VerifyError', 'low>high'])]]
for label, args, expected in cases[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:
Switches whose operands already start on a 4-byte boundary read every word four bytes late.

code is a method's bytes; at addr is tableswitch (0xAA) or lookupswitch (0xAB). After the opcode, 0-3 padding bytes align the next byte to a multiple of 4 from the method start; then big-endian signed 32-bit words: default, and either low, high and high-low+1 offsets, or npairs followed by sorted (match, offset) pairs. Branch offsets are relative to the switch opcode address. Return the target address, or ["VerifyError", reason] for low > high, negative npairs, keys not strictly increasing, another opcode, or truncated operands.

split: open-access