Created
July 12, 2012 16:16
-
-
Save tsurushuu/3099119 to your computer and use it in GitHub Desktop.
find patterns in the difits of pi.
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
module Main where | |
import Data.List | |
hexTo01s :: Char -> String | |
hexTo01s '0' = "0000" | |
hexTo01s '1' = "0001" | |
hexTo01s '2' = "0010" | |
hexTo01s '3' = "0011" | |
hexTo01s '4' = "0100" | |
hexTo01s '5' = "0101" | |
hexTo01s '6' = "0110" | |
hexTo01s '7' = "0111" | |
hexTo01s '8' = "1000" | |
hexTo01s '9' = "1001" | |
hexTo01s 'a' = "1010" | |
hexTo01s 'b' = "1011" | |
hexTo01s 'c' = "1100" | |
hexTo01s 'd' = "1101" | |
hexTo01s 'e' = "1110" | |
hexTo01s 'f' = "1111" | |
main = do | |
cs <- readFile "hex.txt" | |
let datas = concatMap (hexTo01s) $ concat $ lines cs | |
print $ take 100 $ datas | |
print $ findIndex (isPrefixOf "0110") $ tails datas | |
print $ findIndex (isPrefixOf "010101010") $ tails datas | |
print $ findIndex (isPrefixOf "01011010010110100101") $ tails datas | |
print $ findIndex (isPrefixOf "0101010101010101010101010") $ tails datas | |
print $ findIndex (isPrefixOf "010101101010010101101010010101101010") $ tails datas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment