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

  What does cissp stand for

What does CISSP stand for? Using the internet, find out what continuing education is required for the holder of a CISSP t remain current and in good standing.

  Some time on a new parallel computer

You are given some time on a new parallel computer. You run a program which parallelizes perfectly during certain phases, but which must run serially during others.

  Features of a change management tool

Features of a Change Management Tool

  Define a function that takes argument in name of a csv file

Define a function that takes an argument in the name of a CSV file. This file can have any number of rows. Each row has exactly 10 words separated by comma. Your function should print the total number of four letter words in the file.

  Several policies or events that affect the performance

Several policies or events that affect the performance of the economy

  Computer forensics examiner get involved with, and how

Other than the two basic types of computer crimes above, what non-computer crimes might a computer forensics examiner get involved with, and how?

  Database environment

Analyze the database environmen

  What are the implications for companies seeking to learn

Mark Jamison of Kimberly Clark notes that it is business processes and not the technology (e.g RFID)itself, what bring value to the supply chain.What does he means by that. what are the implications for companies seeking to learn from the likes of..

  Individual traffic light has at least three states (g.y,r)

Consider a traffic light system at a four-way crossroads (two roads intersecting at right angles) with a countdown timer, a crosswalk button, and a speaker that announces it's ok or not ok to walk

  Convert hand-drawn diagram to a fully labeled visio diagram

1.Using the IP addresses provided by your instructor, hand-draw a network diagram of your network configuration. (This will include at least two Windows Servers and one Workstation.)2.Convert the hand-drawn diagram to a fully labeled Visio diagram.

  Design a zoo using coding best practices and object oriented

Design a ZOO using coding best practices and object oriented design principles

  File of the game tic-tac-toe

First have a good grasp on the game, its concepts, and its rules.  For your first assignment, download the linked file below. This is a .cpp file of the game Tic-Tac-Toe.

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