To be honest i actually had it solved on paper way before i posted this hehe. I am now close to finding a way on C++ too. If i require any extra assistance i shall inform although i think i got this on my own.