Skip to content

Instantly share code, notes, and snippets.

@bogardon
Last active December 15, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogardon/5328018 to your computer and use it in GitHub Desktop.
Save bogardon/5328018 to your computer and use it in GitHub Desktop.
Programming Question
So there's this game called Monster Hunter. Think of it like the Japanese WOW. It is extremely addicting and can ruin your life.
In the game, there are items called Charms, which you can think of like any other game accessory.
A Charm has two components. It has --
1. Slots
2. Skills
The game is constrained in such a way that every charm has 1-2 to skills and 0-3 slots.
A Skill also has two components. It has --
1. Name/Type
2. Value
For example. Evasion +5. Critical -3. Get it?
In MH, you get a lot of charms, which takes up valuable space in your inventory. We want to throw away "lesser" charms. So, let's compare some charms.
Charm A: 1 slot, Evasion +5
Charm B: 1 slot, Evasion +6
Which one is the better Charm? Charm B of course. Next!
Charm A: 1 slot, Evasion +5, Hearing +2
Charm B: 1 slot, Evasion +4, Hearing +3
Which one should we pick now? The answer is neither! Next!
Charm A: 1 slot, Evasion +1, Hearing +2
Charm B: 0 slot, Critical -3, Sharpness +5
The answer is STILL neither. Let's look at the last one.
Charm A: 2 slot, Crit +3
Charm B: 1 slot, Evasion -3
Which one? Charm A is the answer.
Now, write a program that compares two charms. A<=>B should yield 1 if A is better, -1 if B is better, 0 if they are not comparable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment