Done very quickly, but works.
F#
let deafRats s= let rec inner s (piper, deaf) = if s = "" then deaf else match s.[0..1] with | x when x.[0] = 'P' -> inner s.[1..] (1, deaf) | "O~" -> inner s.[2..] (piper, deaf + (1-piper)) | "~O" -> inner s.[2..] (piper, deaf + piper) | _ -> inner s.[1..] (piper, deaf) inner s (0, 0)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Done very quickly, but works.
F#