Algorithm Puzzles Solved in JavaScript