Beta

Damn those dwarves: A tale of gold nuggets

Description:

[Background]

Pounding. A loud noise comes from your friends whispering your name. You tell yourself this is the last time you let your dwarven friends take you out to the local inn for a game of flabbajacks. Slowly you open your eyes and ponder about the gold you won. You open your backpack and notice it is empty! Your friends burst out in laughter as you try to hold in that fine roasted deer you had for dinner last night.

Curse those dwarves! They took your winnings and hid them in a cave nearby! You pick up your backpack and waddle through the door to fetch your dearly beloved gold.

[Rules]

In this Kata you will receive a maze in string form. The goal of this Kata is to find your way to the exit while picking up all the gold nuggets, keeping the amount of points it will cost to a minimum. All given mazes are perfect squares.

A maze consists of the following characters:

# Wall
S Start Point
E End Point

All other characters can be treated as an open space.

You begin at the square marked with S and you can only move horizontally or vertically. Every move made costs one point. A nugget has a certain PickupCost and a Movecost. The pickup cost tells you how many points it costs to pick up the nugget. The MoveCost affects the total cost for a single move.

If no solution can be found , for example, if a StartPoint, EndPoint or nugget is closed off, the program should return -1;

[Example]

#####
#S E#
#   #
#. .#
#####

List of nuggets = new List() { new Nugget() { X = 1, Y = 3, PickupCost = 2, MoveCost = 9 }, new Nugget() { X = 3, Y = 3, PickupCost = 7, MoveCost = 5 }, };

In this example you would first move down 2 squares, adding 2 points to your total. Picking up the nugget at this location will cost you 2 extra points. Your total MoveCost now equals 10 (1+9). Moving 2 steps to the right costs you another 20 points. Picking up the second treasure will cost you 7 additional points. Now that you have collected all the nuggets it is time to go to the endpoint. Moving 2 steps up costs you 30 points (2*(1+9+5)).

The total costs now add up to 61: (2*1+2)+(2*10+7)+(2*15) This is the most efficient route.

Algorithms
Data Structures
Puzzles

Similar Kata:

Stats:

CreatedMay 6, 2016
PublishedMay 6, 2016
Warriors Trained76
Total Skips9
Total Code Submissions99
Total Times Completed5
C# Completions5
Total Stars4
% of votes with a positive feedback rating67% of 3
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • cresconio Avatar
  • hobovsky Avatar
Ad