Completed part 1.
Completely complicated implementation of the solution. 
This uses all the java fundae I learnt earlier :P