I need help with coding a puzzle game

usually forums have certain rules, and the rules are summarized in some sticky threads.
here we like seeing code properly formatted, and for that you can use code tags, as explained here .
you can freely edit your post at any time.