Skip to content

Instantly share code, notes, and snippets.

@mike-pete
Last active April 9, 2025 02:04
Show Gist options
  • Save mike-pete/6264ece3de28d5f3529e2a60a9cdbb92 to your computer and use it in GitHub Desktop.
Save mike-pete/6264ece3de28d5f3529e2a60a9cdbb92 to your computer and use it in GitHub Desktop.
Directions Map - useful for direction based traversal
const direction = {
'↑': [-1, 0],
'↗': [-1, 1],
'→': [0, 1],
'↘': [1, 1],
'↓': [1, 0],
'↙': [1, -1],
'←': [0, -1],
'↖': [-1, -1],
} satisfies Record<string, [number, number]>
const direction = {
'up': [-1, 0],
'upRight': [-1, 1],
'right': [0, 1],
'downRight': [1, 1],
'down': [1, 0],
'downLeft': [1, -1],
'left': [0, -1],
'upLeft': [-1, -1],
} satisfies Record<string, [number, number]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment