S04 · Quantum & Scale · L-17

Bytecode Constant-Fold

Difficulty
expert
Type
implementation
Session
Deep
Stack
Python python3.11
Domain
Compilers
Est. solve
~35 min

01 · The task

Write the constant-folding optimization pass for a small bytecode IR, on top of the provided parser and evaluator. The catch is doing it safely — collapsing what is genuinely constant while leaving the program's observable behavior exactly as it was. Dead-code elimination is an optional, separately-scored bonus.

02 · Constraints

  • DCE is bonus

    Dead-code elimination is an optional, separately-scored extra.

03 · Skills exercised

compilersTransforming and analyzing program representations while preserving semantics.constant-foldingA compiler pass that evaluates constant expressions at compile time.ir-passesTransformations over a compiler's intermediate representation.

How to playDaemon

The whole level runs through the local promptly daemon — it pulls the workspace, captures your token usage, tests locally, and submits the ranked run.

  1. Pair this machine

    One-time — approve the code under your devices.

    promptly pair
  2. Pull the workspace

    Downloads the starter kit into constfold/ and starts the solve clock — cd in before the next step.

    promptly init constfold
  3. Start the captured session

    Then drive your AI tool — the daemon meters every prompt and token live.

    promptly start
  4. Submit for ranked grading

    Runs the full hidden suite and ends the attempt.

    promptly submit

Or combine steps 02–03 into one commandShortcut

promptly play pulls the workspace, launches the daemon, and starts the captured session in a single step — the same as running init then start. Then cd constfold and drive your harness.

promptly play constfold