broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(mhws-tide)
    geo=2.08*math.sqrt(he+hle)
    vis=min(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous'])], [('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic'])], [('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(mhws-tide)
    geo=2.08*math.sqrt(he)+math.sqrt(hle)
    vis=min(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous'])], [('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic'])], [('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])]]
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:
Lights are raised far too late.

Input [he, hl, nominal, mhws, tide]: observer height of eye (m), light elevation charted above MHWS (m), nominal range (nm), MHWS and current tide above datum. Effective light height = hl+(mhws-tide). Geographic range = 2.08*(sqrt(he)+sqrt(effective)). Visible range = min(geographic, nominal); the limit is "geographic" when geographic<nominal else "luminous". Return [geo rounded 1, visible rounded 1, limit].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(mhws-tide)
    geo=2.08*(math.sqrt(he)+math.sqrt(hle))
    vis=max(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic'])], [('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous'])], [('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(mhws-tide)
    geo=2.08*(math.sqrt(he)+math.sqrt(hle))
    vis=nom
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic'])], [('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous'])], [('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous'])]]
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 weak light is promised beyond its luminous range.

Input [he, hl, nominal, mhws, tide]: observer height of eye (m), light elevation charted above MHWS (m), nominal range (nm), MHWS and current tide above datum. Effective light height = hl+(mhws-tide). Geographic range = 2.08*(sqrt(he)+sqrt(effective)). Visible range = min(geographic, nominal); the limit is "geographic" when geographic<nominal else "luminous". Return [geo rounded 1, visible rounded 1, limit].

split: open-access


prompt:
The limiting factor flips when the two ranges coincide.

Input [he, hl, nominal, mhws, tide]: observer height of eye (m), light elevation charted above MHWS (m), nominal range (nm), MHWS and current tide above datum. Effective light height = hl+(mhws-tide). Geographic range = 2.08*(sqrt(he)+sqrt(effective)). Visible range = min(geographic, nominal); the limit is "geographic" when geographic<nominal else "luminous". Return [geo rounded 1, visible rounded 1, limit].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(mhws-tide)
    geo=1.17*(math.sqrt(he)+math.sqrt(hle))
    vis=min(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous'])], [('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic'])], [('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])]]
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:
Every light is sighted too early relative to a metric table.

