Archive for the ‘Code’ Category.

Messing with Javascript

9-dotsThe “9-dots” puzzle was discussed on PBS the other day. The 9-dots puzzle consists of 9 dots arranged in a 3 x 3 grid. A person is asked to use 4 connected straight line segments to pass through all 9 dots. It is a simple puzzle that lead to the saying, “Think outside the box.” I decided it would be interesting and fun to see if I could program an interactive web version of the 9-dots puzzle.

With the problems surrounding java on the web, I decided to use javascript and html. I found a useful javascript framework for interactive graphics called paper.js. The paper.js website isĀ here. I coded an interactive 9-dots program in a few hours. I spent more hours trying to figure out how to allow users to enter their initials. That ended up being a bit of a kludge using an intermediate text file. I would not use that technique for a work project, but it was good enough for my 9-dots test case. Click here to try my 9-dots code.