Return to site

Let's play Countdown!

For those of you who do not know what Countdown is, it's a British game
show. There are two main games based on anagrams and simple mathematics as well as a final Countdown conundrum. Being stuck at work on a rainy Sunday allowed me to build the maths and the conundrum game in R. Have fun!
The numbers round
The rules
1. You get a choice of 6 numbers (big or small). You can change these parameters at the top of the code.
2. You then have 30 seconds to get to the randomly generated number at the top using those 6 numbers. You can divide, add, multiple and subtract. You do not need to use all of the numbers.
##How many bigs and how many smalls? A total of 6
top<-3
bottom<-3
##The game function, highlight all and run
big<-c(100,75,50,25)
small<-c(1,2,3,4,5,6,7,8,9,10)
cdown<-c(sample(big,top,replace=F),sample(small,bottom,replace=F))
plot(1,xlab="",ylab="",type="n",
     ,xaxt="n",yaxt="n")
rect(0.89,1.38,1.11,1.26,col="grey")
rect(0.9,1.37,1.1,1.27,col="black")
text(1,1.32,round(runif(1,0,999),0),col="green",cex=4.5)
rect(0.7,1.1,0.8,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.8,1.1,0.9,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.9,1.1,1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1,1.1,1.1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.1,1.1,1.2,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.2,1.1,1.3,1.2,col="blue",border="darkgrey",lwd=2)
text(0.75,1.15,cdown[1],col="white",cex=2)
text(0.85,1.15,cdown[2],col="white",cex=2)
text(0.95,1.15,cdown[3],col="white",cex=2)
text(1.05,1.15,cdown[4],col="white",cex=2)
text(1.15,1.15,cdown[5],col="white",cex=2)
text(1.25,1.15,cdown[6],col="white",cex=2)
rect(0.6,0.6,1.4,1.05,density=2,angle=90)
rect(0.6,0.6,1.4,1.05,density=2,angle=180)
#The above code runs without initiating the countdown timer.
#Run this code to include a 30 second countdown timer
for(i in round(seq(30, 1, length = 30),0)){
  rect(0.9,0.6,1.1,0.7,col="white")
  text(1,0.65,i,cex=5,col="red")
  p1 <- proc.time()
  Sys.sleep(1)
  proc.time()
}
#
Countdown conundrum
The rules
Run the code to produce a jumbled up 8 letter word. Simply unjumble the letters to find the word. The answer will appear after 30 seconds.
#Load the package and data
dd<-read.csv(url("http://files.figshare.com/2593506/8letterwords.csv"))
##Run all the code
ran<-round(runif(1,1,nrow(dd)),0)
t<-dd[ran,]
ran<-sample(seq(1,8,length=8),8)
plot(1,xlab="",ylab="",type="n",
     ,xaxt="n",yaxt="n")
rect(0.6,1.1,0.7,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.7,1.1,0.8,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.8,1.1,0.9,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.9,1.1,1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1,1.1,1.1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.1,1.1,1.2,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.2,1.1,1.3,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.3,1.1,1.4,1.2,col="blue",border="darkgrey",lwd=2)
text(0.65,1.15,substr(t,start=ran[1],stop=ran[1]),col="white",cex=4.5)
text(0.75,1.15,substr(t,start=ran[2],stop=ran[2]),col="white",cex=4.5)
text(0.85,1.15,substr(t,start=ran[3],stop=ran[3]),col="white",cex=4.5)
text(0.95,1.15,substr(t,start=ran[4],stop=ran[4]),col="white",cex=4.5)
text(1.05,1.15,substr(t,start=ran[5],stop=ran[5]),col="white",cex=4.5)
text(1.15,1.15,substr(t,start=ran[6],stop=ran[6]),col="white",cex=4.5)
text(1.25,1.15,substr(t,start=ran[7],stop=ran[7]),col="white",cex=4.5)
text(1.35,1.15,substr(t,start=ran[8],stop=ran[8]),col="white",cex=4.5)
for(i in round(seq(30, 0, length = 31),0)){
  rect(0.9,0.6,1.1,0.7,col="white")
  text(1,0.65,i,cex=5,col="red")
  p1 <- proc.time()
  Sys.sleep(1)
  proc.time()
}
rect(0.6,1.1,0.7,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.7,1.1,0.8,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.8,1.1,0.9,1.2,col="blue",border="darkgrey",lwd=2)
rect(0.9,1.1,1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1,1.1,1.1,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.1,1.1,1.2,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.2,1.1,1.3,1.2,col="blue",border="darkgrey",lwd=2)
rect(1.3,1.1,1.4,1.2,col="blue",border="darkgrey",lwd=2)
text(0.65,1.15,substr(t,start=1,stop=1),col="white",cex=4.5)
text(0.75,1.15,substr(t,start=2,stop=2),col="white",cex=4.5)
text(0.85,1.15,substr(t,start=3,stop=3),col="white",cex=4.5)
text(0.95,1.15,substr(t,start=4,stop=4),col="white",cex=4.5)
text(1.05,1.15,substr(t,start=5,stop=5),col="white",cex=4.5)
text(1.15,1.15,substr(t,start=6,stop=6),col="white",cex=4.5)
text(1.25,1.15,substr(t,start=7,stop=7),col="white",cex=4.5)
text(1.35,1.15,substr(t,start=8,stop=8),col="white",cex=4.5)
###end#####
All Posts
×

Almost done…

We just sent you an email. Please click the link in the email to confirm your subscription!

OKSubscriptions powered by Strikingly