Hi xpi0t0s,

First of all I assume ur comment was meant for thamiz. If so, I think he/she just wanted an idea, which i guess i gave in my solution:-) .
If its understood by him/her, its great! Having said that, i think having a full code with a main function is always easier to answer on.