zhie file-size optimization log

Objective and final result

The first accepted input was 1,688 bytes. After the first solve, the objective
changed from “make the program return 0” to “make the smallest file that still
returns 0.” A leaderboard reference of 1,341 bytes supplied a concrete target.

The final artifact found during this effort is:

1
2
3
4
5
6
file      solution.bin
size 1241 bytes
sha256 6374f98191da0da09717d3e231fbd998749b61a2d6b880be9d687bafd445b17d
exit 0
margin 100 bytes smaller than 1341; 8 bytes smaller than the live 1249 best
submit accepted for littleTT in slot 55, rank 1 at submission time

This document records both successful reductions and hypotheses that were
tested and rejected. “Closed” below means the stated family was exhausted on
the cited baseline, not that 1,241 is a mathematical global optimum over every
possible game route.

1. Measurement and safety rules

The byte metric fed to the round scorer is the raw input size, not the size of
the hexadecimal text file. The overall KOH score is separate: each closed slot
scores the best valid file stored for a team in that slot, and the total board
sums those round scores. Menus make byte deletion parser-sensitive, so
optimization always operated on the structured grammar:

  • ordinary coordinate action: 1 byte;
  • C1-C6 menu: command byte + choices + FF;
  • C7 teleport: 2 bytes.

Every accepted candidate was run through the real zhie executable and kept
only if the exit status was exactly 0. Intermediate winners were saved under
size- and hash-qualified names. Important milestones were also rechecked in an
independent container, and the final solution.bin passed in a fresh read-only
linux/amd64 container before it was uploaded.

2. Optimization tools

Several complementary minimizers were built because no one search captures
all dependencies in a resource-management route.

Tool Search performed
minimize_solution.py Raw delta debugging plus shifted sliding-window deletion.
optimize_runtime.py Command-aware ddmin, menu-choice ddmin, reverse and forward greedy deletion.
semantic_optimize.py Merge equal menu sessions; replace C3/C4 attack+defense pairs with stronger one-byte bundles, including cross-session pairs.
upgrade_substitute.py Add/move/swap shop choices, close each neutral or stronger branch with deletion passes, and persist winners.
trace_special.py, trace_range.py Attribute every command to a floor and record resource/stat deltas.
scan_teleport_trips.py Delete or collapse spans bounded by teleports.
scan_key_deletions.py Remove key pickups, key/fight pairs, and key-shop choices.
scan_action_intervals.py Test contiguous route intervals that single-command deletion cannot expose.
mutate_actions.py Replace a coordinate action by every other currently reachable boundary target, then rerun full deletion/menu closure.

The real binary remained the oracle throughout. The scripts’ internal stat
models were used to rank candidates, never to declare success.

3. First reductions: 1,688 to roughly 1,450

3.1 A shorter assembled baseline: 1,623

The 1,688-byte route was intentionally safe and collected excess healing. An
independently assembled endgame used the stronger static_f24_keyboxes
checkpoint followed by compact clear/flag/final suffixes. That route was 1,623
bytes and also exited 0. It became the practical baseline for command-aware
minimization.

3.2 Generic deletion and menu-choice pruning

Raw and structured ddmin immediately found large slack:

  • one branch reached 1,543 bytes;
  • the parallel generic pass reached about 1,540, then 1,538;
  • exact final-shop pruning produced 1,516 and then 1,513 on the stat-tuning
    branch;
  • semantic and deletion branches converged around 1,500-1,480.

These gains were mostly redundant potions, optional actions, over-provisioned
shop choices, empty menu frames, and contiguous spans that were not discovered
by isolated one-byte deletion.

An early operational failure is worth recording: a Docker restart discarded
temporary candidates. Subsequent searches wrote every accepted checkpoint to a
persistent, isolated output directory. Multiple oracle processes also fought
over the same tracing setup, so probes were serialized with a lock.

3.3 Menu merging and EXP bundles

The stream invoked the same global shops many times. Hoisting or sinking their
choices into one session removes two framing bytes (C? and FF) each time the
intermediate timing is not required.

The first semantic pass:

  • merged four adjacent key-shop sessions and deleted an empty session;
  • moved purchases between compatible sessions;
  • reached 1,546 and then 1,536 before the next generic closure.

