Solved P18 to P20. Refactorred some solutions after seeing pulpillo's solutions.