Okay, first things first. Do you understand how the solution above works? Judging by the code you wrote I'd guess you have a 50/50 chance of. So step one, explain to me in words why his solution works, what it does.