Need help with Roulette Excel question!

  • Thread starter Thread starter aftershock
  • Start date Start date
A

aftershock

I had a question in math class on Microsoft Excel.

The question was "Create a Excel expression that will show a result o
a roulette spin"

There are 0 to 32 numbers for the red spaces and 0 to 32 numbers fo
the black spaces.

I did this:

=INT(1+32)*RAND() to generate a random number between 0 to 32

but I don't know how to assign the number to the choices which are re
or black.

I thought it might be

=IF(A1<32,"red") A1 is the random number generated but it only assign
"red" to the number. I need an expression that would assign the rando
number with a random text (either red or black).




Please help!!!
 
One way

=VLOOKUP(INT(RAND()*(32-1)+1),{1,"Red";2,"Black";3,"Red";4,"Black";5,"Red";6
,"Black";7,"Red";8,"Black";9,"Red";10,"Black";11,"Red";12,"Black";13,"Red";1
4,"Black";15,"Red";16,"Black";17,"Red";18,"Black";19,"Red";20,"Black";21,"Re
d";22,"Black";23,"Red";24,"Black";25,"Red";26,"Black";27,"Red";28,"Black";29
,"Red";30,"Black";31,"Red";32,"Black"},2,0)
 
Note that isodd is part of the ATP.. You can use mod as well

=CHOOSE(MOD(INT(RAND()*(32-1)+1),2)+1,"Red","Black")

=IF(MOD(INT(RAND()*(32-1)+1),2)=1,"Red","Black")

I prefer not to use ATP when I can
 
Hi Peo,

I've grown accustomed to your superb expertise and figured
there was a good reason!

Biff
 
Peo Sjoblom said:
Note that isodd is part of the ATP.. You can use mod as well

=CHOOSE(MOD(INT(RAND()*(32-1)+1),2)+1,"Red","Black")

=IF(MOD(INT(RAND()*(32-1)+1),2)=1,"Red","Black")

I prefer not to use ATP when I can

Excellent formulae Peo!

However, as an aside to the OP, isn't there a green spot on zero?

I could be wrong - don't spend much time in casinos, but this would
make sense to me so that the casino has a little more than 50% chance
of winnning if you choose either red or black, but you only get the
chance to double your money thus giving them a profit margin.

Alan.
 
Biff,

is that your name (it means beef in Swedish)?
The reason I used a lookup formula in the first place was not because the
ATP,
it was because I wanted to illustrate the roulette colours the OP asked for.
The first formula I did was actually the choose formula. Having said that
given the ratio of posts asking about name errors I try if possible to avoid
ATP
even if sometimes that makes the formulas more complicated. I wish
things like networkdays, workdays, eomonth and mround were part of the
regular functions
since they are very useful and at least the first 2 require fairly
complicated workarounds..
 
Peo,

I agree with your logic. I am guilty of taking for granted
that *all users* have the ATP and it's loaded.

Biff
 
Back
Top