dice_flips <- c()
dice <- c(1, 2, 3, 4, 5, 6)
i <- 1
while (sum(dice_flips == 6) < 3){
dice_flips[i] <- sample(dice, size = 1)
i <- i + 1
}
dice_flips # 投擲紀錄
## [1] 3 1 5 4 6 3 4 1 1 5 1 5 1 3 5 1 4 5 2 1 5 2 2 5 3 6 6
length(dice_flips) # 總共投了幾次
## [1] 27