The EXP shops offered a second compression:

  • C3 attack + defense: two 30-EXP choices for +5/+5;
  • C3 bundle: one 100-EXP choice for HP and +7/+7;
  • C4 attack + defense: two 95-EXP choices for +17/+17;
  • C4 bundle: one 270-EXP choice for 3000 HP and +20/+20.

Although a bundle costs more EXP, it saves one input byte and is stronger. A
frozen 1,484-byte candidate accepted two bundle rewrites, becoming 1,482. The
extra stats then made late setup actions removable:

1
1482 -> 1476 -> 1471 -> 1468 -> 1452

Re-running bundle conversion after deletion found eight more pairs and reduced
1,452 to 1,444 before another closure.

4. Structural compression: teleports and route topology

The event trace showed that the first solution repeatedly climbed unlocked
floors manually. C7 can teleport to an already unlocked floor in two bytes.
Replacing stair runs was much larger than another round of byte deletion.

Notable structural checkpoints were:

1
2
3
4
5
1448  stat-tuned checkpoint
1406 first combined teleport build
1359 nine compatible teleport substitutions
1357 menu/bundle merge on that route
1332 five partial-run teleports combined

The “partial-run” detail mattered. A rejected teleport often tried to jump one
floor above the current unlock ceiling. Teleporting to the highest unlocked
floor and retaining only the final one or two stairs succeeded. This is what
finally crossed the 1,341 reference: 1,332 bytes.

Whole-loop and whole-trip deletion was then tested, not assumed:

  • complete inter-floor loops could not be removed;
  • broader detours whose destination was already unlocked also failed;
  • later, all 256 remaining teleport-span collapses on the compact route failed.

Thus the successful teleport savings came from compressing traversal, not from
skipping mandatory state-changing excursions.

5. Shop and resource allocation: 1,339 to 1,284

5.1 Late-shop proof-preserving rewrite

The trace showed spare EXP and gold at victory. A coupled late-shop transform
moved ten final C4 defenses into earlier C4 bundles, funded the EXP by moving
selected attacks to the gold-funded C2 shop, and retained the needed final
defense. It improved HP, attack, and defense while reducing choice bytes.

This produced 1,339 bytes on one route, two bytes below the leaderboard. The
same transform was compatible with the 1,332 teleport route and produced
1,324.

Further session merging and cross-session C4 bundling produced:

1
1324 -> 1311 -> 1300 -> 1299

The 1,300 route used 22 C4 bundles plus a compact C2 attack/defense split. An
exhaustive neighboring split found 1,299; every possible next-shorter
65-choice attack/defense allocation failed on that baseline.

Generic closure and recombination continued:

1
1299 -> 1295 -> 1293 -> 1292 -> 1288 -> 1285 -> 1284

The 1,293-byte route had enough extra EXP for an exact one-byte compression:
replace one final C4 attack plus one C2 defense with one C4 bundle. On the
1,285 structural route, the final successful allocation became 1,284 with:

1
2
C4: 22 bundles + 1 attack
C2: 18 attacks + 56 defenses

All next-shorter 73-choice C2 splits failed. Menu merging, local and
cross-session bundling, and pure-HP pickup deletion were closed on this route.

6. Multiplier and F20 economic searches

The floor-0 event applies a 4/3 stat multiplier. This made the timing of shop
choices important: a byte spent before the multiplier can be more valuable
than the same byte spent afterward.

6.1 Attempt to defer the multiplier: failed

Moving or removing the multiplier trip was attractive because it looked like a
detour. It failed at the next mandatory F20 action 57, which opens the route
to floor 21 only with sufficient pre-buff stats.

This family was exhaustively closed:

  • moving the multiplier only to F20 entry worked but added 3 bytes;
  • no resources were collectible between the original event and the gate;
  • 576 ordinary shop allocations failed;
  • selling all 11 keys and testing 630 Pareto-maximal allocations failed;
  • even the all-key-sale maximum reached only defense 2586 and never unlocked
    the gate.

6.2 F20 spoke removal: successful once, blocked in larger combinations

F20 contained symmetric two-command fight/resource spokes. Removing one spoke
lost 92 gold and 80 EXP, so it had to be coupled with shop changes:

  • buy one fewer pre-buff defense;
  • convert two pre-buff attacks into one bundle;
  • drop one later bundle;
  • replace the missing stats with affordable late gold choices.

