Skip to content

Instantly share code, notes, and snippets.

@nabe256
Created March 21, 2016 12:00
Show Gist options
  • Save nabe256/117fba059cb17dd5f85e to your computer and use it in GitHub Desktop.
Save nabe256/117fba059cb17dd5f85e to your computer and use it in GitHub Desktop.
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