๐Ÿ“ฆ Ops

The Manifest

Stardate 55118.4 ยท UES Magnanimous

Briefing

Forty crates were loaded at Starbase 11 and the cargo manifest's total mass field now reads, in full, "crate". Chief T'Kala, who signs for cargo and takes signing seriously, has declined to sign for a mass of "crate".

Ensign Tannenbaum's summing routine, on inspection, adds the first crate to itself forty times and then, for reasons that remain unclear, formats the result as its own name. The Chief would like a number. Any number, provided it is the right one.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขFour crates add up correctly
  • โ€ขA single crate is its own total
  • โ€ขAn empty hold has a mass of zero
  • โ€ขForty identical crates
  • โ€ขLarge masses do not lose anything
Ask Commander Raghunathan for a hint

A running total: start at zero and add every crate. Both languages have a one-liner for this (sum, .iter().sum()), and it is worth writing the loop by hand once first.