Immutable updates and persistent data

F-IMMUT-V4-2medium

Add a hotel night

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

What needs to change

Repair with_nights so the planned trip keeps its hotel nights.

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: up to 50 city days hotel nights trips, one per record. 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