Solution for Problem 27, updated solution for 26