Retroactively added Problems 1-4 and added a newly non-brute force solution for problem 5