broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_HALF_UP) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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 decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_FLOOR) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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:
Local fares are sometimes below the converted NUC amount.

Input {'nuc':[component amounts],'roe','currency'}. Sum components exactly, truncate the NUC total to 2 decimals, multiply by ROE, and round UP to the currency unit (USD/EUR/GBP 1, JPY 100, KWD 0.1) in exact decimal arithmetic; other currencies -> 'ERR_CURRENCY'. Return [NUC string, local string].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)).quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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 decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(round(c, 2))) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Multi-component journeys lose fractions of a cent per component and the total drops a cent.

Input {'nuc':[component amounts],'roe','currency'}. Sum components exactly, truncate the NUC total to 2 decimals, multiply by ROE, and round UP to the currency unit (USD/EUR/GBP 1, JPY 100, KWD 0.1) in exact decimal arithmetic; other currencies -> 'ERR_CURRENCY'. Return [NUC string, local string].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc / decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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 decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(round(x['roe'], 2)))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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:
JPY fares come out at a fraction of the correct amount.

Input {'nuc':[component amounts],'roe','currency'}. Sum components exactly, truncate the NUC total to 2 decimals, multiply by ROE, and round UP to the currency unit (USD/EUR/GBP 1, JPY 100, KWD 0.1) in exact decimal arithmetic; other currencies -> 'ERR_CURRENCY'. Return [NUC string, local string].

split: open-access


prompt:
A 100.00 NUC fare at ROE 1.1 is collected as 111 instead of 110.

Input {'nuc':[component amounts],'roe','currency'}. Sum components exactly, truncate the NUC total to 2 decimals, multiply by ROE, and round UP to the currency unit (USD/EUR/GBP 1, JPY 100, KWD 0.1) in exact decimal arithmetic; other currencies -> 'ERR_CURRENCY'. Return [NUC string, local string].

split: open-access


prompt:
A US-originating round trip with a Mexican stop pays both US and Mexican percentage taxes.

Input {'base','yq','segments':[[from country, to country]],'pct_tax':{country: %},'dep_tax':{country: flat}}. The percentage tax of the journey origin (first segment departure country) applies once to the base fare only; each segment pays the flat departure tax of its departure country plus YQ. Return total r2.

split: open-access


prompt:
Adding YQ increases the percentage tax.

Input {'base','yq','segments':[[from country, to country]],'pct_tax':{country: %},'dep_tax':{country: flat}}. The percentage tax of the journey origin (first segment departure country) applies once to the base fare only; each segment pays the flat departure tax of its departure country plus YQ. Return total r2.

split: open-access


prompt:
A flight into London is charged the UK departure tax, and the flight out is not.

Input {'base','yq','segments':[[from country, to country]],'pct_tax':{country: %},'dep_tax':{country: flat}}. The percentage tax of the journey origin (first segment departure country) applies once to the base fare only; each segment pays the flat departure tax of its departure country plus YQ. Return total r2.

split: open-access


prompt:
Percentage tax follows the last departure rather than where the journey began.

Input {'base','yq','segments':[[from country, to country]],'pct_tax':{country: %},'dep_tax':{country: flat}}. The percentage tax of the journey origin (first segment departure country) applies once to the base fare only; each segment pays the flat departure tax of its departure country plus YQ. Return total r2.

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = n // x['free_per']
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]], ['regression: free ticket entitlement', {'pax': 31, 'min_group': 20, 'free_per': 15, 'fare': 530.51, 'disc_pct': 12}, [30, 1, 14005.5]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]], ['regression: free ticket entitlement', {'pax': 47, 'min_group': 10, 'free_per': 15, 'fare': 513.47, 'disc_pct': 20}, [45, 2, 18485.1]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]], ['regression: free ticket entitlement', {'pax': 38, 'min_group': 15, 'free_per': 5, 'fare': 383.79, 'disc_pct': 10}, [32, 6, 11053.12]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = (n - 1) // x['free_per']
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]], ['regression: free ticket entitlement', {'pax': 31, 'min_group': 20, 'free_per': 15, 'fare': 530.51, 'disc_pct': 12}, [30, 1, 14005.5]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]], ['regression: free ticket entitlement', {'pax': 47, 'min_group': 10, 'free_per': 15, 'fare': 513.47, 'disc_pct': 20}, [45, 2, 18485.1]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]], ['regression: free ticket entitlement', {'pax': 38, 'min_group': 15, 'free_per': 5, 'fare': 383.79, 'disc_pct': 10}, [32, 6, 11053.12]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
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 group of 15 receives a free ticket although only 14 would then be paying.

Input {'pax','min_group','free_per','fare','disc_pct'}. Below min_group (total travellers) no discount and no free tickets. Otherwise one free ticket per free_per paying travellers (free = pax // (free_per+1)); each paying fare = fare*(100-disc)/100 rounded to cents, then multiplied. Return [paying, free, total r2].

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n <= x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n - n // (x['free_per'] + 1) < x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
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:
Ten travellers booking a ten-minimum group fare pay the full fare.

Input {'pax','min_group','free_per','fare','disc_pct'}. Below min_group (total travellers) no discount and no free tickets. Otherwise one free ticket per free_per paying travellers (free = pax // (free_per+1)); each paying fare = fare*(100-disc)/100 rounded to cents, then multiplied. Return [paying, free, total r2].

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = x['fare'] * (100 - x['disc_pct']) / 100
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        return [n, 0, round(per * n, 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = int(x['fare'] * (100 - x['disc_pct'])) / 100
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The group total differs by a few cents from the per-passenger fares printed on each ticket.

Input {'pax','min_group','free_per','fare','disc_pct'}. Below min_group (total travellers) no discount and no free tickets. Otherwise one free ticket per free_per paying travellers (free = pax // (free_per+1)); each paying fare = fare*(100-disc)/100 rounded to cents, then multiplied. Return [paying, free, total r2].

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        free = n // (x['free_per'] + 1)
        return [n - free, free, round(per * (n - free), 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    n = x['pax']
    if n < x['min_group']:
        per = round(x['fare'], 2)
        return [n, n // (x['free_per'] + 1), round(per * n, 2)]
    free = n // (x['free_per'] + 1)
    paying = n - free
    per = round(x['fare'] * (100 - x['disc_pct']) / 100, 2)
    return [paying, free, round(per * paying, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 13}, [10, 0, 2174.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 200.95, 'disc_pct': 10}, [15, 0, 2712.75]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 35, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [33, 2, 10230.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 101.0, 'disc_pct': 10}, [12, 0, 1212.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 13, 'min_group': 20, 'free_per': 5, 'fare': 244.64, 'disc_pct': 12}, [13, 0, 3180.32]], ['sampled case 2', {'pax': 24, 'min_group': 20, 'free_per': 5, 'fare': 241.52, 'disc_pct': 20}, [20, 4, 3864.4]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 10, 'fare': 154.51, 'disc_pct': 15}, [54, 5, 7091.82]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 14}, [10, 0, 2149.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 201.95, 'disc_pct': 10}, [15, 0, 2726.25]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 36, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [34, 2, 10540.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 102.0, 'disc_pct': 10}, [12, 0, 1224.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 24, 'min_group': 15, 'free_per': 5, 'fare': 165.48, 'disc_pct': 15}, [20, 4, 2813.2]], ['sampled case 2', {'pax': 50, 'min_group': 20, 'free_per': 15, 'fare': 118.08, 'disc_pct': 10}, [47, 3, 4994.69]], ['sampled case 3', {'pax': 24, 'min_group': 20, 'free_per': 9, 'fare': 198.91, 'disc_pct': 7}, [22, 2, 4069.78]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 15}, [10, 0, 2124.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 202.95, 'disc_pct': 10}, [15, 0, 2739.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 37, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [35, 2, 10850.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 103.0, 'disc_pct': 10}, [12, 0, 1236.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 28, 'min_group': 20, 'free_per': 9, 'fare': 148.43, 'disc_pct': 15}, [26, 2, 3280.42]], ['sampled case 2', {'pax': 19, 'min_group': 10, 'free_per': 10, 'fare': 244.1, 'disc_pct': 12}, [18, 1, 3866.58]], ['sampled case 3', {'pax': 37, 'min_group': 20, 'free_per': 15, 'fare': 79.12, 'disc_pct': 5}, [35, 2, 2630.6]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 16}, [10, 0, 2099.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 203.95, 'disc_pct': 10}, [15, 0, 2753.4]], ['small party', {'pax': 8, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [8, 0, 960.0]], ['large group two free', {'pax': 38, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [36, 2, 11160.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 104.0, 'disc_pct': 10}, [12, 0, 1248.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 17, 'min_group': 20, 'free_per': 10, 'fare': 198.81, 'disc_pct': 7}, [17, 0, 3379.77]], ['sampled case 2', {'pax': 19, 'min_group': 15, 'free_per': 10, 'fare': 304.43, 'disc_pct': 5}, [18, 1, 5205.78]], ['sampled case 3', {'pax': 23, 'min_group': 15, 'free_per': 10, 'fare': 154.19, 'disc_pct': 7}, [21, 2, 3011.4]]], [['exactly minimum group', {'pax': 10, 'min_group': 10, 'free_per': 15, 'fare': 249.99, 'disc_pct': 17}, [10, 0, 2074.9]], ['sixteen travellers one free', {'pax': 16, 'min_group': 10, 'free_per': 15, 'fare': 199.95, 'disc_pct': 10}, [15, 1, 2699.4]], ['fifteen travellers none free', {'pax': 15, 'min_group': 10, 'free_per': 15, 'fare': 204.95, 'disc_pct': 10}, [15, 0, 2766.9]], ['small party', {'pax': 9, 'min_group': 10, 'free_per': 15, 'fare': 120.0, 'disc_pct': 15}, [9, 0, 1080.0]], ['large group two free', {'pax': 39, 'min_group': 10, 'free_per': 15, 'fare': 333.33, 'disc_pct': 7}, [37, 2, 11470.0]], ['generous free rule small party', {'pax': 12, 'min_group': 20, 'free_per': 5, 'fare': 105.0, 'disc_pct': 10}, [12, 0, 1260.0]], ['rounding per passenger', {'pax': 21, 'min_group': 20, 'free_per': 9, 'fare': 99.99, 'disc_pct': 15}, [19, 2, 1614.81]], ['sampled case 1', {'pax': 30, 'min_group': 15, 'free_per': 15, 'fare': 348.05, 'disc_pct': 12}, [29, 1, 8882.12]], ['sampled case 2', {'pax': 31, 'min_group': 15, 'free_per': 9, 'fare': 312.49, 'disc_pct': 12}, [28, 3, 7699.72]], ['sampled case 3', {'pax': 59, 'min_group': 20, 'free_per': 9, 'fare': 68.44, 'disc_pct': 10}, [54, 5, 3326.4]]]]
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 12-person party on a 20-minimum group fare gets two free tickets.

Input {'pax','min_group','free_per','fare','disc_pct'}. Below min_group (total travellers) no discount and no free tickets. Otherwise one free ticket per free_per paying travellers (free = pax // (free_per+1)); each paying fare = fare*(100-disc)/100 rounded to cents, then multiplied. Return [paying, free, total r2].

split: open-access