Skip to content

Instantly share code, notes, and snippets.

@tmasjc
Last active July 3, 2020 06:32
Show Gist options
  • Select an option

  • Save tmasjc/d98b573de473eea8910b00f85e6b4cb0 to your computer and use it in GitHub Desktop.

Select an option

Save tmasjc/d98b573de473eea8910b00f85e6b4cb0 to your computer and use it in GitHub Desktop.
another dynamic programming
cuts = 0.8 # cutoff level
maxN = 100 # number of trials
run_game <- function(vec, cutoff, N) {
# browser()
if (length(vec) > N) {
return(vec)
}
pass = ifelse(mean(vec) >= cutoff, 0, 1)
vec = c(vec, pass)
run_game(vec, cutoff = cutoff, N = N)
}
run_game(1L, cutoff = cuts, N = maxN)
@tmasjc
Copy link
Copy Markdown
Author

tmasjc commented Jul 3, 2020

How to solve C-stack limit problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment