[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

need all possible variations of RED or BLACK for  5 roulette spins.

Posted on 2011-10-28
17
Medium Priority
?
323 Views
Last Modified: 2012-05-12
need all possible variations of RED or BLACK for  5 roulette spins.
0
Comment
Question by:khbat
  • 3
  • 3
  • 2
  • +6
15 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 37048508
RRRRR
RRRRB
RRRBR
RRRBB
RRBRR
RRBRB
RRBBR
RRBBB
RBRRR
RBRRB
RBRBR
RBRBB
RBBRR
RBBRB
RBBBR
RBBBB
BRRRR
BRRRB
BRRBR
BRRBB
BRBRR
BRBRB
BRBBR
BRBBB
BBRRR
BBRRB
BBRBR
BBRBB
BBBRR
BBBRB
BBBBR
BBBBB
0
 

Expert Comment

by:delger
ID: 37048549
I thought it has 64 variations. 4-8-16-32-64.Am I wrong?
0
 
LVL 85

Expert Comment

by:ozo
ID: 37048562
How many variations for one spin?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 

Author Comment

by:khbat
ID: 37048578
sorry.I was wrong.thanks
0
 
LVL 33

Expert Comment

by:Paul Sauvé
ID: 37050368
number of possibilities per spin ** number of spins
0
 
LVL 28

Expert Comment

by:dpearson
ID: 37051057
If you're actually talking about Roulette don't forget there is a space (or two) on the wheel that is green - i.e. neither red nor black.  This of course is how the house gets its advantage - since the odds of either red or black is slightly less than 50% and the payoff is exactly 50%.

So the sequence is really:
[RED | BLACK | GREEN] ^ (number-spins)

e.g. for 2 spins:
RR
RB
RG

BR
BB
BG

GR
GB
GG

The pattern should be pretty obvious :)

Doug
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 37055776
Hi khbat,

You are posting this in the AS/400 zone, do you need AS/400 routines (RPG) for this?
0
 
LVL 27

Expert Comment

by:tliotta
ID: 37059265
Is it clear that combinations of R and B are nothing more than combinations of '1' and '0' in binary numbers? It just uses different symbols for the digits.

[00000] can have the same logical meaning as [RRRRR]. Likewise, [01100] can be used to represent [RBBRR].

From there, it should be clear that "all possible variations of RED or BLACK for  5 roulette spins" is just a different way of saying "all binary numbers from 00000 to 11111".

Tom
0
 

Expert Comment

by:delger
ID: 37060429
Is there are special program to get "all binary numbers".i'd like to have all posibilities from 5 to 10 or maybe even 15 times?
0
 

Expert Comment

by:delger
ID: 37060434
murphey2:Hi khbat,

You are posting this in the AS/400 zone, do you need AS/400 routines (RPG) for this?

 Sorry,i do not understand what you mean.
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 37060880
You asked this question in the zones: Programming for iSeries / AS400, Algorithms, Theory

So I was wondering if you need this for an AS/400 system?

If not what language can you read, I can send you a routine, even a EXCEL macro if you like?



0
 
LVL 2

Expert Comment

by:mtgradwell
ID: 37062390
@delger: "Is there are special program to get "all binary numbers"?
A simple for-loop can do this. In c, it's

for (i = 0; i< (2 <<num_digits); i++){desired-action-goes-here}

where num_digits is 5 to 10 or maybe even 15.
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 37062538
Hi Delger,

mtgradwell is right, but that works only for the situation Red vs. Black. if green is involved, I'm not sure if it will function.

but theoretically it's not that complex,

In a binary system you have 2 digits (0 to 1), so 2 is the base number
in a decimal system you have 10 digits (0 to 9) so 10 is the base the number

in a Binary 101 means

1 * 2^0 = 1 * 1 = 1
0 * 2^1 = 0 * 2 = 0
1 * 2^2 = 1 * 4 = 4
total = 5 so 101 is 5

in a Decimal system
1 * 10^0 = 1 * 1 = 1
0 * 10^1 = 0 * 10 = 0
1 * 10^2 = 1 * 100 = 100
total = 101 so 101 is 101  :)

If we use that in an Octal system 8 digits (0-7)
1 * 8^0 = 1 * 1 = 1
0 * 8^1 = 0 * 8 = 0
1 * 8^2 = 1 * 64 = 64
total = 65 so 101 is 65

and yes hexadecimal works the same :-)

Knowing this you can program whatever language you like, the basics are all the same.

Regards,
murph
0
 
LVL 27

Expert Comment

by:tliotta
ID: 37078994
I don't know what the AS/400 forum has to do with this, but I used the basic EDTF editor to create a java function that runs on an AS/400 to do this. With no help from the editor, this is a crude example, but it should work anywhere. I didn't put any real thought into how it could be done better. The string handling could be much more efficient.

public class MyPow {
public static void main(String argv[]) {

int limit = 5;
String a = "";
String b = "";

for (int j = 0; j < limit ; j++)
    a = a + "R";

for(int i=0;i<Math.pow(2, limit);i++) {
    b = a + Integer.toBinaryString(i);
    System.out.println((b.substring(b.length()-limit).replace('0','R')).replace('1','B'));
    }
  }
}

Open in new window

It uses limit to set how many spins to tabulate.

It creates a simple string of Rs first -- that string is as wide as the number of spins, so it creates "RRRRR" when limit=5.

It then loops through binary numbers from zero through 2 raised to the power of limit. Each binary number is converted to a string with Integer.toBinaryString() and that's appended to the original string of Rs.

The right-most substring is taken from that string for limit characters. The substring then has any 0s replaced with Rs, and the result of that has any 1s replaced with Bs. The final result of each one is printed to standard output.

Change limit to show the number of spins you're interested in. All combinations of Rs and Bs should be listed. It ought to run pretty much unchanged wherever you can run java.

Tom
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 37272019
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question