Created
June 22, 2017 00:17
-
-
Save qdx/b15f74ac45fef1da488e3ca34487a897 to your computer and use it in GitHub Desktop.
Gold mining problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You manage a gold mining facility, to simplify mining, lets say each mine has multiple levels that gives you different profit. | |
For example, you may have 4 gold mines, let's call them a, b, c, d. | |
Each of them has a couple levels: | |
a: 1 level | |
b: 2 levels | |
c: 1 level | |
d: 4 levels | |
and each level have gives you different profit if you mine it: | |
a: 2 | |
b: 8, 4 | |
c: 6 | |
d: 3, 4, 4, 4 | |
To mine each level, you need a miner, for each extra level you want to reach, you need one extra miner. | |
Alternatively, there's a technique called explosive mining. You can finish up a single mine with only one miner, but with a profit less than the sum of all levels, greater than the first level, for example: | |
a: 2 | |
b: 9 | |
c: 6 | |
d: 5 | |
You want to know the maximu profit you can gain given a number of miners. | |
Exampls: | |
If you have 1 miner, you should do explosive mining in mine b to gain profit 9 | |
If you have 2 miner, explosive mine b, and normal mine c, to gain profit 9 + 6 = 15 | |
3 miners: explosive mine b and d, normal mine c, you have 9 + 6 + 5 = 20 | |
4 miners: normal mine b 2 levels, normal mine c, explosive mine d, you have 8 + 4 + 6 + 5 = 23 | |
5 miners: explosive mine b, normal mine c, normal mine d 3 levels, you have 9 + 6 + 3 + 4 + 4 = 26 | |
example input of above example: | |
{"a": {"explosive": 2, | |
"normal": [2]}, | |
"b": {"explosive": 9, | |
"normal": [8, 4]}, | |
"c": {"explosive": 6, | |
"normal": [6]}, | |
"d": {"explosive": 5, | |
"normal": [3, 4, 4, 4]} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment