Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

A spellcaster is given an object (e.g. mouse, owl, dwarf, purse ...) and a set of spells that she / he can use to transform the object. The
effect of each spell is described by a set of from-to pairs. For example, spell "Chiroptera" may transform objects as follows:

crocodile -> dragon
mouse -> bat

If the spell is cast on an unspecified inital form, the form of the object is not changed.

The spellcaster possesses some finite amount of magical energy (an integer > 0). Each spell casting, whether fruitful or not, consumes
certain amount of magical energy (an integer > 0). Write a program that helps the spellcaster to transform the object into desired form in the most energy-efficient way.

The program inputs the description of spells, the amount of available magical energy, the initial object form, and the desired object form.
If desired transfiguration is possible, the program should print the appropriate sequence of spells to achieve the desired form. The sequence
of spells should consume the least possible amount of magical energy.

If the transformation is not possible the program should print:

TRANSFORMATION IS IMPOSSIBLE

Input data format:
------------------

The input data will be given in the following format:

number of spells (K)
name of spell 1 \
amount of energy consumed by spell 1 \
number of transformation pairs (N1) \
initial form 1 \
resultant form 1 \
initial form 2 information about spell 1
resultant form 2 /
... /
initial form N1 /
resultant form N1 /
name of spell 2 \
amount of energy consumed by spell 2 \
number of transformation pairs (N2) \
initial form 1 \
resultant form 1 \
initial form 2 information about spell 2
rtesultant form 2 /
... /
initial form N2 /
target form N2 /
...
...
...
name of spell k \
amount of energy consumed by spell k \
number of transformation pairs (Nk) \
initial form 1 \
resultant form 1 \
initial form 2 information about spell 2
rtesultant form 2 /
... /
initial form Nk /
target form Nk /
available amount of magical energy
initial form of the object
desired form of the object

You can assume that both the number of spells (K) and the number of
transformation pairs within a spell (N) are all less than 100, and that
amounts of magical energy are positive numbers < 1000000.

Example:
--------

Given below is an example input to the transfiguration program.

The input defines:

* two spells:

CHIROPTERA (each casting consumes 4 units of magical energy):
crocodile -> dragon
mouse -> bat

and REDUCTIO (each casting consumes 1 unit of magical energy):
elephant -> hyppo
hyppo -> horse
horse -> mouse
mouse -> elephant

* 8 units of available magical energy

* initial object "elephant"

* desired object form is "bat"

---- Input: ----
2
CHIROPTERA
4
2
crocodile
dragon
mouse
bat
REDUCTIO
1
4
elephant
hyppo
hyppo
horse
horse
mouse
mouse
elephant
8
elephant
bat
--------------------

In response to this input, your program should output:

REDUCTIO
REDUCTIO
REDUCTIO
CHIROPTERA

That output defines sequences of four transformations:
(Initial object: elephant; initial magical energy: 8 units)

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91605328

Have any Question?


Related Questions in Computer Engineering

Reduce setup timehammond inc has analyzed the setup time on

Reduce Setup Time Hammond Inc. has analyzed the setup time on its computer-controlled lathe. The setup requires changing the type of fixture that holds a part. The average setup time has been 135 minutes, consisting of t ...

Suppose you have used the following production function to

Suppose you have used the following Production Function to estimate the Industry's average and marginal products for its inputs: Q = 150 L 1/4 K 1/3  M 1/5. Where Q stands for output; L is labor; K is capital (machine ho ...

Question the three as of security are authentication

Question: The three A's of security are Authentication, Authorization, and Auditing. Write a 1-2 page paper in APA format describing these techniques and how they are used in your organization. What could be improved? Th ...

Advertisements suggest that a new window design can save

Advertisements suggest that a new window design can save $400 per year in energy cost over its 30-year life. At an initial cost of $8,000 and zero salvage value, using IRR, is this window a good investment? MARR is 8%.

Suppose a consumer is trying to make a choice over the

Suppose a consumer is trying to make a choice over the consumption of two goods: x and y. Px = 3, Py = 4 and the income is equal to 50. Assume that the government distributes some stamps that are good to buy 5 units of g ...

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks

1 the lab manual instructs you to heat camphor at position

1.) The lab manual instructs you to heat camphor at position 2 on the hot plate, which is a moderately low setting. What would be a problem of heating the camphor too quickly? 2.) A mixture of ammonium chloride, sand, an ...

Penetration testing is a technique used to identify

Penetration testing is a technique used to identify security weaknesses in your network. Discuss a type of penetration testing and the different methods utilized to recognize vulnerabilities in your network.

We might consider a regression of the number of group

We might consider a regression of the number of group members and the efficiency of project completion. Which of those would be the dependent and which would be the independent variables?

Question after reading this chapter you should now be

Question : After reading this chapter, you should now be familiar with the "Fun" part of Java utilizing the GUI. The GUI offers all kinds of functionality in the graphical sence. Why do you think Java and Javas GUI are s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As