First stab at solving the problem. Largely a copy-paste from example problem, with type and names of variable changed. Should work without problem though.