I'm fairly new to programming and have a general computer programming logic that's been bugging me. This is just a logic problem that I've been trying to figure out as an exercise; not really a practical problem.
I have a stream of random binary numbers. I want to come up with an efficient code (I know there are many inefficient ways to do this) to use the random binary numbers to select a random item from a list of any length. Doing this with an even-numbered set is easy; you just use the 0 or 1 to keep splitting the list until you get a random number.
But doing this with an odd-numbered list has been surprisingly difficult. Maybe this is an actual difficult thing to do or maybe I'm just missing some logical step that's very obvious to experienced programmers.