Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopgrid · manhattan-distance · dynamic-updates
The organizer’s problem statement is available at the official source link.
grid distance
Find the farthest pair across two fruit classes
A query asks the largest shortest bee travel time between any U cell and any V cell; another operation changes one field’s fruit.
| fruit A | . | fruit B |
| . | . | . |
| fruit A | . | fruit B |
- 1
Group cells by fruit
Maintain the grid locations grouped by fruit type. - 2
Measure Manhattan distance
Four-neighbor shortest travel equals Manhattan distance. - 3
Query the farthest pair
For a query, maximize that distance across the two fruit groups; updates move one cell between groups.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.