Input [he, hl, nominal, mhws, tide]: observer height of eye (m), light elevation charted above MHWS (m), nominal range (nm), MHWS and current tide above datum. Effective light height = hl+(mhws-tide). Geographic range = 2.08*(sqrt(he)+sqrt(effective)). Visible range = min(geographic, nominal); the limit is "geographic" when geographic<nominal else "luminous". Return [geo rounded 1, visible rounded 1, limit].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl
    geo=2.08*(math.sqrt(he)+math.sqrt(hle))
    vis=min(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic'])], [('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic'])], [('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    he,hl,nom,mhws,tide=x
    hle=hl+(tide-mhws)
    geo=2.08*(math.sqrt(he)+math.sqrt(hle))
    vis=min(geo,nom)
    lim='geographic' if geo<nom else 'luminous'
    return [round(geo,1),round(vis,1),lim]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous'])], [('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous'])], [('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [5, 5, 6, 3.0, 1.0]', [5, 5, 6, 3.0, 1.0], [10.2, 6, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic'])], [('light geographic and visible range [2, 40, 15, 4.0, 6.0]', [2, 40, 15, 4.0, 6.0], [15.8, 15, 'luminous']), ('light geographic and visible range [25, 100, 28, 4.0, 4.0]', [25, 100, 28, 4.0, 4.0], [31.2, 28, 'luminous']), ('light geographic and visible range [4, 16, 12.48, 3.0, 3.0]', [4, 16, 12.48, 3.0, 3.0], [12.5, 12.5, 'luminous']), ('light geographic and visible range [4, 9.174, 10.48, 2.0, 2.0]', [4, 9.174, 10.48, 2.0, 2.0], [10.5, 10.5, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic'])], [('light geographic and visible range [12, 80, 30, 5.0, 2.0]', [12, 80, 30, 5.0, 2.0], [26.2, 26.2, 'geographic']), ('light geographic and visible range [3, 25, 18, 4.5, 1.0]', [3, 25, 18, 4.5, 1.0], [14.7, 14.7, 'geographic']), ('light geographic and visible range [3, 25, 10, 4.5, 1.0]', [3, 25, 10, 4.5, 1.0], [14.7, 10, 'luminous']), ('light geographic and visible range [9, 64, 23, 5.0, 5.0]', [9, 64, 23, 5.0, 5.0], [22.9, 22.9, 'geographic']), ('light geographic and visible range [1.5, 12, 20, 4.0, 0.5]', [1.5, 12, 20, 4.0, 0.5], [10.7, 10.7, 'geographic']), ('light geographic and visible range [16, 36, 20.8, 3.0, 3.0]', [16, 36, 20.8, 3.0, 3.0], [20.8, 20.8, 'luminous']), ('light geographic and visible range [4, 9, 10.4, 2.0, 2.0]', [4, 9, 10.4, 2.0, 2.0], [10.4, 10.4, 'luminous'])]]
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:
At low water lights are sighted later than predicted.

Input [he, hl, nominal, mhws, tide]: observer height of eye (m), light elevation charted above MHWS (m), nominal range (nm), MHWS and current tide above datum. Effective light height = hl+(mhws-tide). Geographic range = 2.08*(sqrt(he)+sqrt(effective)). Visible range = min(geographic, nominal); the limit is "geographic" when geographic<nominal else "luminous". Return [geo rounded 1, visible rounded 1, limit].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else None
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None])], [('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [0]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None])], [('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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:
Plain "Fl" lights are reported with a null group.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[sum(int(p) for p in m.group(3).split('+'))] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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:
Composite group flashing lights cannot be parsed.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4)
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None])], [('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5])], [('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or None
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None])], [('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5])], [('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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:
White lights are reported with no colour.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(round(float(m.group(5)))) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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:
Quick lights with 1.2 s or 2.5 s periods fail to parse.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x)
    if not m: return None
    cls=m.group(1).rstrip('.')+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15])], [('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None])], [('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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:
Alternating lights are indistinguishable from fixed-colour ones.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x,re.I)
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    m=re.match(r"^(Al\.|)(LFl|Fl|VQ|Q|Iso|Oc|F)(?:\(([0-9+]+)\))?\.?([WRGY]*)\.?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)m)?(?:(\d+)M)?$",x.lower())
    if not m: return None
    cls=m.group(1)+m.group(2)
    grp=[int(p) for p in m.group(3).split('+')] if m.group(3) else [1]
    col=m.group(4) or 'W'
    per=float(m.group(5)) if m.group(5) else None
    return [cls,grp,col,per,int(m.group(6)) if m.group(6) else None,int(m.group(7)) if m.group(7) else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "LFl.10s"', 'LFl.10s', ['LFl', [1], 'W', 10.0, None, None]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "Oc(2)R.8s12m9M"', 'Oc(2)R.8s12m9M', ['Oc', [2], 'R', 8.0, 12, 9]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Q"', 'Q', ['Q', [1], 'W', None, None, None]), ('light characteristic abbreviation "Al.Fl.WR.5s"', 'Al.Fl.WR.5s', ['Al.Fl', [1], 'WR', 5.0, None, None]), ('light characteristic abbreviation "Fl(2+1)G.15s"', 'Fl(2+1)G.15s', ['Fl', [2, 1], 'G', 15.0, None, None]), ('light characteristic abbreviation "Q(9)15s"', 'Q(9)15s', ['Q', [9], 'W', 15.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "VQ(6)10s"', 'VQ(6)10s', ['VQ', [6], 'W', 10.0, None, None]), ('light characteristic abbreviation "F.R"', 'F.R', ['F', [1], 'R', None, None, None]), ('light characteristic abbreviation "Fl.2.5s"', 'Fl.2.5s', ['Fl', [1], 'W', 2.5, None, None]), ('light characteristic abbreviation "Fl(4)Y.20s8m5M"', 'Fl(4)Y.20s8m5M', ['Fl', [4], 'Y', 20.0, 8, 5]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None])], [('light characteristic abbreviation "Fl.10s20M"', 'Fl.10s20M', ['Fl', [1], 'W', 10.0, None, 20]), ('light characteristic abbreviation "Iso.WRG.4s"', 'Iso.WRG.4s', ['Iso', [1], 'WRG', 4.0, None, None]), ('light characteristic abbreviation "LFl.G.12s24m15M"', 'LFl.G.12s24m15M', ['LFl', [1], 'G', 12.0, 24, 15]), ('light characteristic abbreviation "Al.Oc.WG.6s"', 'Al.Oc.WG.6s', ['Al.Oc', [1], 'WG', 6.0, None, None]), ('light characteristic abbreviation "Q.1.2s"', 'Q.1.2s', ['Q', [1], 'W', 1.2, None, None]), ('light characteristic abbreviation "Mo(A)10s"', 'Mo(A)10s', None), ('light characteristic abbreviation "Fl(3)WR.10s15m20M"', 'Fl(3)WR.10s15m20M', ['Fl', [3], 'WR', 10.0, 15, 20])]]
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 range such as 20M is read as a 20 m elevation when no height is given.

Input a chart light abbreviation such as "Fl(3)WR.10s15m20M". Return [class, groups, colours, period_s, height_m, range_nm]: class includes an "Al." prefix; groups is a list (composite "2+1" -> [2,1], default [1]); colours default "W"; missing numbers are None. Unparseable strings return None.

split: open-access


prompt:
Conversions in westerly variation go the wrong way.

Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].

split: open-access


prompt:
Magnetic courses include variation that belongs only to true.

Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].

