You are viewing a single comment's thread. Return to all comments →
--- F# solution ---
let compress (msg: string) = let (_, _, res) = (msg + " ") |> Seq.fold (fun acum i -> let (pc, n, resmsg: StringBuilder) = acum match pc with | p when n = 0 -> (i, 1, resmsg) | p when p = i -> (p, n+1, resmsg) | _ -> (i, 1, resmsg.Append(pc).Append(match n with | 1 -> "" | _ -> n.ToString())) ) (' ', 0, StringBuilder()) res.ToString()
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
--- F# solution ---