Created
March 21, 2016 12:00
-
-
Save nabe256/117fba059cb17dd5f85e to your computer and use it in GitHub Desktop.
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
import System.Random | |
import Control.Monad | |
main :: IO() | |
main = print showKiyoshi | |
getRandomInt :: IO Int | |
getRandomInt = getStdRandom $ randomR (0,1) :: IO Int | |
text :: [String] | |
text = ["zun", "doko", "kiyoshi"] | |
terminator :: [Int] | |
terminator = [0,0,0,0,1] | |
getRandom :: [Int] | |
getRandom = randomRs (0,1) (mkStdGen 1) :: [Int] | |
getNth :: Int -> [Int] | |
getNth n = take (n+5) getRandom | |
findMatch :: Int -> Int | |
findMatch n = if drop n (getNth n) == terminator | |
then n | |
else findMatch (n+1) | |
showText :: Int -> String | |
showText n = text!!n | |
showKiyoshi :: [String] | |
showKiyoshi = map showText (getNth (findMatch 0) ++ [2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment