A higher resolution is required to access the IDE
- 86
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
You are a Warrior in the fantasy world.You have a little money (
The world is represented by a rectangular grid. A position is denoted by its row number and its column number like this:
You can move 1 unit in any one direction (Right or Left or Up or Down) at a time. You have planned the path you will take, and written it down in shorthand, using
Each position in the world may contain money, an enemy or nothing. You have gathered the information in the following format:
position
position
When you get to a point of money or an enemy, you do the following:
• If you find some money, you pick up all the money. so after you got the money, it disappears from the map.
• If you encounter an enemy which is not a goblin e.g. a slime, you fight it and stop moving further (i.e. ignore the remaining untaken path).
• If you encounter a goblin and you have less than
• If you encounter a goblin and you have enough money, you pay the goblin
Output the result of your adventure:
• If you complete the planned path safely without fighting any enemies, output
• If you have to stop and fight an enemy, output your final position, the final amount of money you have and the name of the enemy, e.g.
Input
Line 1: A string s for the path you have planned to take.
Line 2: An integer n for the number of positions which you have information.
Next n lines: A string m for the information on a position.
Line 2: An integer n for the number of positions which you have information.
Next n lines: A string m for the information on a position.
Output
Line 1: A string for the result of the adventure.
If you complete the planned path:GameClear , your final position and the final amount of money you have
Otherwise: your final position, the final amount of money you have and the name of the enemy
If you complete the planned path:
Otherwise: your final position, the final amount of money you have and the name of the enemy
Constraints
1 ≤ s.length ≤ 100
s.length ≤ n ≤ s.length * 2
row number and column number in m are always integers
-50 ≤ row number, column number in m ≤ 50
1 ≤ money in m ≤ 100
s.length ≤ n ≤ s.length * 2
row number and column number in m are always integers
-50 ≤ row number, column number in m ≤ 50
1 ≤ money in m ≤ 100
Example
Input
ULULRDDLRU 14 -2 -3 enemy goblin -1 0 money 83G 2 -1 enemy goblin -2 2 enemy slime -1 1 money 31G -4 -2 enemy slime -3 0 enemy goblin -4 -1 money 17G 1 -3 money 60G 3 0 enemy slime 1 -2 enemy slime 3 -1 enemy goblin -1 -3 enemy slime 3 3 enemy goblin
Output
GameClear -1 -1 133G
A higher resolution is required to access the IDE