# usaco reset/rm/delete/template/tpl [-y] [[ $# -ge 1 ]] || usage dir="$(find_problem "$1")" name="$(basename "$dir")" io="$(detect_io "$dir" || true)" io="${io:-$name}" if [[ "${2:-}" != -y ]]; then echo "This resets ${dir#$ROOT/} to a fresh template:" if [[ -f "$dir/driver.h" ]]; then echo " main.cpp -> LeetCode's starter code again (old one saved as main.cpp.bak)" else echo " main.cpp -> re-created from template (old one saved as main.cpp.bak)" fi echo " removes compiled binary and $io.out (tests/ and $io.in are kept)" read -r -p "Reset '$name'? [y/N] " ans [[ "$ans" == y || "$ans" == Y ]] || { echo "Aborted."; exit 1; } fi [[ -f "$dir/main.cpp" ]] && cp "$dir/main.cpp" "$dir/main.cpp.bak" if [[ -f "$dir/driver.h" ]]; then # a LeetCode import: re-fetch its starter code python3 -I "$ROOT/lib/leetcode.py" "$ROOT" "$dir" --main-only >/dev/null || exit 1 else fresh_main "$dir" "$io" fi rm -f "$dir/main" "$dir/a.out" "$dir/$io.out" echo "Reset $name (old solution in main.cpp.bak)"