I'm kindof confused: do you want us to write actual code? Just give an explanation of how to do this?
If the former: what language, what assumptions can we make about the environment?
If the former: what language, what assumptions can we make about the environment?
for q2 - just the answers are sufficient
for q3 - submit an explanation of how you'd tackle the problem, or code