Copyright | Copyright (C) 2021 Yoo Chung |
---|---|
License | GPL-3.0-or-later |
Maintainer | dev@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P49.
Documentation
gray :: Int -> [String] Source #
An n-bit Gray code is a sequence of n-bit strings constructed according to certain rules. For example,
>>>
gray 1 -- 1-bit gray code
["0","1"]
>>>
gray 2 -- 2-bit gray code
["00","01","11","10"]
>>>
gray 3 -- 3-bit gray code
["000","001","011","010","110","111","101","100"]
Infer the construction rules and write a function returning the n-bit Gray code.