module Solutions.P49 (gray) where
gray :: Int -> [String]
gray :: Int -> [String]
gray Int
0 = [String
""]
gray Int
1 = [String
"0", String
"1"]
gray Int
n
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1 = (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Char
'0':) [String]
g [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Char
'1':) ([String] -> [String]
forall a. [a] -> [a]
reverse [String]
g)
| Bool
otherwise = [String]
forall a. HasCallStack => a
undefined
where g :: [String]
g = Int -> [String]
gray (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1)