Jan 13, 2025
10:13:52pm
SalmonOfCapistrano All-American
I wouldn't be surprised if there's something off by one. It could be clearer
as well. Heck, could even use recursion to cut down on number of lines


int myRandom() {
int rand = random();
return rand ≠ 5 ? rand % 2 : myRandom();
}

(note el jefe changed not equals to the not equals sign.. sigh)


Personally I'd stick with the loop though.
This message has been modified
Originally posted on Jan 13, 2025 at 10:13:52pm
Message modified by SalmonOfCapistrano on Jan 13, 2025 at 10:14:28pm
Message modified by SalmonOfCapistrano on Jan 13, 2025 at 10:15:35pm
SalmonOfCapistrano
Previous username
Pedant
Bio page
SalmonOfCapistrano
Joined
Feb 1, 2012
Last login
Jan 16, 2025
Total posts
11,316 (81 FO)
Messages
Author
Time
Jan 13, 10:03pm
Jan 13, 10:03pm

Posting on CougarBoard

In order to post, you will need to either sign up or log in.