Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
Polynomial Regression with Interaction
Quiz 2
Teste de sheffé
Flower boxplot
EulerEx1
Pràctica 1
T4_EX01_9436451
Aula 16 agosto 2019
jcruet_bi variate regression model
19-08-2020-JacobiSistemaNewtonaprpx