split: open-access


prompt:
Compass courses derived from true are off by twice the error.

Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].

split: open-access


prompt:
Cancelling deviation and variation shows as 0.0W.

Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].

split: open-access


prompt:
The published compass error ignores the ship deviation.

Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].

split: open-access


prompt:
Headings between the last card heading and 360 return nothing.

Input [heading, card]: card lists [compass heading, deviation] pairs (east positive) in any order. Headings wrap modulo 360; deviation is linearly interpolated between neighbouring card headings, including across the 360/0 seam. Return deviation rounded to 2 decimals.

split: open-access


prompt:
A card starting at 015 returns nothing for headings 000-014.

Input [heading, card]: card lists [compass heading, deviation] pairs (east positive) in any order. Headings wrap modulo 360; deviation is linearly interpolated between neighbouring card headings, including across the 360/0 seam. Return deviation rounded to 2 decimals.

split: open-access


prompt:
Cards written clockwise from another heading give wrong deviations.

Input [heading, card]: card lists [compass heading, deviation] pairs (east positive) in any order. Headings wrap modulo 360; deviation is linearly interpolated between neighbouring card headings, including across the 360/0 seam. Return deviation rounded to 2 decimals.

split: open-access


prompt:
Irregular cards give deviations outside the neighbouring values.

Input [heading, card]: card lists [compass heading, deviation] pairs (east positive) in any order. Headings wrap modulo 360; deviation is linearly interpolated between neighbouring card headings, including across the 360/0 seam. Return deviation rounded to 2 decimals.

split: open-access


prompt:
At high water the anchor has too little scope and drags.

Input [depth, tmax, tmin, bow, scope, boat_len]: charted depth and tide heights above datum (m). Rode = scope*(depth+tmax+bow) rounded up to the next 5 m chain mark. Swing radius = sqrt(rode^2 - (depth+tmin+bow)^2) + boat_len (largest at the lowest tide), rounded to 0.1 m. Return [rode, radius].

split: open-access


prompt:
Scope ratios are computed on water depth only.

Input [depth, tmax, tmin, bow, scope, boat_len]: charted depth and tide heights above datum (m). Rode = scope*(depth+tmax+bow) rounded up to the next 5 m chain mark. Swing radius = sqrt(rode^2 - (depth+tmin+bow)^2) + boat_len (largest at the lowest tide), rounded to 0.1 m. Return [rode, radius].

