Skip to content

Instantly share code, notes, and snippets.

@itsdebartha
Created August 22, 2022 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsdebartha/2bdc865dac30dc902da1b521e54b28b4 to your computer and use it in GitHub Desktop.
Save itsdebartha/2bdc865dac30dc902da1b521e54b28b4 to your computer and use it in GitHub Desktop.
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