d3a9e137db9698e4afd5e7bf84487c205fe4a7d7
[synacor-challenge.git] / src / CoinSolver.hs
1 import Data.Map.Strict as M
2 import Data.Map.Strict ((!))
3 import Data.List
4
5 data Coins = Red | Blue | Shiny | Corroded | Concave
6 deriving (Ord, Eq, Show, Enum, Bounded)
7
8 allCoins = [Red .. Concave]
9
10 main = print solve
11
12 coins :: M.Map Coins Int
13 coins = M.fromList $ zip [Red .. Concave] [2, 9, 5, 3, 7]
14
15 solve :: [[Coins]]
16 solve = [ [a, b, c, d, e]
17 | [a, b, c, d, e] <- permutations allCoins
18 , (coins ! a) + (coins ! b) * (coins ! c) ^2 + (coins ! d) ^3 - (coins ! e) == 399
19 ]