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...
-
What is the penalty for scientific fraud in the science community?
-
In the linear example in panel a of Figure 11.3, how does charging the monopoly a specific tax of \(t=\$ 8\) per unit affect the monopoly optimum and the welfare of consumers, the monopoly, and...
-
Furniture Depot is a retail chain selling furniture and appliances. The firm has after-tax operating income of \($250\) million in the current year on revenues of \($5\) billion. The firm also has...
-
Gordon Beckham started his own delivery service, Beckham Deliveries, on June 1, 2012. The following transactions occurred during the month of June. June 1 Gordon invested $10,000 cash in the...
-
I need help with this finance question, please. Thanks! Jill Clark invested $25,000 in the bonds of Industrial? Aromatics, Inc. She held them for 13? months, at the end of which she sold them fo...
-
Paolo is a 50% partner in the Capri Partnership and has decided to terminate his partnership interest. Paolo is considering two options as potential exit strategies. The first is to sell his...
-
Read page 127of your text about psychologist Albert Ellis and his thoughts about irrational beliefs. Look over the irrational beliefs listed here and then see if you can come up with others. These...
-
In which three ways have the new IT developments spurred innovation and international expansion in financial markets? Explain
-
The list price of an item is $ 8 7 . 6 2 . The supplier is offering a series trade discount of 8 / 1 9 . Use complements to find the net cost. ( Round to the nearest cent as needed. )
-
NE-YO Corporation is currently manufacturing laptops using traditional technology. Only one machine is used for assembling the product. With the improving economic decisions and increasing demands of...
-
Describe the importance of international capital structure. What risks can you identify when working with cash, credit and inventory management? Provide your rationale and any supporting data.
-
There are three levels of efficiency under the efficient market hypothesis (EMH), namely weak form, semi-strong form and strong form. a) Describe a market anomaly that refutes the weak form of the...
-
WILL UPVOTE!! PLEASE ANSWER THE FOLLOWING ASAP! Suggest at least 10-15 trends and innovations in supply chain management in 2022.
-
Anne is employed by Bradley Contracting Company. Bradley has a $1.3 million contract to build a small group of outbuildings in a national park. Anne alleges that Bradley Contracting has discriminated...
-
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?
-
Explain the so called "gap analysis approach" to fraud deterrence.
-
Assume the following facts about a local government. Determine the Tax Limit Exhausted and the Debt Limit Exhausted ratios. Tax Limit \(\$ 11\) million Debt Limit \(\$ 13\) million Tax Levy \(\$...
-
How much year-end cash should a local government have?
Study smarter with the SolutionInn App