PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Shopify

Simulate rover movement on a grid

Last updated: Mar 29, 2026

Quick Overview

This question evaluates spatial reasoning, state and command parsing, collision detection, boundary handling, and API design for extensible simulation across 2D and 3D coordinate systems.

  • easy
  • Shopify
  • Coding & Algorithms
  • Software Engineer

Simulate rover movement on a grid

Company: Shopify

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are building a rover navigation simulator. ## Part 1: Single rover on a 2D map You are given: - A rectangular 2D grid with coordinates `(x, y)`. - A rover starting position `(x0, y0)` and a facing direction (one of `N, E, S, W`). - A command string consisting of: - `L`: turn left 90° - `R`: turn right 90° - `M`: move forward 1 step in the current facing direction Rules: - The rover cannot move outside the map boundaries. If a command would move it out of bounds, ignore that move (or alternatively, return an error—state your chosen behavior clearly and implement it consistently). Task: Implement a function that returns the rover’s final position and direction after executing all commands. ## Part 2: Multiple rovers Extend the design to support multiple rovers on the same 2D map. - Each rover has its own initial state and command string. - (Clarify your assumption) Either rovers execute sequentially (one after another) or simultaneously step-by-step. - Decide and implement a collision policy (e.g., rovers cannot occupy the same cell; a move that would collide is rejected). Task: Explain how you would change the code structure/API to support multiple rovers cleanly and safely. ## Part 3: 3D map Now the map is 3D with coordinates `(x, y, z)`. - Define a reasonable model for orientation in 3D (e.g., a heading direction plus pitch, or facing as one of 6 axes: `+X, -X, +Y, -Y, +Z, -Z`). - Extend commands accordingly (you may introduce new commands if needed, but specify them). Task: Describe and/or implement how your solution generalizes to 3D while keeping the design maintainable.

Quick Answer: This question evaluates spatial reasoning, state and command parsing, collision detection, boundary handling, and API design for extensible simulation across 2D and 3D coordinate systems.

Related Interview Questions

  • Compute Jaccard Similarity for Lists - Shopify (medium)
  • Implement URL Shortening Codec - Shopify (medium)
  • Simulate a rover fleet - Shopify (medium)
  • Simulate robot moves on a grid - Shopify (medium)
  • Implement a Capacity-Bounded Cache - Shopify (medium)
Shopify logo
Shopify
Jan 27, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
9
0

You are building a rover navigation simulator.

Part 1: Single rover on a 2D map

You are given:

  • A rectangular 2D grid with coordinates (x, y) .
  • A rover starting position (x0, y0) and a facing direction (one of N, E, S, W ).
  • A command string consisting of:
    • L : turn left 90°
    • R : turn right 90°
    • M : move forward 1 step in the current facing direction

Rules:

  • The rover cannot move outside the map boundaries. If a command would move it out of bounds, ignore that move (or alternatively, return an error—state your chosen behavior clearly and implement it consistently).

Task: Implement a function that returns the rover’s final position and direction after executing all commands.

Part 2: Multiple rovers

Extend the design to support multiple rovers on the same 2D map.

  • Each rover has its own initial state and command string.
  • (Clarify your assumption) Either rovers execute sequentially (one after another) or simultaneously step-by-step.
  • Decide and implement a collision policy (e.g., rovers cannot occupy the same cell; a move that would collide is rejected).

Task: Explain how you would change the code structure/API to support multiple rovers cleanly and safely.

Part 3: 3D map

Now the map is 3D with coordinates (x, y, z).

  • Define a reasonable model for orientation in 3D (e.g., a heading direction plus pitch, or facing as one of 6 axes: +X, -X, +Y, -Y, +Z, -Z ).
  • Extend commands accordingly (you may introduce new commands if needed, but specify them).

Task: Describe and/or implement how your solution generalizes to 3D while keeping the design maintainable.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Shopify•More Software Engineer•Shopify Software Engineer•Shopify Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.