Last active
December 18, 2015 13:28
-
-
Save jwbowers/5789800 to your computer and use it in GitHub Desktop.
Predicting the outcome of eenie meenie miney mo ... you are not it!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Eenie meenie miney mo, | |
## Catch a tiger by its toe | |
## If it hollers let it go, | |
## eenie meenie miney mo. | |
## My mom says that | |
## you are not it. | |
## The poem is 24 beats long (4 counts per line, 6 lines). | |
## The aim of the poem is to eliminate people from consideration as "it". | |
## Given n kids, you have to run the poem n-1 times on progressively shorter | |
## vectors of kids to find "it". The start position for the count is the person | |
## after the one who is "not it" each time. | |
## The question is who is "it". | |
## First letter of names of the eight girls in the Sisters Eight | |
## sisterseight<-c("A","D","G","J","M","P","R","Z") | |
## maybeit<-sisterseight | |
## princesses<-c("b","j","sw","c","aurora","t","a") | |
## maybeit<-princesses | |
findIt<-function(players){ | |
maybeit<-players | |
notit<-vector(length=length(players)-1) | |
for(i in 1:(length(players)-1)){ | |
## while(length(maybeit)>1){ | |
## replicate the player list to length 24. The 24th person is "not it" | |
notit[i]<-rep(maybeit,ceiling(24/length(maybeit)))[24] | |
maybeit<-maybeit[maybeit!=notit] | |
message(notit, " is not it. But, ", paste(maybeit,sep=",",collapse=" "), " could be it." ) | |
} | |
message(maybeit," is it!") | |
return(maybeit) | |
} | |
c(seq(which(princesses=="c")+1,length(princesses)),1:length(princesses))[1:length(princesses)] | |
## Belle first and Belle wins | |
## If we have seven princesses, then the first one is always it | |
findIt(c("belle","jasmin","snow","cinderella","aurora","tiana","ariel")) | |
## Now with six princesses | |
findIt(c("aurora","tiana","jasmin","snow","cinderella","ariel")) | |
findIt(c("tiana","jasmin","snow","cinderella","ariel")) | |
findIt(c("jasmin","snow","cinderella","ariel")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment