Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Numbers game from British game show Countdown
v = c(50,75,7,2,8,2) t = 841 countdown <- function(v,t){ if (v[1] == t) { return(TRUE) } else { for (i in 1:length(v)){ for (j in i:length(v)){ if (i<j) { l <- rep(TRUE,length(v)) l[i] = FALSE l[j] = FALSE a = max(v[i],v[j]) b = min(v[i],v[j]) if (countdown(c(a+b,v[l]),t)){ print(sprintf("%d + %d = %d",v[i],v[j],v[i]+v[j])) return(TRUE) } if (countdown(c(a-b,v[l]),t)){ print(sprintf("%d - %d = %d",v[i],v[j],v[i]-v[j])) return(TRUE) } if (countdown(c(a*b,v[l]),t)){ print(sprintf("%d * %d = %d",v[i],v[j],v[i]*v[j])) return(TRUE) } if (a/b == round(a/b)){ if (countdown(c(a/b,v[l]),t)){ print(sprintf("%d / %d = %d",v[i],v[j],v[i]/v[j])) return(TRUE) } } } } } return(FALSE) } } countdown(v,t)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Paired t-test [Shear Strength of Girder]
Learning
errores resta
ex1
Various matrix manipulations
untitled
EulerEx3
лул
Área sob curvas de funções: Integração numérica utilizando a regra do trapézio.
BTBsung
Please log in to post a comment.