Join Nostr
2024-05-15 02:40:24 UTC

YoshikuniJujo on Nostr: /run haskell import Data.List import System.Random format :: String -> [Char] -> ...

/run haskell

import Data.List
import System.Random

format :: String -> [Char] -> String
format "" _ = ""
format ('_' : s) (c : cs) = c : format s cs
format (c : s) cs = c : format s cs

shuffle :: [a] -> IO [a]
shuffle xs =
(permutations xs !!) <$> randomRIO (0, product [1 .. length xs])

main = putStrLn . format "_ニ_リーム_ロッ_" =<< shuffle "カクケコ"