Skip to content

Instantly share code, notes, and snippets.

@bleis-tift
Created December 17, 2014 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleis-tift/c99f1627e6445d24d9cd to your computer and use it in GitHub Desktop.
Save bleis-tift/c99f1627e6445d24d9cd to your computer and use it in GitHub Desktop.
http://d.hatena.ne.jp/teramonagi/20141215/1418648845 を参考にぞいを数えてみた
open System
let dic = [ ["今日"; "ぞい"]; ["も"]; ["1"; "ぞい"]; ["日"; "ぞい"]; ["がん"; "ぞい"]; ["ばる"; "ぞい"]; ["ぞい!"]]
let rnd = Random()
let makeZoi (xss: string list list) =
let rec makeZoi' (xss: string list list, count) =
match xss, count with
| xs::xss, count ->
let crnt = xs.[rnd.Next(List.length xs)]
let rest, count = makeZoi' (xss, if crnt.Contains("ぞい") then count + 1 else count)
crnt + rest, count
| [], count -> ("", count)
makeZoi' (xss, 0)
let countZoi (xss: string list list) =
let rec countZoi' count =
let zoi, cnt = makeZoi xss
printfn "%s" zoi
match zoi with
| "今日も1日がんばるぞい!" -> count
| _ -> countZoi' (count + cnt)
countZoi' 0
printfn "🌟 がんばるまで %d zoiでした🌟" (countZoi dic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment