Calculate the minimum distance from the start to the goal

Assignment Help Basic Computer Science
Reference no: EM13495533 , Length: 40

We are planning an orienteering game.

The aim of this game is to arrive at the goal (G) from the start (S) with the shortest distance.However, the players have to pass all the checkpoints (@) on the map.

An orienteering map is to be given in the following format. ######## #@....G# ##.##@## #[email protected]# #@.....# ######## In this problem, an orienteering map is to be given.

Calculate the minimum distance from the start to the goal with passing all the checkpoints -Specification * A map consists of 5 characters as following.

You can assume that the map does not contain any invalid characters andthe map has exactly one start symbol ''S'' and exactly one goal symbol ''G''. * ''S'' means the orienteering start. * ''G'' means the orienteering goal. * ''@'' means an orienteering checkpoint. * ''.'' means an opened-block that players can pass. * ''#'' means a closed-block that players cannot pass. * It is allowed to move only by one step vertically or horizontally (up, down, left, or right) to thenext block.

Other types of movements, such as moving diagonally (left up, right up, left down and right down)and skipping one or more blocks, are NOT permitted. * You MUST NOT get out of the map. * Distance is to be defined as the number of movements to the different blocks. * You CAN pass opened-blocks, checkpoints, the start, and the goal more than once if necessary * You can assume that parameters satisfy following conditions. * 1 <= width <= 100 * 1 <= height <= 100 * The maximum number of checkpoints is 18. * Return -1 if given arguments do not satisfy specifications, or players cannot arrive at the goal from the start by passing all the checkpoints.

Input: The input is to be given in the following format, from the standard input. W H Row1 Row2 ... RowH The first row is to describe the width and the height of the orienteering map, sectioned by a space.From the second row, map information is to be given for exactly the same number of rows as the height.

Each row contains exactly the same number of letters as the width.See "Specification" for details of the symbols contained in the map. Output: Output into the standard output, and put a return.

Reference no: EM13495533

Questions Cloud

Compute how far from the wall should the mirror be located : A concave mirror (R = 64 cm) is used to project a transparent slide onto a wall. The slide is located at a distance of 40.0 cm from the mirror, How far from the wall should the mirror be located
Evaluate the energy of a photon emitted : Calculate the energy of a photon emitted when an electron in a hydrogen atom undergoes a transition from n=3 to n=1
Explain what is the molecular weight of the protein : A sample of protein weighs 0.800 g and is dissolved in 50.0 mL of water. If the osmotic pressure of the solution is 10.5mmHg at 25 degrees C, what is the molecular weight of the protein
Explain a lactic acid/lactate ion buffer solution : A lactic acid/lactate ion buffer solution contains 0.24 M HC3H5O3 and 0.82 M C3H5O3^-, respectively. The Ka value of lactic acid is 1.4*10^-4. Calculate the of this buffer. Express the pH numerically.
Calculate the minimum distance from the start to the goal : Calculate the minimum distance from the start to the goal with passing all the checkpoints -Specification * A map consists of 5 characters as following.
Explain what is the value for the equilibrium constant : What is the value for the equilibrium constant (K = KP ) at 1200 K for the reaction: 2HBr +1/2O2 ?? Br2 + H2O. b) What is the value of ?rG? at 1200 K temperature for the reaction in a)
Explain fuel consumed and combustion is assumed complete : Ethane enters furnace at 0.9 kg/min and burns with 200% excess air. 50% of fuel is consumed and combustion is assumed complete (meaning no CO is produced). Find the flow rate of Oxygen, Nitrogen,
Evaluate the criteria or mechanisms used by the organisation : Assess the budgeting process and procedures for the organisation with regards to preparation techniques, uses for evaluation, differences between business units/divisions, etc.
Explain how to analysis a compound : The analysis of a compound shows that it contains 20.0% H and 80.0% C. The empirical formula is:

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Every programming language have several commonalities

The basics of every programming language have several commonalities

  Trust and deception

Trust and Deception

  How to use the input validation

Requirement Determine if a word is a palindrome Using a cloulread in a word chaster by character Store each character in its own node.

  Write a command to do an alphabetical sort on the third fiel

Write the command to run the file called 'process' assuming it is in your current directory, has execute permission, but that your current directory is not in the standard path command search list:

  Describe a dbms and its functions updated dbms technology

Describe a DBMS and its functions. Name some of the popular DBMS software? You should search the Internet for the updated DBMS technology.

  Search the web for steganographic tools

Search the Web for steganographic tools.

  What is the order of the leaf node

The order of a leaf node in a B+ tree is the maximum number of pairs it can hold. Given that the block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9bytes long and a block pointer is 6bytes long, what is the order of t..

  What values are assigned to x when k has values

What values are assigned to x when k has values of 1,2,3,4, and 10?

  Expalin programs like ping and some of scanning tools

When using programs such as ping and some of the scanning tools to do forensic investigations, we may easily tip off the suspect that is under investigation

  Create a program that asks users to enter the name

Create a program that asks users to enter the name of their favorite team. Have the program display this team's name. Then have program ask the user to enter the name of their five previous oponents,

  Explaining distributed music in physical cds and mp3 files

For some time, popular music has been distributed on physical CDs. It can now be distributed in MP3 files. Explain the nature of the similarity or difference.

  Create an employeeexception class

Create an EmployeeException class whose constructor receives a String that consists of an employee's ID and pay rate. Create an Employee class with two fields, idNum and hourlyWage.

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