iwk #2314(2007/08/18 15:09 GMT) [ OCaml ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#light let rec bingo n = shuffle [1..n] and shuffle ls = let rnd = new System.Random() List.sort (fun x y-> rnd.Next(-1,2)) ls let printLine ln n = let rec len (m:int) = ( m.ToString() ).Length and mk (m:int) = (String.make ((len n) - (len m)) ' ') ^ m.ToString() and (|SplitAt|) m xs = List.partition (fun (x,i) -> i <= m) xs and mkLns c = function | [] -> [] | SplitAt c (head,tail) -> (List.unzip head)::mkLns (c+ln) tail and concatMap f xs = String.concat " " <| List.map f xs and bs = mkLns ln (List.zip (bingo n) [1..n]) [for (xs,ids) in bs -> (concatMap mk xs) ^ "\n" ^ (concatMap mk ids)] |> String.concat "\n" |> printf "%s\n" let bingoPr = fun n -> printLine 10 n
Rating0/0=0.00-0+
1 reply [ reply ]
iwk #2315(2007/08/18 15:11 GMT) Rating1/1=1.00
修正。 |> String.concat "\n" じゃなくて |> String.concat "\n\n" としないとお題のようにならないですね。
[ reply ]
iwk
#2314()
[
OCaml
]
Rating0/0=0.00
Rating0/0=0.00-0+
1 reply [ reply ]