Created
February 23, 2018 17:52
-
-
Save AnthonyMikh/8d6c97de0faa2cf5b096177c3cbb98e5 to your computer and use it in GitHub Desktop.
Решение задачи №73 от UniLecs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tribonacci = 0:0:1:zipWith3 (\x y z -> x+y+z) tribonacci (tail tribonacci) (drop 2 tribonacci) | |
solutions = 0:drop 4 tribonacci | |
solution = (solutions !!) | |
main = print . solution $ 4 -- 13 |
Обоснование решения (сравнение с решением "в лоб"):
seed = ["00", "01", "10", "11"]
advanseSeq list@(x:y:_) = case (x, y) of
('1', '1') -> ['0':list]
_ -> ['0':list, '1':list]
advanse = concatMap advanseSeq
solutions = iterate advanse seed
lens = 0:2:map length solutions
tribonacci = 0:0:1:zipWith3 (\x y z -> x+y+z) tribonacci (tail tribonacci) (tail . tail $ tribonacci)
lens2 = 0:drop 4 tribonacci
main = print . take 15 $ zipWith (==) lens lens2
Вывод:
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playground: https://repl.it/repls/AdmiredSkeletalDisassembly