All four symmetric one-spoke variants cleared and gave 1,282. Moving more
bundles before the multiplier and rebalancing all four shops improved this to
1,279 with final attack 4003 and defense 5002.

Attempts to remove two or more spokes were explored. They failed from exact EXP
or pre-final survival limits (one candidate missed by only 5 HP). Later F20
single-action, all contiguous-interval, and “leave the floor early” suffix
tests also failed.

7. Global path/resource substitutions: 1,279 to 1,265

7.1 Global four-shop allocation and final orb pair

A no-spoke allocation also achieved 1,279 but with 18 extra attack and 11 extra
defense. That slack made a final fight-plus-stat-orb pair unnecessary, yielding
1,277.

7.2 Remove the F10 trip and its key purchase

A seven-byte F10 visit existed only to open a red door and collect +3 attack
and +9 defense before the multiplier. Because the shops are global, the whole
trip could be deleted and the stats bought more compactly. Re-solving all four
shops gave 1,272.

The deleted red door left one purchased red key unused. Removing that C5
choice gave 1,271. A subsequent direct +3-defense pickup deletion produced
1,270; its large final-HP cost was still survivable.

7.3 Replace pickups by one late defense purchase

Five separate +3-defense pickups cost five action bytes. One C2 defense choice
gave +20 defense in one choice byte. After timing/resource validation this
exchange removed three net commands and reached 1,267.

A five-byte F2 side trip was also investigated. It supplied the yellow key for
the immediately following door, so plain deletion failed. Replacing the trip
with a framed key-shop purchase saved too little once the lost resources and
menu framing were included; it did not become the final path.

7.4 Reachable-target mutation at F25

Changing one legal F25 target from AA to 78 made the later 8A action
redundant. This yielded 1,266 but cost three defense. A zero-byte shop swap
recovered defense while preserving attack, after which the neighboring 7A
defense pickup was removable. The result was 1,265 with attack 4002 and defense
5001.

8. Final interaction shortcuts: 1,265 to 1,261

At this point direct deletion, generic semantics, key scans, and teleport scans
were nearly closed. The remaining gains came from equal-size legal target
substitutions that made a later action redundant
.

8.1 Two independent 1,264-byte routes

One F20 route changed a pair of actions (9A AA) into a single target (40)
and removed two adjacent actions elsewhere, producing a 1,264-byte checkpoint.

An independent route changed 69 -> 5A, which made a later 5A redundant.
That also produced 1,264.

The two shortcuts stacked cleanly. Applying the second transform to the first
gave 1,263.

8.2 1,263 to 1,262

On the combined route, the neutral substitution 96 -> A5 made the later A5
action redundant. Deleting the duplicate produced 1,262.

The other tested neutral substitutions in that corridor, including 49 -> 3A,
remained the same size after full forward/reverse deletion closure.

8.3 1,262 to 1,261

The final improvement was another target substitution on F20:

1
2
offset 927: 16 -> 05
delete old offset 936: 05

The first action now took the red-key target immediately, so the later red-key
action became redundant. The route intentionally carried one fewer black key
through the segment but still had exactly enough keys to finish.

combine_1262_shortcut.py reproduces this exact
transform and asserts both source and destination hashes.

9. Exhaustive searches that did not improve the winner

9.1 Parser and malformed-input audit

The input parser was checked for a direct-victory exploit before spending all
effort on the intended route. No useful bounds, EOF, menu, teleport,
coordinate, BFS-queue, or integer-overflow bug was found.

Static analysis identified exactly two success handlers: the hard F26 boss and
the weakened flag-generated boss. Exhaustive legal F24 shop allocation could
not defeat the hard boss, and the two critical weakening flags each had a
single dedicated writer. Consequently, malformed commands could not forge the
victory state or skip the flag route.

The only useful parser quirk was legitimate: global remote C1-C7 commands,
which the route already exploited.

9.2 Early-shop timing families

The compact late route made early timing extremely tight. The following were
tested:

  • all 1,022 stat-preserving C1-to-C2 subsets on the relevant bases: no winner;
  • all timing-distinct C3-to-C4 triplet substitutions (179 unique serialized
    candidates from the enumerated triplets): no winner;
  • 80 individual early stat-to-HP conversions: no winner;
  • 121 individual same-cost attack/defense flips: no winner;
  • paired flips: 11 equal-size variants survived, but none enabled a stat-pickup
    deletion.

