Perfect Shuffle Challenge

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,927
Office Version
  1. 365
Platform
  1. Windows
I was looking at this old challenge from @MrExcel, 'Perfect Shuffle Challenge'. It's from back in 2013. I thought that it would be fun to try this challenge with the new dynamic array formulas.

The objective is to see how many times you would need to do a perfect riffle shuffle in order for the deck to get back in its original order. I used 2 formulas. SHUFFLE, and RX, which is a recursive function.

SHUFFLE
Excel Formula:
=LAMBDA(deck,LET(d,deck,r,ROWS(d),s,SEQUENCE(r,,0),cc,HSTACK(TAKE(d,r/2),TAKE(d,-r/2)),INDEX(cc,QUOTIENT(s,2)+1,MOD(s,2)+1)))

RX
Excel Formula:
=LAMBDA(rng,[cnt],LET(s,SHUFFLE(rng),IF(AND(s=SEQUENCE(ROWS(s))),cnt+1,RX(s,cnt+1))))

PERFECT SHUFFLE
HI
242
364
483
5106
61210
71412
8164
9188
102018
11226
122411
132620
142818
153028
16325
173410
183612
193836
204012
214220
224414
234612
244823
255021
26528
275452
285620
295818
306058
316260
32646
336612
346866
357022
Sheet1
Cell Formulas
RangeFormula
H2:H301H2=SEQUENCE(300,,4,2)
I2:I35I2=RX(SEQUENCE(H2))
Dynamic array formulas.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Just playing around with this some more. Changing how the cards are shuffled together, i.e. which deck you use first after splitting the whole deck, means that it will take 52 shuffles to re-order the deck as opposed to only 8. I was only able to post half of the shuffles because of the character limit on the posts. I used unichar symbols to show the cards and a little conditional formatting to get the red and black decks.

Also, the shuffle formula is completely different using SEQUENCE, TOCOL, and CHOOSECOLS instead of MOD and QUOTIENT.

SHUFFLE
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1New Deck1234567891011121314151617181920212223242526
2🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾
3🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽
4🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻
5🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺
6🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹
7🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸
8🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷
9🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶
10🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵
11🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴
12🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳
13🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲
14🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱
15🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞
16🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝
17🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛
18🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚
19🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙
20🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘
21🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗
22🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖
23🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕
24🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔
25🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓
26🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒
27🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑
28🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎
29🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍
30🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋
31🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊
32🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉
33🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈
34🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇
35🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆
36🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅
37🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄
38🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃
39🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂
40🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁
41🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮
42🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭
43🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫
44🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪
45🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥🃓🂲🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩
46🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨
47🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧
48🂸🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦
49🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡🃑🂱🃇🂪🂥
50🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤
51🂻🃍🃞🂷🃊🃝🃆🃚🃅🂩🃕🂳🃈🃛🂶🂺🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣
52🂽🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢
53🂾🃎🂮🃗🂴🂹🃋🂭🂦🂣🃒🃁🂧🃔🃂🃘🃄🃙🂵🃉🂫🃖🃃🂨🂤🂢🂡
Sheet1
Cell Formulas
RangeFormula
C1:BB1C1=SEQUENCE(,52)
A2:A53A2=DECK()
C2:C53C2=SHUFFLE(A2#)
D2:AB53D2=SHUFFLE(C2#)
Dynamic array formulas.


NRNG
Excel Formula:
=LAMBDA(start,end,skip,LET(s,SEQUENCE(end-start+1,,start),UNICHAR(FILTER(s,s<>skip))))

DECK
Excel Formula:
=LAMBDA(LET(spades,NRNG(127137,127150,127148),hearts,NRNG(127153,127166,127164),diamonds,NRNG(127169,127182,127180),clubs,NRNG(127185,127198,127196),VSTACK(spades,diamonds,clubs,hearts)))

SHUFFLE
Excel Formula:
=LAMBDA(deck,INDEX(deck,TOCOL(CHOOSECOLS(TRANSPOSE(SEQUENCE(2,ROWS(deck)/2)),2,1))))
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

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