generating random numbers without consecutive repetition
objective-c, random
Solution
int oldrand = <prior random number>;
int adder = randomNumberGenerator() % 4;
int newrand = (oldrand + adder + 1) % 5;
Problem
How can I generate random integers from 0 - 4 in such a way that the same number is not generated twice consecutively? For example, if 3 is the number that is generated the first time then 0,1,2,4 will be the possible numbers for random generation the second time. If 2 is generated the second time then 0,1,3,4 will be the possible numbers for random generation the third time and so on.