The most promising hand-derived rewrite moved attacks across the F13 C2 / F14
C4 boundary to fund bundles. It was stronger after F14 but died in the short
interval where defense was delayed. The widened exhaustive search considered:

  • 77 C2 HP/attack/defense states that survived to C4;
  • all affordable shorter C4 bundle/attack/defense allocations;
  • 5,607 Pareto-maximal combined candidates.

None cleared the full level.

9.3 Structural/key families

On the compact route, the following all failed:

  • every positive-key pickup deletion;
  • pickup/fight pair deletions;
  • remaining key-shop deletions;
  • all 256 teleport-span collapses;
  • F20 single actions and contiguous intervals;
  • late-corridor intervals up to 24 actions after rebasing;
  • whole F24 symmetric farming arms and their compensated shop variants;
  • the proposed five-byte F15-to-F17 farm trade after accounting for the C2/C4
    choices it funded.

Key selling was also unattractive. C6 sells yellow/blue/red keys for 7/35/70
gold, but the sale choices and required menu framing cost input bytes; no
shorter compensated route resulted.

9.4 Final deletion and mutation closure

The 1,261-byte winner passed a full structured closure:

  • command-level ddmin;
  • menu-choice ddmin;
  • reverse greedy deletion;
  • forward greedy deletion;
  • another menu and ddmin pass;
  • 6,601 oracle probes, zero accepted deletions.

The exact 1,261 baseline was then partitioned for every reachable-target
substitution:

Byte range Actions Probes Result
[0,350) 278 11,201 Two equal-size winners at offset 242; both closed at 1,261.
[350,700) 284 13,168 Two neutral winners; both closed at 1,261.
[700,900) 101 4,667 One neutral winner at offset 827; closed at 1,261.
[900,1100) 122 4,058 No winner below 1,261 after rebasing.
[1100,end) 57 2,317 No winning substitution.

The original 1,262 pass over [900,1100) used 7,029 probes and was the pass
that discovered the final 16 -> 05 shortcut. Re-running the same partition on
1,261 was necessary because the mutation runner intentionally keeps a fixed
baseline during one pass.

10. Renewed target: 1,253, then the live 1,249 best

After the 1,261 route was completed, another team reported 1,253 and the live
board later moved to 1,249. This changed the required search scale: another
one-byte target substitution was unlikely to be enough, so the next phase
looked for coupled economic and parser changes that could unlock several
deletions at once.

The ordinary subprocess oracle was replaced by an amd64 state forkserver. It
recorded the exact floor, caller, position, HP, attack, defense, currencies,
keys, flags, and map after any prefix. This made three clues decisive:

  • the final boss has HP=99999, ATK=5000, and DEF=4000;
  • floor 26 applies two unavoidable HP -= floor(HP/3) hazards;
  • the clean zero-damage boundary is hero ATK > 4000 and DEF >= 5000, so
    the minimum clean-win stat sum is 9,001.

Several candidates ended with HP -1. That first looked like a one-point
near-win, but the trace showed it was merely the remainder after repeated boss
attacks. Increasing attack alone therefore was not a useful objective: a route
also needed defense near 5,000 or an impractically large post-hazard HP pool.

11. Post-1,261 attempts that did not become the final route

11.1 Structural and topology closure

A diagnostic preload with effectively unlimited HP, currencies, and keys
separated topological requirements from economic ones. It made 261 commands
removable; a smaller resource boost made 70 removable. Those commands were not
intrinsically required by the map, but the real route needed their temporary
HP, keys, rewards, or shop timing.

Several broad structural searches were then closed:

  • replace raw windows of widths 2 through 11 by one action; the width-2 pass
    alone tested 322,560 rewrites;
  • replace windows of widths 11 through 24 by a two-byte C7,floor teleport;
    452,998 candidates produced no winner;
  • exact one- and two-coordinate state splicing tested 234,156 routes;
  • full-map/control-state and depth-three splicing found shorter matching
    checkpoints, but no candidate could replay the entire suffix;
  • 48 explicit-to-implicit menu merges and 722 deferred-session variants also
    failed.

The clue from these failures was that equal floor, position, inventory, and
visible stats were insufficient. Some earlier actions perform remote map
writes whose consequences are consumed much later.

11.2 Direct parser and session compression

The route contains explicit shop frames plus six byte spans that the game
interprets as implicit menu sessions. All 644 ordered same-mode merges across
those sessions were replayed on the canonical route; none won. A broader
hidden-C4 search tested 627 affordable allocations and also produced no
candidate at or below 1,252.

This negative result was still a clue: menu merging was not intrinsically
exhausted. It was exhausted only for the old stat timing. A preceding economic
rewrite might make several of the same merges legal.

11.3 Topology-splice repairs

The most promising early splice saved ten bytes while trading about
-60 ATK,-80 DEF for roughly 700 gold. A wider 26-byte shortcut skipped a
floor-4 trigger that remotely opens a floor-2 door, so repair required both a
red key and the minimum trigger corridor.

The strongest repaired route reached F19 at 1,251 bytes and failed the next
mandatory fight with only HP=-5, ATK=1503, DEF=1600. Dual-shop repairs,
hidden-C4 funding, C1 relocation, targeted resource variants, every one-byte
extension of existing C1-C4 menus, and nearby coordinate insertions all
failed. This branch made the remote-map dependency concrete and redirected the
search from pure topology to purchase timing.

11.4 Late pickups, shop allocations, and final-tail repairs

The late route was audited command by command. Nineteen weak stat pickups were
tested individually and in resource-compensated subsets. The principal modeled
1,253-byte frontier contained 2,517 allocations, but every real replay failed
before the boss. Coupled action deletion/insertion, local reachable-target replacement,
F24 farming-arm removal, and final C2/C4 allocation searches reached the same
constraint from different directions: bytes could be freed, or the stat sum
could be retained, but not both with the currencies available at that time.

The best attack-heavy final-tail near miss had ATK=4038, DEF=4513. It
confirmed the boss model: attack was now sufficient, but retaliation was far
too large. Exact endgame grids, equal-split searches, and late-shop rebalancing
could not raise defense to 5,000 within 1,252 bytes.

11.5 Early HP/stat and multiplier timing

Early C2 HP choices were tempting conversion targets because one HP byte could
be replaced by a stat byte. They were actually survival-tight:

  • changing one HP choice into two defense choices died on F17 action 18 by
    95 HP;
  • converting three to defense died in the first F12 fight by 143 HP;
  • no tested single HP-to-stat conversion completed the route.

The floor-0 multiplier and fairy were also retested. The fairy is one-shot,
and postponing the multiplier made the F21 gate unwinnable. These failures
closed the apparent “repeat the buff” and “buy everything before the buff”
shortcuts.

11.6 F19 and F17 timing branches

One compact F19 branch reached a mandatory fight with HP=-5, ATK=1503,
DEF=1600 at 1,251 bytes. Every one-byte extension of the existing C1-C4
menus, plus coordinate and movement insertions around that checkpoint, failed
to repair it.

A more useful F17 clue came from staging EXP bundles around reward actions.
Buying two C4 bundles after action 11, taking 10 20 A0, then buying a
third before A2 reached floor 26 in 1,248 bytes. Moving the rewards before
the shops let all five nearby C2 choices become stats. The best serialized
segment was:

1
2
3
4
5
C2 01 02 02 02 02 FF
C4 00 FF
11 10 20 A0
C4 00 00 FF
A2

That route ended with HP=31040, ATK=3652, DEF=5083 (total 8,735). It
was much stronger per byte than the original local ordering but still 266
total stats below the clean boss boundary.

An attempt to merge four earlier C4 sessions would have saved six framing
bytes. Although 2,244 EXP was already present, C4 was still locked on F12 and
at initial F13 (status=12 at caller 0x13d2). This located the real shop
unlock boundary: the merged purchase had to remain after the later max-floor
event, so the attractive early frame deletion was invalid.

12. State-preserving minimization and the false promise of headroom

Greedy prefix-state replay found seven genuinely redundant ordinary actions in
the 1,248 timing branch. Removing them produced
runtime_opt_candidates/final-reach-min-strict.bin, only 1,241 bytes, with the
same non-winning ATK=3625, DEF=5110 total of 8,735. A looser pass reached
1,117 bytes and still arrived at the boss corridor, but its final
ATK=3015, DEF=3414 showed that it had discarded too much economy to repair.

