match 3 game with a mathematical twist. JavaScript version and Lua/Marmalade Quick version