works, but output formatting is wrong
format is fine; not sure if line-by-line processing is OK
rounding up the 1st page of algorithms warmup