split: open-access


prompt:
Rode can be shorter than the required scope.

Input [depth, tmax, tmin, bow, scope, boat_len]: charted depth and tide heights above datum (m). Rode = scope*(depth+tmax+bow) rounded up to the next 5 m chain mark. Swing radius = sqrt(rode^2 - (depth+tmin+bow)^2) + boat_len (largest at the lowest tide), rounded to 0.1 m. Return [rode, radius].

split: open-access


prompt:
The swing circle is underestimated and the boat can touch neighbours at low water.

Input [depth, tmax, tmin, bow, scope, boat_len]: charted depth and tide heights above datum (m). Rode = scope*(depth+tmax+bow) rounded up to the next 5 m chain mark. Swing radius = sqrt(rode^2 - (depth+tmin+bow)^2) + boat_len (largest at the lowest tide), rounded to 0.1 m. Return [rode, radius].

split: open-access


prompt:
The stern swings outside the planned circle.

Input [depth, tmax, tmin, bow, scope, boat_len]: charted depth and tide heights above datum (m). Rode = scope*(depth+tmax+bow) rounded up to the next 5 m chain mark. Swing radius = sqrt(rode^2 - (depth+tmin+bow)^2) + boat_len (largest at the lowest tide), rounded to 0.1 m. Return [rode, radius].

split: open-access


prompt:
The iteration walks away from the root and returns a huge anomaly.

Input [M, e] (radians). Return None unless 0<=e<1. Reduce M into [0,2pi), start Newton at M (e<0.8) or pi, iterate E -= (E-e sinE-M)/(1-e cosE) up to 50 times until the step is below 1e-13, and return E rounded to 9 decimals.

split: open-access


prompt:
Multi-revolution or negative mean anomalies return eccentric anomalies outside [0,2pi).

Input [M, e] (radians). Return None unless 0<=e<1. Reduce M into [0,2pi), start Newton at M (e<0.8) or pi, iterate E -= (E-e sinE-M)/(1-e cosE) up to 50 times until the step is below 1e-13, and return E rounded to 9 decimals.

split: open-access


prompt:
Eccentric anomalies are only good to about three decimals.

Input [M, e] (radians). Return None unless 0<=e<1. Reduce M into [0,2pi), start Newton at M (e<0.8) or pi, iterate E -= (E-e sinE-M)/(1-e cosE) up to 50 times until the step is below 1e-13, and return E rounded to 9 decimals.

split: open-access


prompt:
Highly eccentric orbits return unconverged anomalies.

Input [M, e] (radians). Return None unless 0<=e<1. Reduce M into [0,2pi), start Newton at M (e<0.8) or pi, iterate E -= (E-e sinE-M)/(1-e cosE) up to 50 times until the step is below 1e-13, and return E rounded to 9 decimals.

split: open-access


prompt:
e=1 returns a meaningless eccentric anomaly.

Input [M, e] (radians). Return None unless 0<=e<1. Reduce M into [0,2pi), start Newton at M (e<0.8) or pi, iterate E -= (E-e sinE-M)/(1-e cosE) up to 50 times until the step is below 1e-13, and return E rounded to 9 decimals.

split: open-access


prompt:
After apoapsis the true anomaly folds back instead of continuing past pi.

Input [E, e] (radians, 0<=e<1, E any real). Return [nu, r/a] with nu = 2*atan2(sqrt(1+e) sin(E/2), sqrt(1-e) cos(E/2)) reduced to [0,2pi) and r/a = 1-e cos E, both rounded to 9 decimals.

split: open-access


prompt:
The spacecraft appears to linger near periapsis instead of apoapsis.

Input [E, e] (radians, 0<=e<1, E any real). Return [nu, r/a] with nu = 2*atan2(sqrt(1+e) sin(E/2), sqrt(1-e) cos(E/2)) reduced to [0,2pi) and r/a = 1-e cos E, both rounded to 9 decimals.

split: open-access