In this challenge, you must navigate a knight on a Toroidal Hexagonal Grid of size
The grid:
  • We use the Axial Coordinate System (q,r)
  • The grid is Toroidal: any move that goes off the edge wraps around to the opposite side. Formally, a position (q,r) is always treated as (mod(q,N),mod(r,N)).
The knight's move:
On a hexagonal grid, a "Knight's move" is defined by 12 possible jumping vectors (). These represent moving 2 steps in one axial direction and 1 step in another, or similar symmetries:
The goal:
Given the board size N,a starting position start_pos, an ending position end_pos, and a list of obstacles, find the minimum number of moves required to reach the destination.
Input:
  • N: Scalar ( board size )
  • start_pos: 1x2 vector []
  • end_pos: 1x2 vector []
  • obstacles: Mx2 matrix where each row is a blocked [ ]
Output:
  • min_steps: The shortest distance ( integer ). Return Inf if the destination is unreachable.

Solution Stats

8 Solutions

5 Solvers

Last Solution submitted on Mar 21, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...