- Backend engineer
- Junior
- 24 min
Parcel counts and boxed copies
Implement Trace. Create a ParcelCount from start, copy it and add delta to the copy. Box the original as IParcelCount and add twice delta through that interface. Return the original, copied and boxed values in that order. All arithmetic fits in int.
Skills and rubricParcel counts and boxed copies
- Assigning this struct copies its value, and boxing creates another copy. I would mutate each destination separately because neither operation gives the original shared mutable fields.
- With start 5 and delta 3, the values are 5, 8 and 11. A zero delta preserves all three, while a negative delta reduces only the two copies.
- Trace a concrete input, then compare the expected value with the actual workspace result.