Need help with Roulette Excel question!

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!!!
 
P

Peo Sjoblom

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)
 
B

Biff

I think this could be shortened to:

=IF(ISODD(INT(RAND()*(32-1)+1)),"RED","BLACK")

Biff
 
P

Peo Sjoblom

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
 
B

Biff

Hi Peo,

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

Biff
-----Original Message-----
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

--

Regards,

Peo Sjoblom

Biff said:
I think this could be shortened to:

=IF(ISODD(INT(RAND()*(32-1)+1)),"RED","BLACK")

Biff
-----Original Message-----
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)

--

Regards,

Peo Sjoblom


I had a question in math class on Microsoft Excel.

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

There are 0 to 32 numbers for the red spaces and 0 to 32 numbers for
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 red
or black.

I thought it might be

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




Please help!!!!


------------------------------------------------
[/url]
~~View and post usenet messages directly from http://www.ExcelForum.com/



.


.
 
A

Alan

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.
 
P

Peo Sjoblom

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..

--

Regards,

Peo Sjoblom


Biff said:
Hi Peo,

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

Biff
-----Original Message-----
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

--

Regards,

Peo Sjoblom

Biff said:
I think this could be shortened to:

=IF(ISODD(INT(RAND()*(32-1)+1)),"RED","BLACK")

Biff

-----Original Message-----
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)

--

Regards,

Peo Sjoblom

"aftershock" <[email protected]>
wrote in message

I had a question in math class on Microsoft Excel.

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

There are 0 to 32 numbers for the red spaces and 0 to
32 numbers for
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 red
or black.

I thought it might be

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




Please help!!!!


------------------------------------------------
[/url]
~~View and post usenet messages directly from
http://www.ExcelForum.com/



.


.
 
B

biff

Peo,

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

Biff
-----Original Message-----
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..

--

Regards,

Peo Sjoblom


Biff said:
Hi Peo,

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

Biff
-----Original Message-----
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

--

Regards,

Peo Sjoblom

I think this could be shortened to:

=IF(ISODD(INT(RAND()*(32-1)+1)),"RED","BLACK")

Biff

-----Original Message-----
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,4,"Black";15,"Red";16,"Black";17,"Red";18,"Black";19,"Red"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)

--

Regards,

Peo Sjoblom

"aftershock" <aftershock.xfcpa@excelforum- nospam.com>
wrote in message

I had a question in math class on Microsoft Excel.

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

There are 0 to 32 numbers for the red spaces and 0 to
32 numbers for
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 red
or black.

I thought it might be

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




Please help!!!!


------------------------------------------------
[/url]
~~View and post usenet messages directly from
http://www.ExcelForum.com/



.



.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top