As an exercise in solving algorithmic problems, program Clara to place a single leaf at the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
As an exercise in solving algorithmic problems, program Clara to place a single leaf at the centre of her world (edges of the world populated with trees are not considered to be a streets/avenues in this scenario). For example, if Clara starts in the world shown in Figure 1, after execution of your program the world should appear as in Figure 2. 4 4 Note that the final configuration of the world should have only a single leaf at the midpoint of Clara's world. When Clara is finished she must step away from the leaf and remain one step to the east from it. Along the way, Clara is allowed to place additional leaves wherever she wants to, but must pick them all up again before she finishes. You are required to develop a general-purpose solution that works with all supplied worlds. 4 4 4 4 4 * 懋 Figure 2. In solving this problem, you may count on the following facts about the world: • Clara starts at 1st Avenue and 1st Street, facing east, with an infinite number of leaves in her bag. • The initial state of the world includes no interior trees (apart from those on the border) or leaves. Your program, moreover, can assume the following simplifications: • That the width of the world is always odd. • The world is always square, so the width of it is always equal to height. • It does not matter which direction Clara is facing at the end of the run. There are many different algorithms you can use to solve this problem. The interesting part of this assignment is to come up with a strategy that works. Please be aware that you are explicitly prohibited to use for loops and variables for solving this problem! This means that Clara is not allowed to memorise anything (e.g. how many steps she made or how wide the street is). You must solve this problem by moving around and putting or removing leaves. </> MyClara 1 /* PERMITTED COMMANDS 2 move(); turnLeft(); turnRight(); treeLeft(); treeRight(); treeFront (); onLeaf(); putLeaf(); removeLeaf (); JAVA if, else, while, &&, ||, ! NOT ALLOWED TO USE for-LOOPS and variables */ UAW N 3 4 5 6 As an exercise in solving algorithmic problems, program Clara to place a single leaf at the centre of her world (edges of the world populated with trees are not considered to be a streets/avenues in this scenario). For example, if Clara starts in the world shown in Figure 1, after execution of your program the world should appear as in Figure 2. 4 4 Note that the final configuration of the world should have only a single leaf at the midpoint of Clara's world. When Clara is finished she must step away from the leaf and remain one step to the east from it. Along the way, Clara is allowed to place additional leaves wherever she wants to, but must pick them all up again before she finishes. You are required to develop a general-purpose solution that works with all supplied worlds. 4 4 4 4 4 * 懋 Figure 2. In solving this problem, you may count on the following facts about the world: • Clara starts at 1st Avenue and 1st Street, facing east, with an infinite number of leaves in her bag. • The initial state of the world includes no interior trees (apart from those on the border) or leaves. Your program, moreover, can assume the following simplifications: • That the width of the world is always odd. • The world is always square, so the width of it is always equal to height. • It does not matter which direction Clara is facing at the end of the run. There are many different algorithms you can use to solve this problem. The interesting part of this assignment is to come up with a strategy that works. Please be aware that you are explicitly prohibited to use for loops and variables for solving this problem! This means that Clara is not allowed to memorise anything (e.g. how many steps she made or how wide the street is). You must solve this problem by moving around and putting or removing leaves. </> MyClara 1 /* PERMITTED COMMANDS 2 move(); turnLeft(); turnRight(); treeLeft(); treeRight(); treeFront (); onLeaf(); putLeaf(); removeLeaf (); JAVA if, else, while, &&, ||, ! NOT ALLOWED TO USE for-LOOPS and variables */ UAW N 3 4 5 6
Expert Answer:
Answer rating: 100% (QA)
Here is a possible algorithm for Clara to place a single leaf at the center of 1st Street Move to th... View the full answer
Related Book For
Introduction To Materials Management
ISBN: 978-9386873248
8th edition
Authors: Arnold J. R. Tony, Gatewood Ann K., M. Clive Lloyd N. Chapman Stephen
Posted Date:
Students also viewed these programming questions
-
To what yearly amount (in today's dollars) does an average inflation rate of 3 percent reduce the purchasing power of Mateo's yearly retirement amount of $150,000?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
I really would like to know the steps idk how to start this buttrying to look for the gross pays has been frustrating, pleasehelp! Each of the following workers is piece-rate workers at Golden Boats...
-
Determine the magnitude and directional sense of the moment of the forces about point P. Units Used: kN = 103 N Given: FB = 260 N e = 2 m a = 4 m f = 12 b = 3 m g = 5 c = 5 m θ = 30 deg d = 2 m...
-
Given 6d +18e-18f=-168,-2d+e+48f273, and 4d + 10e - 20f = -150, use Gaussian elimination to solve the system. State the solution as an ordered triple.
-
What are the final two steps a researcher should do after presenting the research findings to the decision makers?
-
Several years ago The Wall Street Journal reported that the winner of the Massachusetts State Lottery prize had the misfortune to be both bankrupt and in prison for fraud. The prize was $9,420,713,...
-
2. Another dielectrics-filled spherical capacitor Given a spherical capacitor with dielectrics in between for two different cases below, find the net capacitance of the spherical capacitor for both...
-
Bills Boards (BB) is an outdoor advertising company founded by William Longfall. William knows very little accounting so he hired a friend to keep the books. Unfortunately, William did not review his...
-
Question 1 In order to focus on its manufacturing division, the Board of Tanjong Bhd approved a resolution to close down its loss-making property division on 31 December 2022. The property division...
-
Harold Haas owns 100 shares of Spartan Corp. common stock with an adjusted basis of \(\$ 10,000\). On July 28,2018 , he sold all 100 shares for \(\$ 9,000\). On August 18, 2018, he purchased 80...
-
A small country can import a good at a world price of 5 per unit. The domestic supply curve of the good is S = 10 + 10P. The demand curve is D = 600 - 5P. In addition, each unit of production yields...
-
If all colleges are private and the market for education is competitive, calculate the number of students, the tuition, and the deadweight loss. The marginal cost of educating a student is a constant...
-
In December 2019, Mr. Joe Jacobs cashed qualified Series EE U.S. Savings Bonds, which he had purchased in January 2012. The proceeds were used for his son's college education. All of the following...
-
All of the following fringe benefits can be excluded from the employees income except: a. Transportation up to $265 per month for combined commuter highway vehicle transportation and transit passes,...
-
(i) An analytic function with constant real part is constant. Ula (ii) An analytic function with constant imaginary part is constant.
-
The following items were displayed in the statement of affairs for Lubbock Company: Fully secured liabilities ......... $90,000 Partially secured liabilities ....... 12,000 Unsecured liabilities...
-
What two changing conditions led to the development of ERP systems?
-
How many standard hours are needed to run an order of 200 pieces if the setup time is 1.3 hours and the run time 0.3 hours per piece? How many actual hours are needed at the work center if the...
-
A company plans to produce 25,000 units in a 3-month period. The months have 22, 21, and 20 working days, respectively. What should the average daily production be?
-
You are to open the books of F. Polk, a trader, via the journal to record the assets and liabilities, and are then to record the dialy transactions for the month of May. A trial balance is to be...
-
Show the journal entries necessary to record the following items: 2017 Apr 1 Bought office furniture on credit from Durham Brothers Ltd 1,400. 4 We take goods costing 270 out of the business...
-
You are to show the journal entries necessary to record the following items which occured in 2016: (a) May 1 Bought a motor bike on credit from Lakeside Garage for 5,500. (b) May 3 A debt of 347...
Study smarter with the SolutionInn App