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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n > 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression soft pity start #1',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('regression soft pity start #2',
   [[43, 52, 75, 813, 828, 669, 557, 11, 855, 17, 999, 899, 730, 13, 836, 14, 713],
    {'pity': 72, 'guarantee': True}],
   {'results': '-F---------------', 'pity': 15, 'guarantee': False}),
  ('partial repair boundary #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('partial repair boundary #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('regression soft pity start #1',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression soft pity start #2',
   [[52, 34, 15, 820, 60, 952, 28, 17, 954, 687, 731, 3, 889, 15, 985, 37], {'pity': 71, 'guarantee': False}],
   {'results': '--L--------F----', 'pity': 4, 'guarantee': False}),
  ('partial repair boundary #1',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('partial repair boundary #2',
   [[54, 849, 304, 44], {'pity': 72, 'guarantee': True}],
   {'results': '---F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('control #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})],
 [('regression soft pity start #1',
   [[32, 1], {'pity': 73, 'guarantee': False}],
   {'results': 'FL', 'pity': 0, 'guarantee': True}),
  ('regression soft pity start #2',
   [[875, 20, 11, 41, 521, 27, 780, 997, 455, 927, 244, 830, 270, 917, 57, 59, 17, 51],
    {'pity': 72, 'guarantee': False}],
   {'results': '-F----------------', 'pity': 16, 'guarantee': False}),
  ('partial repair boundary #1',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #2',
   [[977, 15, 30, 31, 556, 481, 841, 29, 15, 723, 44, 251, 24], {'pity': 73, 'guarantee': True}],
   {'results': '-F-----------', 'pity': 11, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('control #2',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True})],
 [('regression soft pity start #1',
   [[25, 15, 19, 2, 45, 34, 523, 824, 29, 272, 697], {'pity': 72, 'guarantee': True}],
   {'results': '-F-F-------', 'pity': 7, 'guarantee': False}),
  ('regression soft pity start #2',
   [[35, 814, 40, 956, 3, 418, 44, 36, 812, 906, 868, 800, 42, 866, 926], {'pity': 73, 'guarantee': True}],
   {'results': 'F---L----------', 'pity': 10, 'guarantee': True}),
  ('partial repair boundary #1',
   [[54, 861, 805, 816, 40, 902, 32, 646, 847, 32, 80, 234, 148, 476, 13], {'pity': 72, 'guarantee': True}],
   {'results': '----F----------', 'pity': 10, 'guarantee': False}),
  ('regression soft pity start #3',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('regression soft pity start #1',
   [[633, 19, 988, 444, 13, 683, 926, 9, 362, 59, 866, 928, 889, 983, 202, 35, 13],
    {'pity': 72, 'guarantee': True}],
   {'results': '-F---------------', 'pity': 15, 'guarantee': False}),
  ('regression soft pity start #2',
   [[50, 974, 37, 32, 926, 934, 26, 44, 6, 977, 12, 958, 725, 30, 653], {'pity': 73, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('partial repair boundary #1',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('partial repair boundary #2',
   [[891, 307, 20, 907, 30, 974, 462, 957, 860, 624, 42, 985, 46], {'pity': 73, 'guarantee': False}],
   {'results': '--F----------', 'pity': 10, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('control #2',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 80:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression soft pity start #1',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('regression soft pity start #2',
   [[43, 52, 75, 813, 828, 669, 557, 11, 855, 17, 999, 899, 730, 13, 836, 14, 713],
    {'pity': 72, 'guarantee': True}],
   {'results': '-F---------------', 'pity': 15, 'guarantee': False}),
  ('partial repair boundary #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('partial repair boundary #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('regression soft pity start #1',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression soft pity start #2',
   [[52, 34, 15, 820, 60, 952, 28, 17, 954, 687, 731, 3, 889, 15, 985, 37], {'pity': 71, 'guarantee': False}],
   {'results': '--L--------F----', 'pity': 4, 'guarantee': False}),
  ('partial repair boundary #1',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('partial repair boundary #2',
   [[54, 849, 304, 44], {'pity': 72, 'guarantee': True}],
   {'results': '---F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('control #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})],
 [('regression soft pity start #1',
   [[32, 1], {'pity': 73, 'guarantee': False}],
   {'results': 'FL', 'pity': 0, 'guarantee': True}),
  ('regression soft pity start #2',
   [[875, 20, 11, 41, 521, 27, 780, 997, 455, 927, 244, 830, 270, 917, 57, 59, 17, 51],
    {'pity': 72, 'guarantee': False}],
   {'results': '-F----------------', 'pity': 16, 'guarantee': False}),
  ('partial repair boundary #1',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #2',
   [[977, 15, 30, 31, 556, 481, 841, 29, 15, 723, 44, 251, 24], {'pity': 73, 'guarantee': True}],
   {'results': '-F-----------', 'pity': 11, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('control #2',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True})],
 [('regression soft pity start #1',
   [[25, 15, 19, 2, 45, 34, 523, 824, 29, 272, 697], {'pity': 72, 'guarantee': True}],
   {'results': '-F-F-------', 'pity': 7, 'guarantee': False}),
  ('regression soft pity start #2',
   [[35, 814, 40, 956, 3, 418, 44, 36, 812, 906, 868, 800, 42, 866, 926], {'pity': 73, 'guarantee': True}],
   {'results': 'F---L----------', 'pity': 10, 'guarantee': True}),
  ('partial repair boundary #1',
   [[54, 861, 805, 816, 40, 902, 32, 646, 847, 32, 80, 234, 148, 476, 13], {'pity': 72, 'guarantee': True}],
   {'results': '----F----------', 'pity': 10, 'guarantee': False}),
  ('regression soft pity start #3',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('regression soft pity start #1',
   [[633, 19, 988, 444, 13, 683, 926, 9, 362, 59, 866, 928, 889, 983, 202, 35, 13],
    {'pity': 72, 'guarantee': True}],
   {'results': '-F---------------', 'pity': 15, 'guarantee': False}),
  ('regression soft pity start #2',
   [[50, 974, 37, 32, 926, 934, 26, 44, 6, 977, 12, 958, 725, 30, 653], {'pity': 73, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('partial repair boundary #1',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('partial repair boundary #2',
   [[891, 307, 20, 907, 30, 974, 462, 957, 860, 624, 42, 985, 46], {'pity': 73, 'guarantee': False}],
   {'results': '--F----------', 'pity': 10, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('control #2',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The advertised first soft-pity pull gets no boosted rate.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n > 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression hard pity guarantee #2',
   [[986], {'pity': 89, 'guarantee': True}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression hard pity guarantee #3',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression hard pity guarantee #4',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[986], {'pity': 89, 'guarantee': True}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #4',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #2',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[866, 716, 336, 806, 719, 971, 56, 858, 215, 881, 854, 21, 997, 459, 240],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[866, 716, 336, 806, 719, 971, 56, 858, 215, 881, 854, 21, 997, 459, 240],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[890, 52, 19, 184, 980], {'pity': 89, 'guarantee': False}],
   {'results': 'F----', 'pity': 4, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[929, 229, 908, 987, 916, 982, 868, 899, 703, 873, 474, 54, 48, 190, 47, 959, 85],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L----------------', 'pity': 16, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[890, 52, 19, 184, 980], {'pity': 89, 'guarantee': False}],
   {'results': 'F----', 'pity': 4, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[929, 229, 908, 987, 916, 982, 868, 899, 703, 873, 474, 54, 48, 190, 47, 959, 85],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L----------------', 'pity': 16, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[860, 578, 19, 809, 175, 896, 995, 51, 817, 955, 882, 623, 519, 962, 886, 900, 785, 824, 15],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F------------------', 'pity': 18, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[999, 955, 867, 824, 299, 243, 930, 89, 25, 397, 757, 7, 112, 301, 716, 703, 998, 888, 950, 816],
    {'pity': 88, 'guarantee': True}],
   {'results': '-F------------------', 'pity': 18, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if pity >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression hard pity guarantee #2',
   [[986], {'pity': 89, 'guarantee': True}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression hard pity guarantee #3',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression hard pity guarantee #4',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[986], {'pity': 89, 'guarantee': True}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #4',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #2',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[866, 716, 336, 806, 719, 971, 56, 858, 215, 881, 854, 21, 997, 459, 240],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[866, 716, 336, 806, 719, 971, 56, 858, 215, 881, 854, 21, 997, 459, 240],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[890, 52, 19, 184, 980], {'pity': 89, 'guarantee': False}],
   {'results': 'F----', 'pity': 4, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[929, 229, 908, 987, 916, 982, 868, 899, 703, 873, 474, 54, 48, 190, 47, 959, 85],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L----------------', 'pity': 16, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression hard pity guarantee #1',
   [[890, 52, 19, 184, 980], {'pity': 89, 'guarantee': False}],
   {'results': 'F----', 'pity': 4, 'guarantee': False}),
  ('regression hard pity guarantee #2',
   [[929, 229, 908, 987, 916, 982, 868, 899, 703, 873, 474, 54, 48, 190, 47, 959, 85],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L----------------', 'pity': 16, 'guarantee': True}),
  ('regression hard pity guarantee #3',
   [[860, 578, 19, 809, 175, 896, 995, 51, 817, 955, 882, 623, 519, 962, 886, 900, 785, 824, 15],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F------------------', 'pity': 18, 'guarantee': False}),
  ('regression hard pity guarantee #4',
   [[999, 955, 867, 824, 299, 243, 930, 89, 25, 397, 757, 7, 112, 301, 716, 703, 998, 888, 950, 816],
    {'pity': 88, 'guarantee': True}],
   {'results': '-F------------------', 'pity': 18, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The 90th pull may fail to award a top-rarity item.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = n
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pity reset #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pity reset #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pity reset #4',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('control #1',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True}),
  ('control #2', [[54], {'pity': 61, 'guarantee': False}], {'results': '-', 'pity': 62, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pity reset #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pity reset #3',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pity reset #4',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('control #1',
   [[938, 58, 37, 11, 926, 889, 844, 11, 265], {'pity': 0, 'guarantee': False}],
   {'results': '---------', 'pity': 9, 'guarantee': False}),
  ('control #2',
   [[43, 382, 597, 932, 22, 950, 46, 694, 804, 21, 825, 523, 125, 765], {'pity': 26, 'guarantee': False}],
   {'results': '--------------', 'pity': 40, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pity reset #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression pity reset #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pity reset #4',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('control #1', [[901], {'pity': 54, 'guarantee': False}], {'results': '-', 'pity': 55, 'guarantee': False}),
  ('control #2',
   [[40, 846, 823, 917, 973, 874, 95, 46, 59, 36, 36, 872, 9, 854, 926, 882, 133],
    {'pity': 0, 'guarantee': False}],
   {'results': '-----------------', 'pity': 17, 'guarantee': False})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pity reset #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('regression pity reset #3',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pity reset #4',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('control #1',
   [[986, 892, 958, 29, 925, 855, 10, 138, 806, 213, 889, 837, 994, 19], {'pity': 14, 'guarantee': False}],
   {'results': '--------------', 'pity': 28, 'guarantee': False}),
  ('control #2',
   [[806, 775, 826, 58], {'pity': 66, 'guarantee': False}],
   {'results': '----', 'pity': 70, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 1
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pity reset #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pity reset #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pity reset #4',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('control #1',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True}),
  ('control #2', [[54], {'pity': 61, 'guarantee': False}], {'results': '-', 'pity': 62, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pity reset #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pity reset #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pity reset #3',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pity reset #4',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('control #1',
   [[938, 58, 37, 11, 926, 889, 844, 11, 265], {'pity': 0, 'guarantee': False}],
   {'results': '---------', 'pity': 9, 'guarantee': False}),
  ('control #2',
   [[43, 382, 597, 932, 22, 950, 46, 694, 804, 21, 825, 523, 125, 765], {'pity': 26, 'guarantee': False}],
   {'results': '--------------', 'pity': 40, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pity reset #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression pity reset #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pity reset #4',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('control #1', [[901], {'pity': 54, 'guarantee': False}], {'results': '-', 'pity': 55, 'guarantee': False}),
  ('control #2',
   [[40, 846, 823, 917, 973, 874, 95, 46, 59, 36, 36, 872, 9, 854, 926, 882, 133],
    {'pity': 0, 'guarantee': False}],
   {'results': '-----------------', 'pity': 17, 'guarantee': False})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('regression pity reset #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pity reset #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('regression pity reset #3',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pity reset #4',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('control #1',
   [[986, 892, 958, 29, 925, 855, 10, 138, 806, 213, 889, 837, 994, 19], {'pity': 14, 'guarantee': False}],
   {'results': '--------------', 'pity': 28, 'guarantee': False}),
  ('control #2',
   [[806, 775, 826, 58], {'pity': 66, 'guarantee': False}],
   {'results': '----', 'pity': 70, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
After a top-rarity hit the next hit arrives far too early.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                pass
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('partial repair boundary #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('partial repair boundary #2',
   [[4, 42, 253, 999, 775, 819, 42, 973, 811, 307, 835, 958, 247, 22], {'pity': 73, 'guarantee': False}],
   {'results': 'F-------------', 'pity': 13, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('control #2', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('partial repair boundary #1',
   [[4], {'pity': 73, 'guarantee': False}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression guarantee consumption #1',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[30, 806], {'pity': 83, 'guarantee': False}],
   {'results': 'F-', 'pity': 1, 'guarantee': False}),
  ('partial repair boundary #2',
   [[891, 307, 20, 907, 30, 974, 462, 957, 860, 624, 42, 985, 46], {'pity': 73, 'guarantee': False}],
   {'results': '--F----------', 'pity': 10, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('control #2',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('partial repair boundary #1',
   [[24, 872, 131, 279, 598, 873, 881, 532, 874, 898, 570, 33, 575, 16, 950, 871, 988, 895, 840],
    {'pity': 81, 'guarantee': False}],
   {'results': 'F------------------', 'pity': 18, 'guarantee': False}),
  ('partial repair boundary #2',
   [[764, 38, 847, 39, 859, 959, 58, 877, 56, 252, 44, 46, 23, 992, 525, 972, 997],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F----------------', 'pity': 16, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1', [[54], {'pity': 61, 'guarantee': False}], {'results': '-', 'pity': 62, 'guarantee': False}),
  ('control #2',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[54, 849, 304, 44], {'pity': 72, 'guarantee': True}],
   {'results': '---F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[975, 474, 33, 973, 869, 8, 806, 843, 21, 34, 874], {'pity': 88, 'guarantee': True}],
   {'results': '-F---------', 'pity': 9, 'guarantee': False}),
  ('partial repair boundary #1',
   [[456, 631, 879, 18, 33, 855, 6], {'pity': 73, 'guarantee': False}],
   {'results': '---F---', 'pity': 3, 'guarantee': False}),
  ('partial repair boundary #2',
   [[32, 1], {'pity': 73, 'guarantee': False}],
   {'results': 'FL', 'pity': 0, 'guarantee': True}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('control #2',
   [[938, 58, 37, 11, 926, 889, 844, 11, 265], {'pity': 0, 'guarantee': False}],
   {'results': '---------', 'pity': 9, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = not guarantee
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('partial repair boundary #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('partial repair boundary #2',
   [[4, 42, 253, 999, 775, 819, 42, 973, 811, 307, 835, 958, 247, 22], {'pity': 73, 'guarantee': False}],
   {'results': 'F-------------', 'pity': 13, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('control #2', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('partial repair boundary #1',
   [[4], {'pity': 73, 'guarantee': False}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('regression guarantee consumption #1',
   [[50, 38, 898, 817, 564, 877, 22, 812, 15, 0, 190], {'pity': 73, 'guarantee': True}],
   {'results': 'F--------F-', 'pity': 1, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True}),
  ('control #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[30, 806], {'pity': 83, 'guarantee': False}],
   {'results': 'F-', 'pity': 1, 'guarantee': False}),
  ('partial repair boundary #2',
   [[891, 307, 20, 907, 30, 974, 462, 957, 860, 624, 42, 985, 46], {'pity': 73, 'guarantee': False}],
   {'results': '--F----------', 'pity': 10, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('control #2',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('partial repair boundary #1',
   [[24, 872, 131, 279, 598, 873, 881, 532, 874, 898, 570, 33, 575, 16, 950, 871, 988, 895, 840],
    {'pity': 81, 'guarantee': False}],
   {'results': 'F------------------', 'pity': 18, 'guarantee': False}),
  ('partial repair boundary #2',
   [[764, 38, 847, 39, 859, 959, 58, 877, 56, 252, 44, 46, 23, 992, 525, 972, 997],
    {'pity': 89, 'guarantee': False}],
   {'results': 'F----------------', 'pity': 16, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1', [[54], {'pity': 61, 'guarantee': False}], {'results': '-', 'pity': 62, 'guarantee': False}),
  ('control #2',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True})],
 [('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #1',
   [[54, 849, 304, 44], {'pity': 72, 'guarantee': True}],
   {'results': '---F', 'pity': 0, 'guarantee': False}),
  ('fault site guarantee consumption #2',
   [[975, 474, 33, 973, 869, 8, 806, 843, 21, 34, 874], {'pity': 88, 'guarantee': True}],
   {'results': '-F---------', 'pity': 9, 'guarantee': False}),
  ('partial repair boundary #1',
   [[456, 631, 879, 18, 33, 855, 6], {'pity': 73, 'guarantee': False}],
   {'results': '---F---', 'pity': 3, 'guarantee': False}),
  ('partial repair boundary #2',
   [[32, 1], {'pity': 73, 'guarantee': False}],
   {'results': 'FL', 'pity': 0, 'guarantee': True}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('control #1',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('control #2',
   [[938, 58, 37, 11, 926, 889, 844, 11, 265], {'pity': 0, 'guarantee': False}],
   {'results': '---------', 'pity': 9, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Every hit after one lost fifty-fifty is featured forever.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = False
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[13, 897, 905, 973, 838, 47, 24, 42, 813, 832, 963, 957, 47, 811, 56, 994, 13, 928],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[15, 807, 9, 881, 1, 54, 966, 923, 250, 107, 0, 892, 136, 3, 18, 878], {'pity': 89, 'guarantee': False}],
   {'results': 'L---F-----F--L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[15, 807, 9, 881, 1, 54, 966, 923, 250, 107, 0, 892, 136, 3, 18, 878], {'pity': 89, 'guarantee': False}],
   {'results': 'L---F-----F--L--', 'pity': 2, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[988, 831, 818, 438, 385, 1, 11, 60, 93, 932, 991, 819], {'pity': 88, 'guarantee': False}],
   {'results': '-L---F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[4, 981, 950, 937, 739, 13, 768, 921, 979, 2, 3, 996], {'pity': 89, 'guarantee': False}],
   {'results': 'F--------FL-', 'pity': 1, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[11, 47, 871, 857, 891, 200, 545, 440, 54, 153, 670, 183, 56, 969, 930, 688, 52, 36],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[711, 926, 856, 59, 840, 978, 927, 160, 919, 993, 878, 579, 989], {'pity': 73, 'guarantee': False}],
   {'results': '---L---------', 'pity': 9, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression guarantee grant #1',
   [[811, 511, 897, 20, 849, 22, 758, 623, 891, 950], {'pity': 88, 'guarantee': False}],
   {'results': '-L--------', 'pity': 8, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = n < 90
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[13, 897, 905, 973, 838, 47, 24, 42, 813, 832, 963, 957, 47, 811, 56, 994, 13, 928],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[15, 807, 9, 881, 1, 54, 966, 923, 250, 107, 0, 892, 136, 3, 18, 878], {'pity': 89, 'guarantee': False}],
   {'results': 'L---F-----F--L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[15, 807, 9, 881, 1, 54, 966, 923, 250, 107, 0, 892, 136, 3, 18, 878], {'pity': 89, 'guarantee': False}],
   {'results': 'L---F-----F--L--', 'pity': 2, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[988, 831, 818, 438, 385, 1, 11, 60, 93, 932, 991, 819], {'pity': 88, 'guarantee': False}],
   {'results': '-L---F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[879, 933, 335, 968, 23, 554, 957, 37, 960, 47, 35, 24, 892, 11, 52, 851, 334, 43, 807, 808],
    {'pity': 88, 'guarantee': False}],
   {'results': '-L------------------', 'pity': 18, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[812, 997, 899, 10], {'pity': 88, 'guarantee': False}],
   {'results': '-L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[4, 981, 950, 937, 739, 13, 768, 921, 979, 2, 3, 996], {'pity': 89, 'guarantee': False}],
   {'results': 'F--------FL-', 'pity': 1, 'guarantee': True}),
  ('regression guarantee grant #1',
   [[11, 47, 871, 857, 891, 200, 545, 440, 54, 153, 670, 183, 56, 969, 930, 688, 52, 36],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[941, 855, 955], {'pity': 89, 'guarantee': False}],
   {'results': 'L--', 'pity': 2, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('fault site guarantee grant #1',
   [[711, 926, 856, 59, 840, 978, 927, 160, 919, 993, 878, 579, 989], {'pity': 73, 'guarantee': False}],
   {'results': '---L---------', 'pity': 9, 'guarantee': True}),
  ('fault site guarantee grant #2',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression guarantee grant #1',
   [[811, 511, 897, 20, 849, 22, 758, 623, 891, 950], {'pity': 88, 'guarantee': False}],
   {'results': '-L--------', 'pity': 8, 'guarantee': True}),
  ('regression guarantee grant #2',
   [[835, 921, 31, 855, 841, 35, 966, 806, 957, 858, 42, 57, 921], {'pity': 88, 'guarantee': False}],
   {'results': '-L-----------', 'pity': 11, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Players can lose the featured coin flip repeatedly.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r < 500:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression featured coin #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('partial repair boundary #2',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression featured coin #2',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression featured coin #3',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('regression featured coin #2',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('regression featured coin #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[4, 981, 950, 937, 739, 13, 768, 921, 979, 2, 3, 996], {'pity': 89, 'guarantee': False}],
   {'results': 'F--------FL-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #2',
   [[711, 926, 856, 59, 840, 978, 927, 160, 919, 993, 878, 579, 989], {'pity': 73, 'guarantee': False}],
   {'results': '---L---------', 'pity': 9, 'guarantee': True}),
  ('regression featured coin #3',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4, 42, 253, 999, 775, 819, 42, 973, 811, 307, 835, 958, 247, 22], {'pity': 73, 'guarantee': False}],
   {'results': 'F-------------', 'pity': 13, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression featured coin #2',
   [[13, 897, 905, 973, 838, 47, 24, 42, 813, 832, 963, 957, 47, 811, 56, 994, 13, 928],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression featured coin #3',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4], {'pity': 73, 'guarantee': False}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity + 1
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 1:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('regression featured coin #2',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('partial repair boundary #2',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression featured coin #2',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression featured coin #3',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('regression featured coin #2',
   [[984, 954, 47, 297, 21, 192, 35, 1, 87, 521, 965, 945, 130, 990], {'pity': 72, 'guarantee': True}],
   {'results': '--F----L------', 'pity': 6, 'guarantee': True}),
  ('regression featured coin #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[4, 981, 950, 937, 739, 13, 768, 921, 979, 2, 3, 996], {'pity': 89, 'guarantee': False}],
   {'results': 'F--------FL-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #2',
   [[711, 926, 856, 59, 840, 978, 927, 160, 919, 993, 878, 579, 989], {'pity': 73, 'guarantee': False}],
   {'results': '---L---------', 'pity': 9, 'guarantee': True}),
  ('regression featured coin #3',
   [[346, 740, 973, 629, 933, 35, 831, 930, 214, 969, 923], {'pity': 73, 'guarantee': False}],
   {'results': '-----L-----', 'pity': 5, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4, 42, 253, 999, 775, 819, 42, 973, 811, 307, 835, 958, 247, 22], {'pity': 73, 'guarantee': False}],
   {'results': 'F-------------', 'pity': 13, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False})],
 [('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression featured coin #1',
   [[55, 51, 37, 985, 339, 849, 34, 33, 811, 935, 6, 3], {'pity': 66, 'guarantee': False}],
   {'results': '-------L---F', 'pity': 0, 'guarantee': False}),
  ('regression featured coin #2',
   [[13, 897, 905, 973, 838, 47, 24, 42, 813, 832, 963, 957, 47, 811, 56, 994, 13, 928],
    {'pity': 89, 'guarantee': False}],
   {'results': 'L-----------------', 'pity': 17, 'guarantee': True}),
  ('regression featured coin #3',
   [[860, 832, 950, 795, 21, 53, 128, 667, 5, 11, 16], {'pity': 0, 'guarantee': False}],
   {'results': '--------L--', 'pity': 2, 'guarantee': True}),
  ('partial repair boundary #1',
   [[4], {'pity': 73, 'guarantee': False}],
   {'results': 'F', 'pity': 0, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[911], {'pity': 73, 'guarantee': True}], {'results': '-', 'pity': 74, 'guarantee': True})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Low rarity rolls are almost always featured, biasing the fifty-fifty.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access