-
-
Save itsdebartha/2bdc865dac30dc902da1b521e54b28b4 to your computer and use it in GitHub Desktop.
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
rolls<-function() #function | |
{ | |
a<-sample(1:6,2);i<-1 #roll twice and set the roll counter as 1 | |
while(length(unique(a))!=6) #until all the faces have appeared | |
{ | |
a<-c(a,sample(1:6,2,replace=T)) #continue rolling in pairs | |
i=i+1 #and increase the counter | |
} | |
return(i) #return the number of rolls | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment