Margaretas Puzzle
in JavaScript