FastPrepShortest Atom Action Path

Shortest Atom Action Path

OpenAI logoOpenAI● MediumFULLTIMEOA

Problem statement

An atom starts at cell start in a rectangular grid and must reach cell target. A cell containing . is allowed; a cell containing # is forbidden. Coordinates are zero-based [row, column] pairs, with rows increasing downward and columns increasing to the right.

The input actions defines the available moves. Action i changes cell (r, c) to (r + actions[i][0], c + actions[i][1]). Every action costs one step and may be used repeatedly.

The problem statement continues
Pro

Examples

Example 1

grid = ["...","..."]start = [0,0]target = [1,2]actions = [[0,1],[1,0],[0,-1],[-1,0]]return = [0,0,1]

The atom visits (0,0), (0,1), (0,2), (1,2). Three actions are necessary. Of the shortest sequences, [0,0,1] is lexicographically smallest.

Original screenshot from the interview report
Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See OpenAI hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week