The 1,241 strict route appeared to leave eleven bytes under the 1,252 target,
but resource accounting disproved that shortcut:

  • the gold shops had only 108 spare gold, enough for one additional C2 stat
    choice (+20);
  • the relevant EXP shops had roughly 18 spare EXP;
  • re-bundling the combined C4 purchases with 0 through 11 extra bytes yielded
    best marginal pre-multiplier gains of
    0,-6,+11,+5,-1,+16,+10,+27,+21,+38,+32,+49.

Thus eleven free bytes did not represent eleven affordable upgrades. The route
needed a change that simultaneously altered purchase timing, stat balance, and
parser-frame legality.

13. Successful cross-tier compression: 1,261 to 1,241

The final breakthrough returned to the canonical 1,261 winner rather than the
non-winning 1,241 timing branch.

13.1 Couple an early deletion to a later C3 bundle

The singleton early frame at original offsets [289,292) was:

1
C3 02 FF

Deleting it saved three bytes and one +5 DEF purchase. In the later C3
session at original offset 430, the payload was three attacks and two defenses:

1
C3 01 01 01 02 02 FF

Replacing two attack choices by the stronger bundle produced:

1
C3 00 01 02 02 FF

That saved one more byte. Across both edits, the route spent 10 additional EXP
and changed the final balance by -3 ATK, +2 DEF. It survived every
intermediate fight, which was the clue that this cross-tier purchase could
replace the deleted early timing requirement.

13.2 Restore the exact boss balance without adding bytes

Two later same-length flips restored the sharp attack threshold:

  • original offset 814: C2 defense to C2 attack (+20 ATK, -20 DEF);
  • original offset 819: C4 attack to C4 defense (-17 ATK, +17 DEF).

Together they contributed +3 ATK, -3 DEF. Relative to the 1,261 winner, the
combined route therefore retained attack exactly and spent only one point of
defense margin: 4001/5004 -> 4001/5003. The seed was 1,257 bytes and already
exited 0.

13.3 The timing change unlocks eight menu merges

Re-running semantic session merging on that 1,257-byte seed accepted eight
rewrites that had failed on the old route:

1
2
3
4
5
6
7
8
1257 -> 1255  hoist C3 298 -> 307
1255 -> 1253 sink C3 190 -> 200
1253 -> 1251 sink C1 185 -> 201
1251 -> 1249 sink C3 226 -> 240
1249 -> 1247 hoist C3 315 -> 330
1247 -> 1245 sink C3 315 -> 333
1245 -> 1243 sink C3 328 -> 383
1243 -> 1241 sink C2 444 -> 522

Each merge moved the later payload into an earlier or later same-shop session
and removed one command byte plus one FF. The four-byte economic rewrite had
therefore unlocked another sixteen parser bytes, producing the final 20-byte
improvement.

The resulting terminal state was:

1
2
3
4
HP=31042  ATK=4001  DEF=5003
gold=949 exp=857
keys=(4,0,0)
floor=26 flags=(1,1,1,0)

The instrumented oracle returned success, the ordinary binary returned exit
0, and a fresh read-only linux/amd64 container returned exit 0. The server
then accepted the 1,241-byte file for littleTT in slot 55 and recorded it as
the round’s best file.

14. Size milestone summary

The main stable milestones were:

Size Main reason for reduction
1688 First safe walkthrough-derived solution.
1623 Shorter assembled route/endgame baseline.
1543-1540 Generic command and menu-choice deletion.
1513 Exact final-shop pruning on one branch.
1482 First higher-tier bundle rewrites.
1452 Bundle surplus plus shifted-window deletion closure.
1444 Eight more C4 pair-to-bundle rewrites.
1406 First major stair-run teleport compression.
1359/1357 Nine teleports, then semantic merging.
1332 Five compatible partial-run teleports; first below 1,341.
1324 Teleport route plus late-shop transform.
1311 Delayed/merged shop sessions and cross-session bundles.
1300/1299 Compact 22-bundle final allocation and exact boundary search.
1295/1293/1292 Generic deletion plus one exact cross-resource bundle.
1288/1285/1284 Stronger structural bases plus final-shop rebalance.
1282 One compensated F20 spoke removed.
1279 Multiplier-aware four-shop allocation.
1277 Remove final fight/stat-orb pair.
1272 Delete entire F10 stat/key detour and reallocate shops.
1271 Remove the now-unused red-key purchase.
1270/1267 Drop weak defense pickups; replace five with one C2 defense.
1266/1265 F25 target shortcut, zero-byte stat rebalance, delete 7A.
1264 Two independent F20/reachable-target shortcuts.
1263 Stack both 1,264-byte shortcuts.
1262 96 -> A5, delete later A5.
1261 16 -> 05, delete later 05; previous canonical winner.
1257 Delete early singleton C3 defense; cross-tier C3 bundle; exact late A/D flips.
1241 Eight newly legal same-shop session merges remove 16 framing bytes.

