Completed bonus problem for day2. Phew - not trivial.