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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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