A Random Challenge

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Here’s a little challenge for everyone:

Object
Enter formula(s) in each of 6 cells A1:F1 such that when the worksheet is calculated it produces a random integer between 0 and 9 in each cell with no repeats.

Rules
Formulas only, no macros/vba
Shortest formula wins (total number of characters over all 6 cells)
Random numbers must be generated equally over a large number of trials

Good Luck!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Not very random Steve, 9 never appears and 3,4 & 5 appear every time.
 
Upvote 0
in A1:

Code:
=round(rand()*10;0)-1

in b1 and copied right:
Code:
=if(a1=9;0;a1+1)

That's 20 + 15*5 = 95 characters. All values are random, are not repeated, and occur with the same freqency.
 
Upvote 0
If analysis toolpak is allowed, using randbetween shortens my formula a little bit.
 
Upvote 0
Jubjab, that certainly does the trick in terms of frequency, however, it does mean that you get a sequence of consecutive numbers each time which in itself does not produce 6 independently-random-non-repeated numbers of which there are 151,200 combinations, but rather one of ten possible sequences.
 
Upvote 0
Independantly random was not a requirement in the original post. And Non Sequencial Was Not a requirement either.
 
Upvote 0
You can do this with a helper row, i.e. put this formula in A2

=RAND()

copy across to J2

In A1

=RANK(A2,$A2:$J2)-1

copy across to F1

hide row 2 if you wish

Or......you can accomplish this with a single (rather long) formula, see pgc01's suggestion here
 
Upvote 0
=round(rand()*10;0)-1

This wouldn't be a good way to generate a random number between 0 and 9. It'll generate some -1s :cry: and fewer 9s than other numbers. To generate 0 to 9 with the same frequency

=INT(RAND()*10)
 
Upvote 0
Jonmo, I appreciate that the “randomness” was perhaps not fully defined in the original post, but I did ask that a random integer was produced in each cell, jubjab’s solution does not produce a random number in each cell it only produces 1 random number in A1 with all the other cells explicitly dependant on it. Thus you can precisely “predict” the results in cells B1:F1 based on A1 making it non-random.

Barry, your solution only produces values from 0-5.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top