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

N = 1
observations = []
def solve(minor, ccy):
    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
    if ccy not in spec: return 'ERR:currency'
    pre, suf, grp, dec, e = spec[ccy]
    neg = minor < 0
    major, frac = divmod(abs(minor), 10 ** e)
    digits = str(major)
    groups = []
    while len(digits) > 3:
        groups.insert(0, digits[-3:])
        digits = digits[:-3]
    groups.insert(0, digits)
    body = grp.join(groups)
    body += dec + str(frac).zfill(e)
    return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression zero-exponent-separator 1', (1234567, 'JPY'), '¥1,234,567'),
  ('regression zero-exponent-separator 2', (0, 'JPY'), '¥0'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")],
 [('regression zero-exponent-separator 1', (-1000, 'JPY'), '-¥1,000'),
  ('regression zero-exponent-separator 2', (99999, 'JPY'), '¥99,999'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"), ('control: dinar', (1005, 'KWD'), 'KD 1.005'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency')],
 [('regression zero-exponent-separator 1', (5, 'JPY'), '¥5'),
  ('regression zero-exponent-separator 2', (100000, 'JPY'), '¥100,000'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
 [('regression zero-exponent-separator 1', (-999, 'JPY'), '-¥999'),
  ('regression zero-exponent-separator 2', (-105, 'JPY'), '-¥105'), ('control: small dollars', (105, 'USD'), '$1.05'),
  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50')],
 [('regression zero-exponent-separator 1', (123456, 'JPY'), '¥123,456'),
  ('regression zero-exponent-separator 2', (987654321, 'JPY'), '¥987,654,321'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(minor, ccy):
    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
    if ccy not in spec: return 'ERR:currency'
    pre, suf, grp, dec, e = spec[ccy]
    neg = minor < 0
    major, frac = divmod(abs(minor), 10 ** e)
    digits = str(major)
    groups = []
    while len(digits) > 3:
        groups.insert(0, digits[-3:])
        digits = digits[:-3]
    groups.insert(0, digits)
    body = grp.join(groups)
    body += (dec if e else '') + str(frac).zfill(e)
    return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression zero-exponent-separator 1', (1234567, 'JPY'), '¥1,234,567'),
  ('regression zero-exponent-separator 2', (0, 'JPY'), '¥0'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")],
 [('regression zero-exponent-separator 1', (-1000, 'JPY'), '-¥1,000'),
  ('regression zero-exponent-separator 2', (99999, 'JPY'), '¥99,999'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"), ('control: dinar', (1005, 'KWD'), 'KD 1.005'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency')],
 [('regression zero-exponent-separator 1', (5, 'JPY'), '¥5'),
  ('regression zero-exponent-separator 2', (100000, 'JPY'), '¥100,000'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
 [('regression zero-exponent-separator 1', (-999, 'JPY'), '-¥999'),
  ('regression zero-exponent-separator 2', (-105, 'JPY'), '-¥105'), ('control: small dollars', (105, 'USD'), '$1.05'),
  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50')],
 [('regression zero-exponent-separator 1', (123456, 'JPY'), '¥123,456'),
  ('regression zero-exponent-separator 2', (987654321, 'JPY'), '¥987,654,321'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Yen amounts render as '¥1,234,567.0'.

solve(minor, ccy): format integer minor units. Styles: USD '$' prefix, ',' groups, '.' decimal, 2 digits; EUR ' €' suffix, '.' groups, ',' decimal, 2; JPY '¥' prefix, ',' groups, 0 digits (no decimal separator); CHF 'CHF ' prefix, "'" groups, '.', 2; KWD 'KD ' prefix, ',', '.', 3. Group the whole part in threes from the right; the fraction is zero-padded to the exponent. A negative amount places '-' before everything. Unknown codes return 'ERR:currency'.

split: open-access


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

N = 1
observations = []
def solve(minor, ccy):
    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
    if ccy not in spec: return 'ERR:currency'
    pre, suf, grp, dec, e = spec[ccy]
    neg = minor < 0
    major, frac = divmod(abs(minor), 10 ** e)
    digits = str(major)
    groups = []
    while len(digits) > 3:
        groups.insert(0, digits[-3:])
        digits = digits[:-3]
    groups.insert(0, digits)
    body = grp.join(groups)
    if e: body += dec + str(frac)
    return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-zero-fill 1', (105, 'USD'), '$1.05'),
  ('regression fraction-zero-fill 2', (1005, 'KWD'), 'KD 1.005'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567')],
 [('regression fraction-zero-fill 1', (100000000, 'EUR'), '1.000.000,00 €'),
  ('regression fraction-zero-fill 2', (-1000000, 'EUR'), '-10.000,00 €'),
  ('partial repair guard 1', (-50, 'KWD'), '-KD 0.050'), ('partial repair guard 2', (5, 'CHF'), 'CHF 0.05'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"),
  ('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],
 [('regression fraction-zero-fill 1', (0, 'CHF'), 'CHF 0.00'),
  ('regression fraction-zero-fill 2', (-100000, 'USD'), '-$1,000.00'),
  ('partial repair guard 1', (105, 'EUR'), '1,05 €'), ('partial repair guard 2', (5, 'EUR'), '0,05 €'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
 [('regression fraction-zero-fill 1', (-50, 'KWD'), '-KD 0.050'),
  ('regression fraction-zero-fill 2', (5, 'CHF'), 'CHF 0.05'), ('partial repair guard 1', (-105, 'EUR'), '-1,05 €'),
  ('partial repair guard 2', (-5, 'CHF'), '-CHF 0.05'), ('control: small dollars', (105, 'USD'), '$1.05'),
  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50')],
 [('regression fraction-zero-fill 1', (1000, 'USD'), '$10.00'),
  ('regression fraction-zero-fill 2', (105, 'EUR'), '1,05 €'), ('partial repair guard 1', (-5, 'USD'), '-$0.05'),
  ('partial repair guard 2', (50, 'KWD'), 'KD 0.050'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),
  ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(minor, ccy):
    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
    if ccy not in spec: return 'ERR:currency'
    pre, suf, grp, dec, e = spec[ccy]
    neg = minor < 0
    major, frac = divmod(abs(minor), 10 ** e)
    digits = str(major)
    groups = []
    while len(digits) > 3:
        groups.insert(0, digits[-3:])
        digits = digits[:-3]
    groups.insert(0, digits)
    body = grp.join(groups)
    if e: body += dec + str(frac).ljust(e, '0')
    return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-zero-fill 1', (105, 'USD'), '$1.05'),
  ('regression fraction-zero-fill 2', (1005, 'KWD'), 'KD 1.005'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567')],
 [('regression fraction-zero-fill 1', (100000000, 'EUR'), '1.000.000,00 €'),
  ('regression fraction-zero-fill 2', (-1000000, 'EUR'), '-10.000,00 €'),
  ('partial repair guard 1', (-50, 'KWD'), '-KD 0.050'), ('partial repair guard 2', (5, 'CHF'), 'CHF 0.05'),
  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"),
  ('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],
 [('regression fraction-zero-fill 1', (0, 'CHF'), 'CHF 0.00'),
  ('regression fraction-zero-fill 2', (-100000, 'USD'), '-$1,000.00'),
  ('partial repair guard 1', (105, 'EUR'), '1,05 €'), ('partial repair guard 2', (5, 'EUR'), '0,05 €'),
  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
 [('regression fraction-zero-fill 1', (-50, 'KWD'), '-KD 0.050'),
  ('regression fraction-zero-fill 2', (5, 'CHF'), 'CHF 0.05'), ('partial repair guard 1', (-105, 'EUR'), '-1,05 €'),
  ('partial repair guard 2', (-5, 'CHF'), '-CHF 0.05'), ('control: small dollars', (105, 'USD'), '$1.05'),
  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
  ('control: negative dollars', (-150, 'USD'), '-$1.50')],
 [('regression fraction-zero-fill 1', (1000, 'USD'), '$10.00'),
  ('regression fraction-zero-fill 2', (105, 'EUR'), '1,05 €'), ('partial repair guard 1', (-5, 'USD'), '-$0.05'),
  ('partial repair guard 2', (50, 'KWD'), 'KD 0.050'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),
  ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
  ('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
105 cents renders as '$1.5'.

solve(minor, ccy): format integer minor units. Styles: USD '$' prefix, ',' groups, '.' decimal, 2 digits; EUR ' €' suffix, '.' groups, ',' decimal, 2; JPY '¥' prefix, ',' groups, 0 digits (no decimal separator); CHF 'CHF ' prefix, "'" groups, '.', 2; KWD 'KD ' prefix, ',', '.', 3. Group the whole part in threes from the right; the fraction is zero-padded to the exponent. A negative amount places '-' before everything. Unknown codes return 'ERR:currency'.

split: open-access


prompt:
EURUSD traded before a USD-only holiday settles a day late.

solve(trade, pair, holidays): stipulated spot value-date rule. USDCAD/CADUSD settle T+1, every other pair T+2. Count forward from the trade date: a day before the final one counts only if it is a weekday and not a holiday of the non-USD currencies of the pair; the value date itself must be a weekday that is a holiday in neither currency. holidays maps currency to ISO date strings. Return the ISO value date.

split: open-access


prompt:
EURUSD spot is set on a US holiday when dollars cannot settle.

solve(trade, pair, holidays): stipulated spot value-date rule. USDCAD/CADUSD settle T+1, every other pair T+2. Count forward from the trade date: a day before the final one counts only if it is a weekday and not a holiday of the non-USD currencies of the pair; the value date itself must be a weekday that is a holiday in neither currency. holidays maps currency to ISO date strings. Return the ISO value date.

split: open-access


prompt:
USDCAD trades settle a business day late.

solve(trade, pair, holidays): stipulated spot value-date rule. USDCAD/CADUSD settle T+1, every other pair T+2. Count forward from the trade date: a day before the final one counts only if it is a weekday and not a holiday of the non-USD currencies of the pair; the value date itself must be a weekday that is a holiday in neither currency. holidays maps currency to ISO date strings. Return the ISO value date.

split: open-access


prompt:
A Thursday trade settles on Monday only by accident; a Friday trade settles Monday instead of Tuesday.

solve(trade, pair, holidays): stipulated spot value-date rule. USDCAD/CADUSD settle T+1, every other pair T+2. Count forward from the trade date: a day before the final one counts only if it is a weekday and not a holiday of the non-USD currencies of the pair; the value date itself must be a weekday that is a holiday in neither currency. holidays maps currency to ISO date strings. Return the ISO value date.

split: open-access


prompt:
The receipt shows a rate that does not reproduce the charged card amount.

solve(amount, ref_rate, markup_bps, card_exp): amount in merchant currency, ref_rate cardholder units per merchant unit, markup_bps an integer (negative for a promotional discount). The offered rate is ref*(1+bps/10000) rounded half-up to 6 decimals, and the card amount is amount*offered rounded half-up at card_exp. The disclosed markup percentage is (offered/ref - 1)*100 computed from the rounded offered rate and rounded toward positive infinity to 2 decimals so it never understates. Return [offered, card_amount, markup_pct] as strings.

split: open-access


prompt:
A 3% markup is disclosed as 2.92%.

solve(amount, ref_rate, markup_bps, card_exp): amount in merchant currency, ref_rate cardholder units per merchant unit, markup_bps an integer (negative for a promotional discount). The offered rate is ref*(1+bps/10000) rounded half-up to 6 decimals, and the card amount is amount*offered rounded half-up at card_exp. The disclosed markup percentage is (offered/ref - 1)*100 computed from the rounded offered rate and rounded toward positive infinity to 2 decimals so it never understates. Return [offered, card_amount, markup_pct] as strings.

split: open-access


prompt:
A markup of 3.504% is disclosed as 3.50%.

solve(amount, ref_rate, markup_bps, card_exp): amount in merchant currency, ref_rate cardholder units per merchant unit, markup_bps an integer (negative for a promotional discount). The offered rate is ref*(1+bps/10000) rounded half-up to 6 decimals, and the card amount is amount*offered rounded half-up at card_exp. The disclosed markup percentage is (offered/ref - 1)*100 computed from the rounded offered rate and rounded toward positive infinity to 2 decimals so it never understates. Return [offered, card_amount, markup_pct] as strings.

split: open-access


prompt:
Three postings of 0.4 units each convert to zero in total instead of one unit.

solve(items, rate): items are [day, amount] with integer source minor units (reversals negative) in posting order; rate is target minor units per source minor unit. Within a day, each posting's converted amount is floor(cumulative_exact) - floor(previous cumulative_exact), so daily converted postings sum to floor of the day's exact converted total. The carry (cumulative total and previous floor) resets whenever the day changes. Return the list of integer converted postings.

split: open-access


prompt:
A fraction left over from Monday pays out on Tuesday.

solve(items, rate): items are [day, amount] with integer source minor units (reversals negative) in posting order; rate is target minor units per source minor unit. Within a day, each posting's converted amount is floor(cumulative_exact) - floor(previous cumulative_exact), so daily converted postings sum to floor of the day's exact converted total. The carry (cumulative total and previous floor) resets whenever the day changes. Return the list of integer converted postings.

split: open-access


prompt:
A day that starts with reversals posts converted amounts that do not sum to the floor of the total.

solve(items, rate): items are [day, amount] with integer source minor units (reversals negative) in posting order; rate is target minor units per source minor unit. Within a day, each posting's converted amount is floor(cumulative_exact) - floor(previous cumulative_exact), so daily converted postings sum to floor of the day's exact converted total. The carry (cumulative total and previous floor) resets whenever the day changes. Return the list of integer converted postings.

split: open-access


prompt:
The first posting of a new day is reduced by the previous day's accumulated floor.

solve(items, rate): items are [day, amount] with integer source minor units (reversals negative) in posting order; rate is target minor units per source minor unit. Within a day, each posting's converted amount is floor(cumulative_exact) - floor(previous cumulative_exact), so daily converted postings sum to floor of the day's exact converted total. The carry (cumulative total and previous floor) resets whenever the day changes. Return the list of integer converted postings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / n
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression deviation-denominator 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('regression deviation-denominator 2', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('partial repair guard 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('regression deviation-denominator 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('partial repair guard 2', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression deviation-denominator 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('regression deviation-denominator 2', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression deviation-denominator 1', ('1.093455', '1.1045', 100, False), 'accept'),
  ('regression deviation-denominator 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('1.93703825', '1.7525', 1000, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('0.6260540', '0.6292', 50, False), 'accept'),
  ('regression deviation-denominator 2', ('1.32976725', '1.3331', 25, False), 'accept'),
  ('partial repair guard 1', ('1.36829603', '0.7236', 100, True), 'reject'),
  ('partial repair guard 2', ('0.98224108', '1.0080', 100, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / max(n, r)
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression deviation-denominator 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('regression deviation-denominator 2', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('partial repair guard 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('regression deviation-denominator 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('partial repair guard 2', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression deviation-denominator 1', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('regression deviation-denominator 2', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression deviation-denominator 1', ('1.093455', '1.1045', 100, False), 'accept'),
  ('regression deviation-denominator 2', ('1.87484661', '1.8561', 100, False), 'reject'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('1.93703825', '1.7525', 1000, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression deviation-denominator 1', ('0.6260540', '0.6292', 50, False), 'accept'),
  ('regression deviation-denominator 2', ('1.32976725', '1.3331', 25, False), 'accept'),
  ('partial repair guard 1', ('1.36829603', '0.7236', 100, True), 'reject'),
  ('partial repair guard 2', ('0.98224108', '1.0080', 100, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A drop exactly at the tolerance is rejected while an equal rise is accepted.

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(float(n) - float(r)) / float(r)
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-boundary 1', ('1.1', '1.0', 1000, False), 'accept'),
  ('regression band-boundary 2', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('1.0835', '1.0835', 0, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('2.015556', '1.9956', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('partial repair guard 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('partial repair guard 2', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')],
 [('regression band-boundary 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('regression band-boundary 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('2.015556', '1.9956', 100, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression band-boundary 1', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('regression band-boundary 2', ('1.29844', '1.1804', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('1.886276', '1.8676', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.68751', '1.5341', 1000, False), 'accept'),
  ('partial repair guard 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('partial repair guard 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 < tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-boundary 1', ('1.1', '1.0', 1000, False), 'accept'),
  ('regression band-boundary 2', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('1.0835', '1.0835', 0, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('2.015556', '1.9956', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('partial repair guard 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('partial repair guard 2', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')],
 [('regression band-boundary 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('regression band-boundary 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('2.015556', '1.9956', 100, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression band-boundary 1', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('regression band-boundary 2', ('1.29844', '1.1804', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('1.886276', '1.8676', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.68751', '1.5341', 1000, False), 'accept'),
  ('partial repair guard 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('partial repair guard 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A 10% move against a 1000 bps band is rejected by a few ulps.

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    pass
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression inverted-quote 1', ('0.5', '2.0', 0, True), 'accept'),
  ('regression inverted-quote 2', ('0.52599504', '1.9023', 10, True), 'accept'),
  ('partial repair guard 1', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.58349261', '1.7075', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('partial repair guard 2', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression inverted-quote 1', ('0.91004974', '0.9784', 1000, True), 'reject'),
  ('regression inverted-quote 2', ('0.66896926', '1.4874', 50, True), 'accept'),
  ('partial repair guard 1', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('partial repair guard 2', ('0.51145669', '1.9601', 25, True), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression inverted-quote 1', ('0.79028053', '1.2655', 10, True), 'accept'),
  ('regression inverted-quote 2', ('0.53202622', '1.8710', 100, True), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.96761890', '0.5057', 50, True), 'accept'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('0.87256913', '1.1518', 50, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: r = 1 / r
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression inverted-quote 1', ('0.5', '2.0', 0, True), 'accept'),
  ('regression inverted-quote 2', ('0.52599504', '1.9023', 10, True), 'accept'),
  ('partial repair guard 1', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.58349261', '1.7075', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.20407797', '0.8389', 100, True), 'accept'),
  ('partial repair guard 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('partial repair guard 2', ('0.93539594', '1.0664', 25, True), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression inverted-quote 1', ('0.91004974', '0.9784', 1000, True), 'reject'),
  ('regression inverted-quote 2', ('0.66896926', '1.4874', 50, True), 'accept'),
  ('partial repair guard 1', ('1.00665155', '0.9924', 10, True), 'reject'),
  ('partial repair guard 2', ('0.51145669', '1.9601', 25, True), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression inverted-quote 1', ('0.79028053', '1.2655', 10, True), 'accept'),
  ('regression inverted-quote 2', ('0.53202622', '1.8710', 100, True), 'accept'),
  ('partial repair guard 1', ('1.41341757', '0.7005', 100, True), 'reject'),
  ('partial repair guard 2', ('0.78742098', '1.2687', 10, True), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression inverted-quote 1', ('0.66867939', '1.5030', 50, True), 'accept'),
  ('regression inverted-quote 2', ('1.96761890', '0.5057', 50, True), 'accept'),
  ('partial repair guard 1', ('0.78810637', '1.2657', 25, True), 'reject'),
  ('partial repair guard 2', ('0.87256913', '1.1518', 50, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A USD/EUR print is compared directly with the EUR/USD reference and rejected.

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = (n - r) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression two-sided-band 1', ('0.8', '1.0', 1000, False), 'reject'),
  ('regression two-sided-band 2', ('0.91604868', '1.0968', 25, True), 'reject'),
  ('partial repair guard 1', ('1.2', '1.0', 1000, False), 'reject'),
  ('partial repair guard 2', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression two-sided-band 1', ('0.74336731', '1.4947', 1000, True), 'reject'),
  ('regression two-sided-band 2', ('0.87740214', '1.3928', 1000, True), 'reject'),
  ('partial repair guard 1', ('0.59568663', '0.5929', 25, False), 'reject'),
  ('partial repair guard 2', ('0.95162298', '0.8547', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression two-sided-band 1', ('0.85059956', '0.8572', 50, False), 'reject'),
  ('regression two-sided-band 2', ('1.03353628', '1.0354', 10, False), 'reject'),
  ('partial repair guard 1', ('0.57265770', '0.5718', 10, False), 'reject'),
  ('partial repair guard 2', ('0.96278577', '1.0229', 100, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression two-sided-band 1', ('1.6275668', '1.6574', 100, False), 'reject'),
  ('regression two-sided-band 2', ('1.60129822', '1.6066', 25, False), 'reject'),
  ('partial repair guard 1', ('0.96185726', '0.9529', 50, False), 'reject'),
  ('partial repair guard 2', ('1.35897716', '1.3564', 10, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression two-sided-band 1', ('1.66306861', '1.6649', 10, False), 'reject'),
  ('regression two-sided-band 2', ('0.55485514', '0.5558', 10, False), 'reject'),
  ('partial repair guard 1', ('1.41436370', '0.6093', 1000, True), 'reject'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = (r - n) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression two-sided-band 1', ('0.8', '1.0', 1000, False), 'reject'),
  ('regression two-sided-band 2', ('0.91604868', '1.0968', 25, True), 'reject'),
  ('partial repair guard 1', ('1.2', '1.0', 1000, False), 'reject'),
  ('partial repair guard 2', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression two-sided-band 1', ('0.74336731', '1.4947', 1000, True), 'reject'),
  ('regression two-sided-band 2', ('0.87740214', '1.3928', 1000, True), 'reject'),
  ('partial repair guard 1', ('0.59568663', '0.5929', 25, False), 'reject'),
  ('partial repair guard 2', ('0.95162298', '0.8547', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject')],
 [('regression two-sided-band 1', ('0.85059956', '0.8572', 50, False), 'reject'),
  ('regression two-sided-band 2', ('1.03353628', '1.0354', 10, False), 'reject'),
  ('partial repair guard 1', ('0.57265770', '0.5718', 10, False), 'reject'),
  ('partial repair guard 2', ('0.96278577', '1.0229', 100, True), 'reject'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression two-sided-band 1', ('1.6275668', '1.6574', 100, False), 'reject'),
  ('regression two-sided-band 2', ('1.60129822', '1.6066', 25, False), 'reject'),
  ('partial repair guard 1', ('0.96185726', '0.9529', 50, False), 'reject'),
  ('partial repair guard 2', ('1.35897716', '1.3564', 10, False), 'reject'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression two-sided-band 1', ('1.66306861', '1.6649', 10, False), 'reject'),
  ('regression two-sided-band 2', ('0.55485514', '0.5558', 10, False), 'reject'),
  ('partial repair guard 1', ('1.41436370', '0.6093', 1000, True), 'reject'),
  ('partial repair guard 2', ('0.61344857', '1.6285', 10, True), 'reject'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A collapsed rate far below the reference is accepted.

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

split: open-access


prompt:
Payments booked on the cutover date are divided by the factor although they are already in the new currency.

solve(amount_minor, date, cutover, factor, old_exp, new_exp): amounts dated on or after the cutover (ISO date strings) are already in the new currency and returned unchanged as [amount_minor, 'native']. Earlier amounts are old-currency minor units: new = amount_minor / factor * 10**(new_exp - old_exp), rounded half away from zero, returned as [new, 'converted']. factor is old units per new unit.

split: open-access


prompt:
A zero-decimal legacy currency converted into a two-decimal currency is a hundred times too small.

solve(amount_minor, date, cutover, factor, old_exp, new_exp): amounts dated on or after the cutover (ISO date strings) are already in the new currency and returned unchanged as [amount_minor, 'native']. Earlier amounts are old-currency minor units: new = amount_minor / factor * 10**(new_exp - old_exp), rounded half away from zero, returned as [new, 'converted']. factor is old units per new unit.

split: open-access


prompt:
Old balances lose up to one new minor unit, and debts shrink toward zero.

solve(amount_minor, date, cutover, factor, old_exp, new_exp): amounts dated on or after the cutover (ISO date strings) are already in the new currency and returned unchanged as [amount_minor, 'native']. Earlier amounts are old-currency minor units: new = amount_minor / factor * 10**(new_exp - old_exp), rounded half away from zero, returned as [new, 'converted']. factor is old units per new unit.

split: open-access


prompt:
Legacy amounts with fractional old units lose value when redenominated.

solve(amount_minor, date, cutover, factor, old_exp, new_exp): amounts dated on or after the cutover (ISO date strings) are already in the new currency and returned unchanged as [amount_minor, 'native']. Earlier amounts are old-currency minor units: new = amount_minor / factor * 10**(new_exp - old_exp), rounded half away from zero, returned as [new, 'converted']. factor is old units per new unit.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(quotes, target):
    def per_usd(c):
        if c == 'USD': return Decimal(1)
        if 'USD' + c in quotes: return Decimal(quotes['USD' + c])
        if c + 'USD' in quotes: return Decimal(quotes[c + 'USD'])
        return None
    b, q = target[:3], target[3:]
    pb, pq = per_usd(b), per_usd(q)
    if pb is None or pq is None: return 'ERR:no-quote'
    return format((pq / pb).quantize(Decimal('0.000001'), rounding=ROUND_HALF_EVEN), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('regression quote-orientation 2',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'USDGBP'),
   '0.790514'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote')],
 [('regression quote-orientation 1',
   ({'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'EURGBP'), '0.856369'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'CADGBP'),
   '0.582245'),
  ('partial repair guard 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(quotes, target):
    def per_usd(c):
        if c == 'USD': return Decimal(1)
        if 'USD' + c in quotes: return 1 / Decimal(quotes['USD' + c])
        if c + 'USD' in quotes: return Decimal(quotes[c + 'USD'])
        return None
    b, q = target[:3], target[3:]
    pb, pq = per_usd(b), per_usd(q)
    if pb is None or pq is None: return 'ERR:no-quote'
    return format((pq / pb).quantize(Decimal('0.000001'), rounding=ROUND_HALF_EVEN), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('regression quote-orientation 2',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000')],
 [('regression quote-orientation 1',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'USDGBP'),
   '0.790514'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote')],
 [('regression quote-orientation 1',
   ({'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'EURGBP'), '0.856369'),
  ('regression quote-orientation 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'CADGBP'),
   '0.582245'),
  ('partial repair guard 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
EURJPY is computed as 139.7 instead of 164.0.

solve(quotes, target): quotes maps six-letter pairs to rates (QUOTE units per BASE unit). For currency c, units per USD are: 1 for USD; quotes['USD'+c] if present (authoritative when both orientations exist); else 1/quotes[c+'USD']; else unknown. The target BBBQQQ rate = (QQQ per USD)/(BBB per USD), rounded half-even to 6 decimals and returned as a string; an unknown leg returns 'ERR:no-quote'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(quotes, target):
    def per_usd(c):
        if c == 'USD': return Decimal(1)
        if 'USD' + c in quotes: return Decimal(quotes['USD' + c])
        if c + 'USD' in quotes: return 1 / Decimal(quotes[c + 'USD'])
        return None
    b, q = target[:3], target[3:]
    pb, pq = per_usd(b), per_usd(q)
    if pb is None or pq is None: return 'ERR:no-quote'
    return format((pb / pq).quantize(Decimal('0.000001'), rounding=ROUND_HALF_EVEN), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('partial repair guard 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote')],
 [('regression cross-division-order 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610',
     'USDEUR': '0.9231'},
    'JPYCAD'),
   '0.008969'),
  ('partial repair guard 2',
   ({'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'EURGBP'), '0.856369'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(quotes, target):
    def per_usd(c):
        if c == 'USD': return Decimal(1)
        if 'USD' + c in quotes: return Decimal(quotes['USD' + c])
        if c + 'USD' in quotes: return 1 / Decimal(quotes[c + 'USD'])
        return None
    b, q = target[:3], target[3:]
    pb, pq = per_usd(b), per_usd(q)
    if pb is None or pq is None: return 'ERR:no-quote'
    return format((pq * pb).quantize(Decimal('0.000001'), rounding=ROUND_HALF_EVEN), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('control: euro yen',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURJPY'),
   '164.009395'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000')],
 [('regression cross-division-order 1',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'AUDCHF'),
   '0.581922'),
  ('partial repair guard 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('partial repair guard 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('control: sterling euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'GBPEUR'),
   '1.167513'),
  ('control: direct usd base',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDJPY'),
   '151.370000'),
  ('control: usd quote',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'JPYUSD'),
   '0.006606'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote')],
 [('regression cross-division-order 1',
   ({'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610'},
    'CHFGBP'),
   '0.898209'),
  ('regression cross-division-order 2',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577'},
    'EURAUD'),
   '1.638687'),
  ('partial repair guard 1',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDCAD': '1.3577',
     'JPYUSD': '0.006610',
     'USDEUR': '0.9231'},
    'JPYCAD'),
   '0.008969'),
  ('partial repair guard 2',
   ({'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612', 'USDEUR': '0.9231'}, 'EURGBP'), '0.856369'),
  ('control: missing leg',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'EURSEK'),
   'ERR:no-quote'),
  ('control: franc aussie',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'CHFAUD'),
   '1.718443'),
  ('control: both orientations',
   ({'USDJPY': '151.37',
     'EURUSD': '1.0835',
     'GBPUSD': '1.2650',
     'USDCHF': '0.8801',
     'AUDUSD': '0.6612',
     'USDEUR': '0.9231'},
    'EURCHF'),
   '0.953418'),
  ('control: usd to euro',
   ({'USDJPY': '151.37', 'EURUSD': '1.0835', 'GBPUSD': '1.2650', 'USDCHF': '0.8801', 'AUDUSD': '0.6612'}, 'USDEUR'),
   '0.922935')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
EURJPY is returned as its reciprocal.

solve(quotes, target): quotes maps six-letter pairs to rates (QUOTE units per BASE unit). For currency c, units per USD are: 1 for USD; quotes['USD'+c] if present (authoritative when both orientations exist); else 1/quotes[c+'USD']; else unknown. The target BBBQQQ rate = (QQQ per USD)/(BBB per USD), rounded half-even to 6 decimals and returned as a string; an unknown leg returns 'ERR:no-quote'.

split: open-access