You have two different random calls in your cond statement. Both are independent and may give you different results. Thus, it is possible that the first (random 2) evaluates to 0 , and the second evaluates to 1 , which causes both of these cases to fail and gives you "impossible" .
The solution is to put the result (random 2) in a local variable with let-statement, making sure that random is called only once.
source share