Skip to content

Instantly share code, notes, and snippets.

@thisiswei
Created June 13, 2013 20:11
Show Gist options
  • Save thisiswei/5776932 to your computer and use it in GitHub Desktop.
Save thisiswei/5776932 to your computer and use it in GitHub Desktop.
fun getFinal init res =
let
fun helper total bet n =
case n+1 > size res of
true => total
| _ => if String.sub (res, n) = #"L"
then helper (total-bet) (bet*2) (n+1)
else helper (total+bet) 1 (n+1)
in
helper init 1 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment