Immutable updates and persistent data

F-IMMUT-V4-3hard

Undo plan edits

A trip planner updates days and hotel nights and keeps earlier plans for undo.

What needs to change

Repair plan so undo restores every earlier plan, hotel included.

Reproduce

  1. The starter does not compile; read the diagnostic before changing the code.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its imports, read_lines, the Hotel and Trip structs, parse and the complete main.

Input: one starting city days hotel nights plan, then zero to 50 edits, one per record: days N, nights N or undo. Undo with no retained edit is a no-op. Use nonempty LF/CRLF records with ordinary spaces or tabs between fields. City and hotel names are opaque non-whitespace UTF-8 tokens of at most 100 Unicode scalar values; numeric-looking names remain strings. Durations are unsigned decimal counts from 0 to 1000, including leading-zero spellings. The supplied readers receive valid bounded data; they do not validate these rules.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in