Clean every reachable cell with a blind robot that can only move, turn and clean

hardAbout 40 minutesUpdated CodingProbacktrackingdfsgridssimulation
Not solved

Share this question

Problem

A robot vacuum is placed in a room it cannot see. It does not know the layout or its position. It only has four commands:

// Room (1 = open, 0 = wall), robot starts at row 1, column 3:
// 1 1 1 1 1 0 1 1
// 1 1 1 1 1 0 1 1
// 1 0 1 1 1 1 1 1
// 0 0 0 1 0 0 0 0
// 1 1 1 1 1 1 1 1
cleanRoom(robot); // every open cell connected to the start gets cleaned

Ref. UR-1428 · © UIRound · uiround.com/questions/clean-every-reachable-cell-with-a-blind-robot-that-can-only-move-turn-and-clean

Stuck? Take a hint

Try it in the editor

Run your code as often as you like. Submitting it to the full test suite is part of Pro.

Private, and saved in this browser as you type. All your notes are on My lists.

Every question and answer7 days, one payment