module Exercise05 where -- May or may not be useful: computes the logarithm base 2 (rounded down) of the given number. -- You don't have to move this into the WETT tags if you want to use it. log2 :: (Integral a, Num b) => a -> b log2 = let go acc n = if n <= 1 then acc else go (acc + 1) (n `div` 2) in go 0 {-WETT-} decompose :: [Integer] -> [Integer] decompose ds |0 `elem` ds = [] -- if empty polyhedron -> just return an empty list |otherwise = (oldV - newV) : decompose newDims --otherwise fill with 1x1 so that all of the dimension are even and then solve the problem for the new Cube with newDims where newDims = map (`div` 2) ds --dimension of the new sub-cuboid with dimensions divided by 2 oldV = product ds -- volume of the old cuboid newV = product newDims * 2^length ds --volume of the new cuboid scaled by 2 -> corresponds to the volume of the old cuboid without the needed 1x1 cubes {-TTEW-}