In the game Settlers of Catan two dice are thrown at every turn to determine which areas of the island (represented by hexagonal tiles) will yield raw materials. In every area, a number is written. That number lays between 2 and 12 (boundaries included), but that differs from 7. Only the areas of which the number is equal to the sum of the dots of the dice thrown, will yield raw materials. There are five raw materials: wood, wool, grain, ore and stone. If the sum thrown equals 7, the area won't yield raw materials.
Given is a sequence of land tiles (areas) of the isle Catan (each with their own number and raw material) that form the board of a game of Settlers of Catan. Your assignment is to determine the most scarce raw material on this board, this is the material that will be yielded the least. For example: a board that contains three tiles with the material grass that are labeled with the numbers, 2, 8 and 8 will statistically yield more grass than a board with only two tiles of grass that are labeled with the numbers 2 and 8. If two or more materials have the smallest chance to be yielded, choose the material with the least amount of tiles on the board. In this last case, we guarantee that a unique kind of material occurs less than the rest.
Background calculation of probability: The chance you throw 2 with two dice is 1/36 (this is only possible if both dots are 1, with a chance 1/6 + 1/6). The chance you throw a 3 is 2/36 (1 + 2 or 2 + 1, each with a chance of 1/6 + 1/6, for a total of 2/36), and so on. The chance you throw a 12 is equal to the chance you throw a 2.
Write a function leastChance that determines for a given game board of the Settlers of Catan which raw material has the least chance of yielding something. To this function a string must be given that describes the tiles of a game board. Every tile is described by a letter that describes the raw material on the tile (for example H for wood, W for wool, G for grain, E for ore and S for stone), folowed by an integer between 2 and 12 (boundaries included). The different descriptions of the tiles on the game board are always separated by a single space. In contrast with the real game, the board in this assignment can consist of an arbitrary amount of tiles (at least 1) and more than 2 tiles can contain the same number or the same material. Moreover, more or less letters for materials may occur in contrast with the original game. The function must print the letter of the raw material that has the smallest chance to yield anything. If multiple materials have a minimal chance, the function should print the material with the least amount of tiles.
>>> leastChance('W2 H12 W4 E5 S4 G2 H5 W8')
'G'
>>> leastChance('S4 E6 W8 H9 G12 E3 W4 S2 G5 H5')
'S'
>>> leastChance('E2 H6')
'E'
>>> leastChance('W4 H4 W4')
'H'