subject

A modern ship
A large container ship is traversing the Atlantic Ocean. It needs to deliver a large number of containers to a port in the United States. The ship in question has recently been upgraded with some new technologies.
The most notable of this is a new robot that is being used to perform a number of tasks on the ship.
In order to do so, the robot needs to be given a set of instructions for each task that it needs to perform.
The robot's main function is to check the contents of containers.
Robot Instructions
In order to provide a better definition of the instructions, we use the capital letters X and Y.
X and Y can be any container.

The robot can perform the following instructions:

- move(X, Y)
Moves the contents of container X into container Y.

- isGreater(X, Y)
If the weight of container X is greater than the weight of container Y, execute the next instruction.
Otherwise skip the next instruction.

- isEqual(X, Y)
If the weight of container X is equal to the weight of container Y, execute the next instruction.
Otherwise skip the next instruction.

However, one needs to be very careful with these instructions. The move(X, Y) instruction requires container Y to be empty. If this is not the case, the robot will dump the contents of container Y into the water. Note that the instructions concern the contents of the container.

Unfortunately, the robot cannot read these types of text instructions, because it can only read machine instructions.
In order to execute the above instructions, it first needs to convert these instructions to this machine code.
This process is called compilation.
Containers
The ship contains a lot of stacked containers.

The next two questions will concern four containers: A, B, C and D that have been stacked on top of eachother.

In order to make the ship as stable as possible in heavy seas, the heaviest containers are put at the bottom of the stack, while the lightest are put at the top:

Container D

Empty

Container C

Second Lightest

Container B

Second Heaviest

Container A

Heaviest

We call this the default order.
The top container of this stack, container D, is empty.
If two containers X and Y weigh equally heavy, the order of X and Y does not matter.

Exercise
The containers have accidentally been improperly loaded.
The contents of container C weigh heavier than the contents of container B:

Container D
Empty
Container C
Second Heaviest
Container B
Second Lightest
Container A
HeaviestWrite a set of instructions for the robot that swaps the contents of container B and C.

You are allowed to use at most three instructions.
If less instructions are needed, you should fill the boxes with a dash (-).
(
,
)
(
,
)
(
,
)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
Give an example of a case where a two-way handshake to establish a connection could leave one side of the connection live while the other side does not believe there is a connection.
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
The salespeople at hyperactive media sales all use laptop computers so they can take data with them on the road. you are a salesperson for superduper lightspeed computers talking to hyperactive media sales about upgrading the laptops to windows 10. explain how network location awareness in windows 10 would make the laptops more secure.
Answers: 3
question
Computers and Technology, 24.06.2019 01:00
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
question
Computers and Technology, 24.06.2019 09:50
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
You know the right answer?
A modern ship
A large container ship is traversing the Atlantic Ocean. It needs to deliver a l...
Questions
question
Chemistry, 21.08.2019 12:50
Questions on the website: 13722363