Another solution mainly by hand.