eration. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If it is feasible to move to the left, right, up, or down, then move and repeat the process. If it is not feasible to move to the respective positions, then repeat the generation of random numbers modulo 4 and generate numbers 0, 1, 2, or 3. Take decisions whether to move left, right, up or down now and continue the process of cleaning the respective array positions. You can stop the process when all array positions are cleaned. You need to show the source code and the output. The o

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

Implement the vacuum cleaning agent function in Python/Java for the scenario described below: Consider two-dimensional Boolean array of size m x n (m and n can each be equal to 4) where m is the number of rows, and n is the number of columns. Obtain numerical positive integer values for m and n as inputs from the user. Generate random numbers and scale them down to either a “0” or a “1” according to whether they represent “Clean” or “Dirty”, respectively. After filling the array with 0s or 1s, start at some random array position indicating the initial position of the vacuum cleaner. First check if at that current position, there is the presence of a “Dirt” or not determined by whether 0 or 1 is filled in at that initial position of the vacuum cleaner. If there is a “Dirt”, clean it, and if there is no “Dirt” do a No-operation. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If it is feasible to move to the left, right, up, or down, then move and repeat the process. If it is not feasible to move to the respective positions, then repeat the generation of random numbers modulo 4 and generate numbers 0, 1, 2, or 3. Take decisions whether to move left, right, up or down now and continue the process of cleaning the respective array positions. You can stop the process when all array positions are cleaned. You need to show the source code and the output. The output needs to be shown after the result of each action. The output can be shown as a 4 x 4 square grid (matrix-like) containing numbers 0s and/or 1s.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Lower bounds sorting algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning