Created
December 17, 2014 02:48
-
-
Save bleis-tift/c99f1627e6445d24d9cd to your computer and use it in GitHub Desktop.
http://d.hatena.ne.jp/teramonagi/20141215/1418648845 を参考にぞいを数えてみた
This file contains 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
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