Guest User

Untitled

a guest
Nov 6th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. do {
  2.     if(!FlipCoin()) {
  3.         flips.Clear();
  4.     }
  5. } while(flips.Count < 10);
  6.  
  7. /*
  8. The problem is there's a 50% chance that every time the do-loop iterates FlipCoin will be false, and if it is it CLEARS flips causing flips.Count to never be larger than 10.  In order for flips.count to get larger than 10 and end the loop you have to get 10 flips in a row...which is like a 1/1024 chance of that to actually happen.  And because that's never happening, the do-loop is an infinite loop and it's locking up the unity editor.
  9. */
Advertisement
Add Comment
Please, Sign In to add comment