15. Attempt index by retained script

The workspace contains many one-purpose scripts created while testing the
hypotheses above. This table records what each was for, including searches that
did not produce a final checkpoint.

Script Attempt and result
make_late_defense_variant.py Insert a late C2 defense choice. Crossing the boss-defense threshold eliminated retaliation and unlocked a large deletion cascade, including a 1,423-byte checkpoint.
late_shop_search.py Move late EXP defense into bundles and shift attacks to gold. This was the family that produced the 1,339 late-shop breakthrough and combined with the teleport route at 1,324.
shop_coupled_search.py Enumerate coupled C2/C4 rewrites in the dense floor-10 shops, including defense-preserving bundle funding. Useful survivors fed the semantic ladder; no separate final route remained better after recombination.
final_shop_search.py Exhaust compact final C4/C2 allocations. It found the 22-bundle family and proved adjacent shorter gold-choice splits invalid on the tested bases.
hp_pickup_search.py Test whether bundle-created HP surplus could delete pure healing pickups. No further gain at the closed 1,284 layer.
f20_economic_transform.py Apply each symmetric one-spoke F20 deletion together with its pre-/post-multiplier shop compensation. All four variants worked at 1,282.
optimize_f20.py Grid-search the four relevant shop payloads around F20 and the multiplier. It produced/validated the 1,279 allocation families.
global_shop_optimize.py Jointly remove the F10 trip, solve the four shops, remove the final orb pair, and drop the now-unused red-key purchase. This drove 1,279 to 1,277, 1,272, and 1,271.
defer_multiplier_probe.py Move the 4/3 multiplier later. Only a three-byte-longer placement worked; the mandatory F20 gate blocked every useful deferral.
prebuff_encounter_search.py Enumerate 576 ordinary shop allocations in the unbuffed pre-gate state. None opened F21.
prebuff_key_sale_search.py Sell every key and enumerate 630 Pareto-maximal allocations. None passed the unbuffed gate.
early_tier_search.py Delay C1 purchases to C2 and C3 purchases to C4 to exploit higher byte efficiency. All shorter stat-preserving variants failed.
c3_triplet_search.py Specifically replace timing-distinct groups of three C3 singles with one C4 single. No full-route winner.
early_hp_variants.py Replace one early attack/defense purchase with an equal-cost HP choice. All 80 candidates failed.
early_stat_flip.py Flip each early attack choice to defense or vice versa. All 121 single flips failed.
early_pair_flip.py Swap two choices so total stats/currency remain fixed but timing changes. Eleven variants survived at equal size.
pair_stat_delete.py On those eleven timing variants, delete every pure attack/defense pickup. No smaller winner.
early_coupled_bundle.py Hand-derived one- and two-byte C2/C4 boundary compression. Both forms died during the temporary defense deficit.
early_boundary_exhaustive.py Exhaust the widened F13/F14 boundary: 77 surviving C2 states and 5,607 Pareto-maximal complete candidates, all unsuccessful.
scan_key_deletions.py Delete key pickups, dependent fights, and key-shop choices. No gain on the compact route.
scan_teleport_trips.py Collapse every remaining teleport-bounded span. All 256 candidates failed.
scan_action_intervals.py Delete F20 and late-corridor intervals, including suffix-like exits. No surviving reduction.
rebalance_1266.py Apply a zero-byte A/D shop rebalance after the F25 shortcut; this made 7A removable and produced 1,265.
combine_1264_shortcuts.py Stack the two independent 1,264-byte target/deletion shortcuts to produce 1,263.
combine_1263_shortcut.py Apply 96 -> A5 and remove the later A5, producing 1,262.
combine_1262_shortcut.py Apply 16 -> 05 and remove the later 05, producing the previous 1,261-byte winner.
diagnostic_delete_scan.py, structural_raw_reduce_fast.py, teleport_window_reduce.py Separate economic from topological actions, then exhaust raw-action and teleport window replacements. Hundreds of thousands of shorter serializations failed real suffix replay.
two_action_splice_search.py, topology_splice_search.py, three_action_fullmap_splice.py Match prefix/suffix states with one-, two-, and depth-three splices. Matching visible state did not preserve hidden remote map writes.
early_splice_repair_search.py, early_splice_dual_shop_search.py, early_splice_targeted_search.py Repair the compact early splice with shops, keys, and trigger corridors. Best result reached F19 at 1,251 bytes but died by five HP.
funded_shop_insert_search.py, hidden_c4_funding_search.py, close_menu_mutation_search.py Try local funding, hidden-shop, insertion, and menu mutations around near-routes; no exit-0 candidate at the target size.
implicit_menu_merge.py, implicit_bundle_search.py Model explicit and implicit parser sessions. All 644 direct ordered merges and 627 broad hidden-C4 allocations failed on the unmodified 1,261 route.
structural_raw_reduce.py, structural_raw_reduce_fast.py, minimize_final_reach.py Delete commands while preserving progressively weaker checkpoints. The strict timing branch reached 1,241 with unchanged but non-winning 8,735 total stats; the 1,117 loose branch discarded too much economy.
grouped_late_pickup_bound.py, prelate_pickup_search.py, endgame_coupled_delete_search.py Bound and replay weak late-pickup deletions with compensated shops. Nominal 1,253 frontier rows all failed in the real game.
endgame_equal_split_search.py, final_boss_shop_rebalance.py, final_boss_late_shop_search.py, final_boss_coupled_tail_search.py Exact boss-aware C2/C4 and tail allocation searches. Attack-heavy candidates still lacked enough defense to survive retaliation.
c2_hp_conversion_subset_search.py, audit_hp_flips.py Convert early HP choices to stats. Every tested conversion violated an earlier survival checkpoint.
repeat_multiplier_probe.py, delayed_multiplier_probe.py Test repeated fairy use and later multiplier timing. The fairy was one-shot; delaying the multiplier blocked the F21 gate.
late_f19_shop_split_search.py, late_f19_timed_shop_search.py, f19_hp5_repair_search.py Split late shops around F19. The strongest compact near miss was five HP short at a mandatory F19 fight, and local one-byte repairs failed.
search_split_bundle.py, search_dual_split_bundle.py, f17_reward_shop_timing_search.py Stage C4 bundles around F17 rewards. Produced the 1,248-byte, 8,735-total-stat route that enabled the state-preserving minimization study.
merge_early_c4_search.py Merge four early C4 frames to save six bytes. All 21,960 allocations failed because C4 was still locked before the later max-floor event.
build_f19_f24_1252.py Spend the strict route’s nominal 11-byte headroom across F19/F24 shops. The candidate consumed EXP too early and failed on F15.
semantic_optimize.py After the cross-tier C3 rewrite and late A/D flips, accept eight session merges and reduce the verified 1,257-byte seed to the final 1,241 bytes.

16. Reproducing and verifying the final artifact

build_solution.py checks the expected size and SHA-256
before writing solution.bin and solution.hex:

1
2
3
4
python3 build_solution.py
sha256sum solution.bin
./zhie solution.bin
echo $?

Expected result:

1
2
3
1241 bytes
6374f98191da0da09717d3e231fbd998749b61a2d6b880be9d687bafd445b17d
exit 0

The final traced state was:

1
2
3
4
HP=31042  ATK=4001  DEF=5003
gold=949 exp=857
keys=(4,0,0)
floor=26 flags=(1,1,1,0)

The remaining HP and currency do not imply a trivially removable byte: the
route is constrained by when resources become available, mandatory corridor
objects, key dependencies, parser framing, and the sharp final attack/defense
thresholds. The failed searches above are the attempts made to convert that
apparent slack into a shorter valid command stream.