Prototype parses one line. Trim only ASCII space and tab at each edge. Empty lines or lines whose trimmed first character is # return nullopt. Otherwise split at the FIRST =, trim key and value, require a nonempty key consisting only of ASCII letters/digits/underscore. Empty values and additional = inside a value are valid. Invalid syntax throws invalid_argument. Return owned strings. Final loads lines into an ordered map, ignoring blank/comment lines and rejecting duplicate keys (case sensitive). Preserve input; fresh calls share no state. Keep header definitions inline or otherwise ODR-safe.

C++ contract conventions: numeric values use signed Int (long long); all inputs and intermediate arithmetic are within its representable range. Opt<T> means std::optional<T> and absence is std::nullopt; Vec<T> means std::vector<T>. Invalid documented arguments throw std::invalid_argument. Inputs passed by const reference remain caller owned. Returned containers and records own their contents. No runtime type coercion is required; C++ static types exclude many dynamic-language type errors. Unless a lesson states otherwise, string ordering is lexicographic over Unicode code points (Text) or UTF-8 identifiers (std::string).

cpp

inline Opt<std::pair<std::string,std::string>> prototype(std::string_view line);
inline std::map<std::string,std::string> solve(std::span<const std::string> lines);

Compile and run from this directory:

Shell
c++ -std=c++20 -O2 -Wall -Wextra -pedantic -pthread main.cpp -o practice
./practice --stage prototype
./practice --stage final

Edit exercise.hpp. Both stages start unfinished and must report failures until implemented. Keep main.cpp as the executable contract. The runner returns nonzero for a failed check, an unexpected exception, an invalid stage, or an empty suite. C++20 and only the standard library are required.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

C++ runtime powered by Wasmer.