Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
17 consonants out of scrabble tile distribution
## Drawing consonants in a row
tiles <- c(rep("V", 44), rep("C", 56)) # 42 vowels + 2 blanks, 56 consonants
# combined vowels and blanks into "V" as don't care about difference for this
# loop 1 million times
res<-NULL
for(i in 1:1000000){
draw <- sample(tiles, 17, F)
res[[i]]<-length(draw[draw=="C"])
}
library(ggplot2)
ggplot(data.frame(value=res),
aes(x=value)) +
geom_histogram(color="darkseagreen",
fill="lightseagreen")+
xlab("Number of consonants drawn")
sum(res==17) # number of times got 17 consonants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment