Problem 4 completed (ported from old procedural code).
Problem Template to minimize copy-paste errors