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

  Print a header line with appropriate labels for each column

Print a header line with appropriate labels for each column. Format each data line to vertically align each column right-justified.

  What is the output of this code sequence

What is the output of this code sequence?

  Explain significance of top management commitment

Explain the significance of top management commitment and development of standards for successful project management. Give examples to show the significance of these items based on experience on any type of project.

  Alice and bob are experimenting with csma using walsh table.

Alice and Bob are experimenting with CSMA using walsh table. Alice uses the code[+1,+1] and Bob uses the code[+1,-1]. Assume that they simultaneously send a hexadecimal digit to each other.

  Should digital dynamics use separate portals for employees

How could the concept of supply chain management apply to a company's service- based division? Provide some specific suggestions.

  Conduct an internet search for the oecd

The Organisation for Economic Co-operation and Development (OECD) has created a list of principles to aid organizations in dealing with people and organizations in different countries with different cultures.

  Compare iso-iec outline with nist documents

Compare the ISO/IEC 27001 outline with the NIST documents outlined in 'Management of Information Security' (by Michael E. Whitman, Herbert J. Mattord).

  Difference between a permanent address and a care-of address

How big is the MAC address space? The IPv4 address space and what is the difference between a permanent address and a care-of address? Who assigns a care-of address?

  Compute mean number of rounds per contention period

Determine the probability that the contention ends on round k, and compute the mean number of rounds per contention period?

  Write a program to find the number of comparisons

Write a program to find the number of comparisons using the binary search and sequential search algorithms as follows:Suppose list is an array of 1000 elements.

  Consider a server with poisson job-arrival stream

Consider a server with Poisson job-arrival stream at an average rate of 60 per hour. Determine the probability that the time interval between successive job arrivals is

  Calculate the average for each student and for each exam

The original program is supposed to ask the user to enter 3 grades for 5 students, and then calculate the average for each student and for each exam.

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