Remove value modification decision from plus_minus_two()
PATCH 1/7 Remove value modification decision from plus_minus_two()
From: Tyson Smith <[email protected]>
--- interesting-numbers.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
interesting-numbers.c +3 -4
@@ -7,15 +7,14 @@static unsigned int plus_minus_two (unsigned int num) {/* Now munge it for off-by-ones. */ -switch (rand () %5 ) { +switch (rand () %4 ) {case 0 : num -=2 ;break ;case 1 : num -=1 ;break ; -case 2 :return num; -case 3 : num +=1 ; +case 2 : num +=1 ;break ; -case 4 : num +=2 ; +case 3 : num +=2 ;break ; }return num;
Signature · 1 line
1.9.1
Quoted 1 line · On Wed, Mar 04, 2015 at 01:09:55PM -0800, [email protected] wrote:
From: Tyson Smith <[email protected]>
I just applied everything you sent so far. I could have gone either way on some of them, but given no-one else objected, I figured what the hell.
Now for N months of untraining muscle memory to replace rand_bool() with RAND_BOOL() etc.. :)
Dave