๐Ÿ”ฌ Science

Readings, One at a Time

Stardate 55144.4 ยท UES Magnanimous

Briefing

The other Magnanimous kept everything. Its sensor log is nineteen years long and Lt. Skree does not want it in memory all at once; Skree wants to walk it, one reading at a time, stopping whenever the pattern shows up.

Build a sequence that produces readings on demand: a start value, a step, and a count. It should hand out one value when asked and not before, so that asking for the first three of a million costs three. Skree describes this as "the difference between reading a book and being hit with it".

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขProduces start, start+step, ... for exactly count values
  • โ€ขA count of zero produces nothing
  • โ€ขIt is lazy: values come one at a time on demand, not as a prebuilt list
  • โ€ขThe first three of a million cost three
  • โ€ขIt composes: the values can be doubled with a standard adaptor
Ask Commander Raghunathan for a hint

Python: yield inside a loop makes a generator, and generators are lazy by nature. Rust: a struct holding current, step and remaining, and impl Iterator with a next that returns None when nothing remains.