Counting walks with one matrix-entry query per iteration #
A starting block and a sequence of generated letters select a trajectory through an integer-weighted matrix. The evaluator walks through the blocks, their steps, and the columns of each row in a fixed order. Each iteration receives one lower-level entry as its answer and retains seven natural registers. The width represents the absorbing sink when its row has zero weight.
Main definitions #
SweepStatestores the current seed, generator position, column, current state, candidate, residual label, and number of successful seeds.sweepStartinitializes the first seed.sweepUpdateadvances the sweep by one entry query.
Main results #
iterate_sweepUpdate_hitsidentifies the final count with the number of walks reaching the specified destination.
Registers for the fixed-length sweep of starting blocks, generator steps and matrix columns.
- x : ℕ
Starting block index.
- t : ℕ
Position in the generated walk.
- j : ℕ
Current column, with markers for starting and ending a walk step.
- current : ℕ
State at the start of the step, with the width as sink.
- candidate : ℕ
First column that could still contain the label.
- residual : ℕ
Part of the letter index remaining after skipped columns.
- hits : ℕ
Number of completed starting blocks ending at the requested column.
Start the first walk from source, before reading its first letter.
Begin the scan of one generated letter at column marker n + 1 and end it at marker n.
The time marker len finalizes a starting seed. Marker iterations ignore the supplied entry.
Over all starting blocks, the sweep counts precisely those whose walk ends at dst. The
query count per block depends only on the width and length and includes the finalization steps.