Possesses some finite amount of magical energy

Assignment Help Basic Computer Science
Reference no: EM13934441

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)

Reference no: EM13934441

Questions Cloud

Debt outstanding and total market value : RAK, Inc., has no debt outstanding and a total market value of $240,000. Earnings before interest and taxes, EBIT, are projected to be $26,000 if economic conditions are normal. If there is strong expansion in the economy, then EBIT will be 18 percen..
Discuss the effect this might have on the selection : Some modern, capital-intensive production facilities have significantly reduced the proportion of direct labor cost to total production cost.
Analyse the obesity childhood in the uk : Analyse the obesity childhood in the uk as a health problem, then analyse three effects of this problem on children and give a possible solution for each effect.
What were the probable causes of undervaluation : The Argentine peso was fixed through a currency board at Ps1.00/$ throughout the 1990s. In January 2002, the Argentine peso was floated. On January 29, 2003 it was trading at Ps3.20/$. y what percentage was the Argentine peso undervalued? What were t..
Possesses some finite amount of magical energy : 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 ob..
Using professional-style writing : In your proposal, explain to your boss (using professional-style writing) the reasons for your choice. Include the concepts that are covered in Chapters 7 and 8 as reasons for or against the use of the training tutorials or videos or modules or your ..
Discuss an important characteristic of a good overhead : Discuss an important characteristic of a good overhead allocation base.
Initial investment because of the chinese revaluation : Cnooc, a Chinese public-sector company, has made a bid to purchase Unocal, a big U.S oil company, for $18.5 billion in June 2005. Treat this as an initial investment made by Cnooc in this two-year, U.S based project.  If it now purchased Unocal in Au..
Obesity in the uk as a health problem with statistics : Analyse obesity in the uk as a health problem with statistics, the main body should include 3 effects of this problem and for each problem should be practical solution and evaluation.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Describe the web-based information technologies

Describe the Web-based information technologies

  Decide whether or not software-generated reports

Determine what you perceive to be the most difficult task in writing a system forensics report and explain why you believe this is the case. Decide whether or not software-generated reports assist with this specific portion of the report writing proc..

  Why do some block cipher modes of operation only

Why do some block cipher modes of operation only use encryption while others use both encryption and decryption?

  Developing a use case diagram

Read "The Spring Breaks 'R' Us Travel Service" of your textbook and identify name of the event, state the type of event and name the resulting use cases. Use the event decomposition technique.

  The number of page interrupts in fifo and lru page

A job has four pagse A, B, C, D and the main memory has two page frames only.

  Assume an open addressing hash table

Assume an open addressing hash table, with a load balance α given. What is the expected number of probs needed when searching a key x that is in the table. Note that the development shown in class was for the case that x is not in the table.

  Given a set of integer numbers

Given a set of integer numbers as int A[ ] = { 12, 6, 51, 4, 3, 7, 19, 8, 0, 21}, please write down the divide and conquer procedure of quick sort (step by step), include all left and right positions adjustment, and overwriting.

  A complex and highly sophisticated computer worm

In June 2010, Stuxnet, a complex and highly sophisticated computer worm was discovered by Kaspersky Lab. Stuxnet targeted Siemens industrial Supervisory Control and Data Acquisition (SCADA) systems. It was reported that the worm appeared to target Ir..

  Analysis of executive management team

Give a one to two page analysis summarizing the results to the executive management team of Omega.

  How can a web site distinguish between lack of capacity

How can a web site distinguish between lack of capacity and a denial-of-service attack? For example, web sites often experience a tremendous increase in volume of traffic right after an advertisement with the site's URL is shown on television during ..

  Cnditions under which full offsite backup is worth the cost

Discuss conditions under which it is worth the cost. Suggest some kind of compromise, lower cost solutions that still proved some recovery capabilities, and cases where these might be a preferred alternative.

  Sockets are considered a low-level

Sockets are considered a low-level means for two applications to connect to each other and send/receive information. An alternative approach is the notion of distributed objects.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd