Medium data structure and algorithm practice puzzle.
In an isometric game, square map tiles are drawn as diamonds, so finding the tile under the mouse takes a little algebra. Given a mouse position in screen pixels and the tile width and height, return the [x, y] map tile under the mouse. Tile (0, 0) has its top corner at the screen origin, and one step along x moves half a tile right and half a tile down. Undoing that gives tileX = (sx * th + sy * tw) / (tw * th) and tileY = (sy * tw - sx * th) / (tw * th), both rounded down. Left of the origin the answers are negative, so round toward negative infinity, not toward zero.
Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free.
Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.
Then grow it into a real project with the Software Engineer button: this puzzle becomes the Entity Anomaly Watch, a pipeline you can run and download. See every Software Engineer project.
Browse all 576 puzzles