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

N = 1
observations = []
def solve(x):
    r = x['rated_kg']
    w = x['load_kg']
    if w * 100 > r * 110:
        return {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}
    full = w * 100 >= r * 80
    nuisance = w * 100 <= r * 10 and len(x['car_calls']) > 3
    return {'mode': 'bypass' if full else 'normal', 'depart': True, 'serve_hall': not full, 'cancel_car_calls': nuisance}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 1', {'rated_kg': 1000, 'load_kg': 800, 'car_calls': [0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 4', {'rated_kg': 1000, 'load_kg': 0, 'car_calls': [1, 6]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 7', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': [7, 6, 9, 4]}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just under 80 percent', {'rated_kg': 630, 'load_kg': 503, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: empty car with four calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 15', {'rated_kg': 630, 'load_kg': 693, 'car_calls': [7, 4, 0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 18', {'rated_kg': 450, 'load_kg': 45, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 21', {'rated_kg': 1000, 'load_kg': 30, 'car_calls': [8, 7, 1, 0, 2, 9]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: empty car with four calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: empty car with three calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: light passenger with many calls', {'rated_kg': 1275, 'load_kg': 70, 'car_calls': [0, 1, 2, 3, 4, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 23', {'rated_kg': 675, 'load_kg': 539, 'car_calls': [0, 7, 5, 9, 8, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 26', {'rated_kg': 675, 'load_kg': 540, 'car_calls': [9, 6, 0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 29', {'rated_kg': 675, 'load_kg': 66, 'car_calls': [3, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: light passenger with many calls', {'rated_kg': 1275, 'load_kg': 70, 'car_calls': [0, 1, 2, 3, 4, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('control 34', {'rated_kg': 1275, 'load_kg': 126, 'car_calls': [7, 3, 1, 0, 2, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 37', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 40', {'rated_kg': 450, 'load_kg': 30, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 45', {'rated_kg': 630, 'load_kg': 464, 'car_calls': [8, 7, 5, 9, 2]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 48', {'rated_kg': 675, 'load_kg': 153, 'car_calls': [1, 7, 4, 5, 6, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 51', {'rated_kg': 450, 'load_kg': 330, 'car_calls': [6, 0, 7, 9]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})]]
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(x):
    r = x['rated_kg']
    w = x['load_kg']
    if w * 100 > r * 110:
        return {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}
    full = w * 100 >= r * 80
    nuisance = w < r // 10 and len(x['car_calls']) > 3
    return {'mode': 'bypass' if full else 'normal', 'depart': True, 'serve_hall': not full, 'cancel_car_calls': nuisance}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 1', {'rated_kg': 1000, 'load_kg': 800, 'car_calls': [0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 4', {'rated_kg': 1000, 'load_kg': 0, 'car_calls': [1, 6]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 7', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': [7, 6, 9, 4]}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just under 80 percent', {'rated_kg': 630, 'load_kg': 503, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: empty car with four calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 15', {'rated_kg': 630, 'load_kg': 693, 'car_calls': [7, 4, 0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 18', {'rated_kg': 450, 'load_kg': 45, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 21', {'rated_kg': 1000, 'load_kg': 30, 'car_calls': [8, 7, 1, 0, 2, 9]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: empty car with four calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: empty car with three calls', {'rated_kg': 675, 'load_kg': 0, 'car_calls': [0, 1, 2]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: light passenger with many calls', {'rated_kg': 1275, 'load_kg': 70, 'car_calls': [0, 1, 2, 3, 4, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 23', {'rated_kg': 675, 'load_kg': 539, 'car_calls': [0, 7, 5, 9, 8, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 26', {'rated_kg': 675, 'load_kg': 540, 'car_calls': [9, 6, 0]}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 29', {'rated_kg': 675, 'load_kg': 66, 'car_calls': [3, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: light passenger with many calls', {'rated_kg': 1275, 'load_kg': 70, 'car_calls': [0, 1, 2, 3, 4, 5]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('control 34', {'rated_kg': 1275, 'load_kg': 126, 'car_calls': [7, 3, 1, 0, 2, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('control 37', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 40', {'rated_kg': 450, 'load_kg': 30, 'car_calls': []}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})], [('sampled regression 12', {'rated_kg': 1000, 'load_kg': 100, 'car_calls': [6, 7, 4, 3, 9, 0]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('boundary: fractional ten percent threshold', {'rated_kg': 675, 'load_kg': 67, 'car_calls': [0, 1, 2, 3, 4]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': True}), ('boundary: exactly 110 percent', {'rated_kg': 1000, 'load_kg': 1100, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: just over 110 percent', {'rated_kg': 1000, 'load_kg': 1101, 'car_calls': []}, {'mode': 'overload', 'depart': False, 'serve_hall': False, 'cancel_car_calls': False}), ('boundary: exactly 80 percent', {'rated_kg': 630, 'load_kg': 504, 'car_calls': []}, {'mode': 'bypass', 'depart': True, 'serve_hall': False, 'cancel_car_calls': False}), ('control 45', {'rated_kg': 630, 'load_kg': 464, 'car_calls': [8, 7, 5, 9, 2]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 48', {'rated_kg': 675, 'load_kg': 153, 'car_calls': [1, 7, 4, 5, 6, 3]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False}), ('control 51', {'rated_kg': 450, 'load_kg': 330, 'car_calls': [6, 0, 7, 9]}, {'mode': 'normal', 'depart': True, 'serve_hall': True, 'cancel_car_calls': False})]]
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 anti-nuisance check fires at exactly ten percent load or misses a load just under a fractional threshold.

Overload (load above 110% of rating) keeps the car at the floor: no departure, no hall service, no cancellation. Otherwise the car departs; at 80% or more it runs in bypass (ignores hall calls). Anti-nuisance cancels all car calls when the load is below 10% of rating and more than three car calls are registered. Percentages are exact integer comparisons.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Trip distances include the rise above the destination floor.

heights_mm[i] is the rise from floor i to floor i+1. The trip distance is the sum between the two floors (either direction). With speed vmax (mm/s) and acceleration acc (mm/s^2): if distance*acc >= vmax^2 the car reaches vmax and t = d/vmax + vmax/acc, otherwise t = 2*sqrt(d/acc). Return milliseconds rounded up; zero distance is 0.

split: open-access


prompt:
Medium trips are timed as if the car reached contract speed.

heights_mm[i] is the rise from floor i to floor i+1. The trip distance is the sum between the two floors (either direction). With speed vmax (mm/s) and acceleration acc (mm/s^2): if distance*acc >= vmax^2 the car reaches vmax and t = d/vmax + vmax/acc, otherwise t = 2*sqrt(d/acc). Return milliseconds rounded up; zero distance is 0.

split: open-access


prompt:
Long trips are predicted too short.

heights_mm[i] is the rise from floor i to floor i+1. The trip distance is the sum between the two floors (either direction). With speed vmax (mm/s) and acceleration acc (mm/s^2): if distance*acc >= vmax^2 the car reaches vmax and t = d/vmax + vmax/acc, otherwise t = 2*sqrt(d/acc). Return milliseconds rounded up; zero distance is 0.

split: open-access


prompt:
Short hops are predicted faster or slower than the car can achieve.

heights_mm[i] is the rise from floor i to floor i+1. The trip distance is the sum between the two floors (either direction). With speed vmax (mm/s) and acceleration acc (mm/s^2): if distance*acc >= vmax^2 the car reaches vmax and t = d/vmax + vmax/acc, otherwise t = 2*sqrt(d/acc). Return milliseconds rounded up; zero distance is 0.

split: open-access


prompt:
Predicted trip times are a millisecond short.

heights_mm[i] is the rise from floor i to floor i+1. The trip distance is the sum between the two floors (either direction). With speed vmax (mm/s) and acceleration acc (mm/s^2): if distance*acc >= vmax^2 the car reaches vmax and t = d/vmax + vmax/acc, otherwise t = 2*sqrt(d/acc). Return milliseconds rounded up; zero distance is 0.

split: open-access


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

N = 1
observations = []
def solve(x):
    labels = ['B%d' % i for i in range(1, x['basements'] + 1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 9', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:0', 'index:B2', 'index:X', 'label:-1', 'index:14', 'index:1']}, ['B2', 0, None, None, None, 3]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 25', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 16, 'queries': ['label:14', 'index:17', 'label:9', 'index:B1', 'label:7', 'label:14']}, ['11', None, '6', 1, '4', '11']), ('sampled regression 9', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:0', 'index:B2', 'index:X', 'label:-1', 'index:14', 'index:1']}, ['B2', 0, None, None, None, 3]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('sampled regression 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('control 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 46', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 10, 'queries': ['label:8', 'index:B1', 'index:14', 'label:-1', 'label:2', 'label:4']}, ['6', 1, None, None, 'G', '2']), ('sampled regression 20', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 18, 'queries': ['label:0', 'label:1', 'index:13', 'label:14', 'index:M', 'label:12']}, ['B2', 'B1', 15, '12', None, '10']), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('sampled regression 30', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 19, 'queries': ['index:B1', 'label:0', 'label:3', 'label:19', 'index:1', 'index:12']}, [1, 'B2', 'M', None, 4, 15]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 14', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:7', 'index:M', 'index:b2', 'index:g', 'index:b2', 'label:9']}, ['5', None, 0, 2, 0, '7']), ('sampled regression 39', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 7, 'queries': ['label:7', 'label:1', 'index:17', 'index:17', 'label:5', 'label:6']}, [None, 'B1', None, None, '3', '4']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('control 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('sampled regression 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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(x):
    labels = ['B%d' % i for i in range(x['basements'] - 1, -1, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 9', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:0', 'index:B2', 'index:X', 'label:-1', 'index:14', 'index:1']}, ['B2', 0, None, None, None, 3]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 25', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 16, 'queries': ['label:14', 'index:17', 'label:9', 'index:B1', 'label:7', 'label:14']}, ['11', None, '6', 1, '4', '11']), ('sampled regression 9', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:0', 'index:B2', 'index:X', 'label:-1', 'index:14', 'index:1']}, ['B2', 0, None, None, None, 3]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('sampled regression 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('control 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 46', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 10, 'queries': ['label:8', 'index:B1', 'index:14', 'label:-1', 'label:2', 'label:4']}, ['6', 1, None, None, 'G', '2']), ('sampled regression 20', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 18, 'queries': ['label:0', 'label:1', 'index:13', 'label:14', 'index:M', 'label:12']}, ['B2', 'B1', 15, '12', None, '10']), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('sampled regression 30', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 19, 'queries': ['index:B1', 'label:0', 'label:3', 'label:19', 'index:1', 'index:12']}, [1, 'B2', 'M', None, 4, 15]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 14', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:7', 'index:M', 'index:b2', 'index:g', 'index:b2', 'label:9']}, ['5', None, 0, 2, 0, '7']), ('sampled regression 39', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 7, 'queries': ['label:7', 'label:1', 'index:17', 'index:17', 'label:5', 'label:6']}, [None, 'B1', None, None, '3', '4']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('control 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('sampled regression 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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 deepest basement is labelled B1.

Physical indices 0..floors-1 are labelled bottom-up: basements Bk..B1, then G, then M if there is a mezzanine, then 1, 2, 3 ... skipping 13 when skip13. label:i returns the label of index i (None outside the range); index:L returns the index of label L (case-insensitive) or None.

split: open-access


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

N = 1
observations = []
def solve(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num + (1 if x['mezz'] else 0) == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 64', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 20, 'queries': ['index:b2', 'label:18', 'index:G', 'index:15', 'label:15', 'label:18']}, [0, '16', 2, 17, '12', '16']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 72', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:12', 'index:13', 'label:-1', 'index:X', 'label:-1', 'label:-2']}, ['11', None, None, None, None, None]), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('control 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('sampled regression 64', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 20, 'queries': ['index:b2', 'label:18', 'index:G', 'index:15', 'label:15', 'label:18']}, [0, '16', 2, 17, '12', '16']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('control 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num % 13 == 0:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 64', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 20, 'queries': ['index:b2', 'label:18', 'index:G', 'index:15', 'label:15', 'label:18']}, [0, '16', 2, 17, '12', '16']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 72', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:12', 'index:13', 'label:-1', 'index:X', 'label:-1', 'label:-2']}, ['11', None, None, None, None, None]), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('control 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('sampled regression 64', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 20, 'queries': ['index:b2', 'label:18', 'index:G', 'index:15', 'label:15', 'label:18']}, [0, '16', 2, 17, '12', '16']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('sampled regression 71', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['label:4', 'label:0', 'index:13', 'label:4', 'label:14', 'label:4']}, ['1', 'B2', None, '1', '11', '1']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('control 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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:
Floor 12 disappears instead of 13 in buildings with a mezzanine.

Physical indices 0..floors-1 are labelled bottom-up: basements Bk..B1, then G, then M if there is a mezzanine, then 1, 2, 3 ... skipping 13 when skip13. label:i returns the label of index i (None outside the range); index:L returns the index of label L (case-insensitive) or None.

split: open-access


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

N = 1
observations = []
def solve(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 5', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:M', 'label:0', 'index:B1', 'index:B1', 'label:-2', 'index:g']}, [3, 'B2', 1, 1, None, 2]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('sampled regression 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('sampled regression 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 28', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 12, 'queries': ['label:1', 'label:13', 'index:m', 'index:b2', 'label:-2', 'label:10']}, ['G', None, 2, None, None, '8']), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('control 21', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:11', 'index:b2', 'label:0', 'index:B2', 'label:6', 'index:1']}, [None, 0, 'B2', 0, '3', 4])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 46', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 10, 'queries': ['label:8', 'index:B1', 'index:14', 'label:-1', 'label:2', 'label:4']}, ['6', 1, None, None, 'G', '2']), ('sampled regression 33', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 12, 'queries': ['label:8', 'index:13', 'label:9', 'label:0', 'label:6', 'label:-1']}, ['6', None, '7', 'B2', '4', None]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('control 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('sampled regression 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 53', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'index:B2', 'label:7', 'label:-1', 'index:B2', 'label:1']}, [None, None, None, None, None, 'G']), ('sampled regression 66', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['index:15', 'label:3', 'label:6', 'label:0', 'label:-2', 'label:3']}, [None, '1', None, 'B2', None, '1']), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('sampled regression 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 74', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:14', 'index:g', 'index:G', 'index:20', 'index:X', 'label:-1']}, [None, 1, 1, None, None, None]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('sampled regression 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 < i < len(labels) else None)
        else:
            v = val.upper()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 5', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:M', 'label:0', 'index:B1', 'index:B1', 'label:-2', 'index:g']}, [3, 'B2', 1, 1, None, 2]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('sampled regression 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('sampled regression 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3'])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 28', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 12, 'queries': ['label:1', 'label:13', 'index:m', 'index:b2', 'label:-2', 'label:10']}, ['G', None, 2, None, None, '8']), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('sampled regression 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None]), ('control 21', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:11', 'index:b2', 'label:0', 'index:B2', 'label:6', 'index:1']}, [None, 0, 'B2', 0, '3', 4])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 46', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 10, 'queries': ['label:8', 'index:B1', 'index:14', 'label:-1', 'label:2', 'label:4']}, ['6', 1, None, None, 'G', '2']), ('sampled regression 33', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 12, 'queries': ['label:8', 'index:13', 'label:9', 'label:0', 'label:6', 'label:-1']}, ['6', None, '7', 'B2', '4', None]), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('control 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('sampled regression 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 53', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'index:B2', 'label:7', 'label:-1', 'index:B2', 'label:1']}, [None, None, None, None, None, 'G']), ('sampled regression 66', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['index:15', 'label:3', 'label:6', 'label:0', 'label:-2', 'label:3']}, [None, '1', None, 'B2', None, '1']), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('sampled regression 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('control 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('sampled regression 74', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:14', 'index:g', 'index:G', 'index:20', 'index:X', 'label:-1']}, [None, 1, 1, None, None, None]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('sampled regression 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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 negative index returns a label from the top of the building.

Physical indices 0..floors-1 are labelled bottom-up: basements Bk..B1, then G, then M if there is a mezzanine, then 1, 2, 3 ... skipping 13 when skip13. label:i returns the label of index i (None outside the range); index:L returns the index of label L (case-insensitive) or None.

split: open-access


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

N = 1
observations = []
def solve(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3']), ('control 10', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['index:14', 'index:1', 'index:14', 'index:14', 'label:17', 'index:1']}, [15, 3, 15, 15, None, 3])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('sampled regression 6', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 11, 'queries': ['index:13', 'label:0', 'index:g', 'index:13', 'label:11', 'index:17']}, [None, 'B1', 1, None, None, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('control 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('sampled regression 14', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:7', 'index:M', 'index:b2', 'index:g', 'index:b2', 'label:9']}, ['5', None, 0, 2, 0, '7']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 63', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:14', 'label:5', 'index:b2', 'index:B1', 'label:0', 'index:14']}, [None, '3', 0, 1, 'B2', None]), ('control 22', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 17, 'queries': ['label:18', 'index:m', 'label:0', 'index:G', 'label:6', 'index:X']}, [None, None, 'B1', 1, '5', None]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('sampled regression 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 79', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 11, 'queries': ['index:17', 'index:m', 'index:X', 'index:20', 'index:g', 'label:0']}, [None, None, None, None, 1, 'B1']), ('control 30', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 19, 'queries': ['index:B1', 'label:0', 'label:3', 'label:19', 'index:1', 'index:12']}, [1, 'B2', 'M', None, 4, 15]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('sampled regression 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('control 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
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(x):
    labels = ['B%d' % i for i in range(x['basements'], 0, -1)] + ['G']
    if x['mezz']:
        labels.append('M')
    num = 1
    while len(labels) < x['floors']:
        if x['skip13'] and num == 13:
            num += 1
            continue
        labels.append(str(num))
        num += 1
    out = []
    for q in x['queries']:
        kind, val = q.split(':')
        if kind == 'label':
            i = int(val)
            out.append(labels[i] if 0 <= i < len(labels) else None)
        else:
            v = val.lower()
            out.append(labels.index(v) if v in labels else None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 4', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 15, 'queries': ['index:B1', 'label:-1', 'index:g', 'label:13', 'index:13', 'index:14']}, [None, None, 0, '14', None, 13]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('control 1', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['label:2', 'index:B1', 'index:B1', 'label:9', 'index:15', 'label:9']}, ['1', None, None, None, None, None]), ('control 7', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 9, 'queries': ['index:G', 'index:B2', 'index:14', 'label:8', 'label:-1', 'label:5']}, [1, None, None, '6', None, '3']), ('control 10', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 16, 'queries': ['index:14', 'index:1', 'index:14', 'index:14', 'label:17', 'index:1']}, [15, 3, 15, 15, None, 3])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('sampled regression 6', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 11, 'queries': ['index:13', 'label:0', 'index:g', 'index:13', 'label:11', 'index:17']}, [None, 'B1', 1, None, None, None]), ('boundary: thirteen kept', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 16, 'queries': ['label:13', 'index:13']}, ['13', 13]), ('boundary: negative index', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:-1', 'label:0']}, [None, 'B1']), ('control 12', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:B2', 'index:20', 'index:12', 'index:13', 'index:12', 'label:-1']}, [None, None, None, None, None, None]), ('control 15', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:14', 'index:1', 'index:13', 'label:0', 'label:7', 'index:X']}, ['11', 4, None, 'B2', '4', None]), ('control 18', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B1', 'label:-1', 'index:12', 'index:15', 'label:16', 'index:20']}, [0, None, 14, 16, '15', None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 44', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 15, 'queries': ['label:-1', 'label:15', 'label:16', 'index:13', 'index:g', 'label:4']}, [None, None, None, None, 1, '2']), ('sampled regression 14', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:7', 'index:M', 'index:b2', 'index:g', 'index:b2', 'label:9']}, ['5', None, 0, 2, 0, '7']), ('boundary: twenty-six with skip', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 30, 'queries': ['label:26', 'label:27', 'index:26']}, ['27', '28', 25]), ('sampled regression 23', {'basements': 2, 'mezz': True, 'skip13': True, 'floors': 18, 'queries': ['index:B2', 'label:5', 'index:15', 'index:B1', 'index:b2', 'index:g']}, [0, '2', 17, 1, 0, 2]), ('control 26', {'basements': 1, 'mezz': True, 'skip13': True, 'floors': 8, 'queries': ['index:G', 'label:-1', 'label:6', 'label:3', 'index:G', 'label:-1']}, [1, None, '4', '1', 1, None]), ('control 29', {'basements': 1, 'mezz': False, 'skip13': False, 'floors': 14, 'queries': ['label:11', 'label:6', 'label:14', 'label:2', 'index:b2', 'index:M']}, ['10', '5', None, '1', None, None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('sampled regression 63', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:14', 'label:5', 'index:b2', 'index:B1', 'label:0', 'index:14']}, [None, '3', 0, 1, 'B2', None]), ('control 22', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 17, 'queries': ['label:18', 'index:m', 'label:0', 'index:G', 'label:6', 'index:X']}, [None, None, 'B1', 1, '5', None]), ('boundary: index past the top', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 6, 'queries': ['label:6', 'label:5']}, [None, '5']), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('control 34', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:B2', 'index:M', 'label:4', 'index:13', 'label:-2', 'label:5']}, [None, None, '4', None, None, '5']), ('control 37', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 19, 'queries': ['label:15', 'index:17', 'label:5', 'index:15', 'index:M', 'index:B1']}, ['15', 17, '4', 15, None, 0]), ('sampled regression 40', {'basements': 1, 'mezz': True, 'skip13': False, 'floors': 13, 'queries': ['index:B2', 'index:B2', 'index:g', 'index:17', 'index:17', 'label:13']}, [None, None, 1, None, None, None])], [('regression: ground floor index', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 10, 'queries': ['label:0', 'index:g', 'index:m']}, ['G', 0, 1]), ('boundary: two basements', {'basements': 2, 'mezz': False, 'skip13': True, 'floors': 8, 'queries': ['label:0', 'label:1', 'index:B1', 'index:B2']}, ['B2', 'B1', 1, 0]), ('sampled regression 79', {'basements': 1, 'mezz': False, 'skip13': True, 'floors': 11, 'queries': ['index:17', 'index:m', 'index:X', 'index:20', 'index:g', 'label:0']}, [None, None, None, None, 1, 'B1']), ('control 30', {'basements': 2, 'mezz': True, 'skip13': False, 'floors': 19, 'queries': ['index:B1', 'label:0', 'label:3', 'label:19', 'index:1', 'index:12']}, [1, 'B2', 'M', None, 4, 15]), ('boundary: thirteen skipped', {'basements': 0, 'mezz': False, 'skip13': True, 'floors': 16, 'queries': ['label:13', 'index:14', 'index:13']}, ['14', 13, None]), ('sampled regression 45', {'basements': 0, 'mezz': False, 'skip13': False, 'floors': 6, 'queries': ['index:m', 'index:15', 'label:4', 'index:g', 'index:17', 'label:7']}, [None, None, '4', 0, None, None]), ('sampled regression 48', {'basements': 0, 'mezz': True, 'skip13': True, 'floors': 17, 'queries': ['label:8', 'label:5', 'index:m', 'label:13', 'label:-1', 'label:16']}, ['7', '4', 1, '12', None, '16']), ('control 51', {'basements': 2, 'mezz': False, 'skip13': False, 'floors': 10, 'queries': ['label:6', 'label:-2', 'label:8', 'label:-2', 'label:7', 'index:B1']}, ['4', None, '6', None, '5', 1])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Lower-case labels such as g or b1 are not found.

Physical indices 0..floors-1 are labelled bottom-up: basements Bk..B1, then G, then M if there is a mezzanine, then 1, 2, 3 ... skipping 13 when skip13. label:i returns the label of index i (None outside the range); index:L returns the index of label L (case-insensitive) or None.

split: open-access