Talk:Perfect shuffle: Difference between revisions

m
fix typo
m (fix typo)
 
(6 intermediate revisions by 3 users not shown)
Line 33:
 
:::: I cannot think of any grounds for objection to shortening the sequence. Though for a decent workout, perhaps the sequence should be factorial values: 2 6 24 120 720 5040? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 04:20, 16 June 2015 (UTC)
 
:: When changing the solutions to only do the calculation for the 7 deck sizes suggested by Paddy3118, the Python solution finishes in 0.11 seconds and the Perl solution in 0.12 seconds, on my machine. With the values suggested by Rdm it takes a bit longer, but still reasonable (1.32 sec and 3.29 sec respectively).
:: So, +1 from me for this change (with either one of those sets). I'd also suggest listing the expected inputs and outputs as a "Test Cases" table in the task description, like I tend to do [[Convert_seconds_to_compound_duration|in my tasks]]:
::{| class="wikitable"
|-
! input ''(deck size)'' !! output ''(number of shuffles)''
|-
| 4 || 2
|-
| 16 || 4
|-
| 64 || 6
|-
| 256 || 8
|-
| 1024 || 10
|-
| 4096 || 12
|-
| 16384 || 14
|}
:: Or:
::{| class="wikitable"
|-
! input ''(deck size)'' !! output ''(number of shuffles)''
|-
| 2 || 1
|-
| 6 || 4
|-
| 24 || 11
|-
| 120 || 24
|-
| 720 || 359
|-
| 5040 || 2519
|}
:: --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 07:23, 16 June 2015 (UTC)
 
:: Or how about these inputs, for a nice mix of interesting cases:
::{| class="wikitable"
|-
! input ''(deck size)'' !! output ''(number of shuffles)''
|-
| 2 || 1
|-
| 100 || 30
|-
| 720 || 359
|-
| 1020 || 1018
|-
| 1024 || 10
|-
| 10000 || 300
|-
| 65536 || 16
|}
:: --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 07:52, 16 June 2015 (UTC)
 
::: +1 on using your third and last set of numbers (and the table). --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 08:33, 16 June 2015 (UTC)
 
:::: Some other possible sequences include 2^(2 .. 15) - 2:
::::{| class="wikitable"
|-
! input ''(deck size)'' !! output ''(number of shuffles)''
|-
| 2 || 1
|-
| 6 || 4
|-
| 14 || 12
|-
| 30 || 28
|-
| 62 || 60
|-
| 126 || 100
|-
| 254 || 110
|-
| 510 || 508
|-
| 1022 || 340
|-
| 2046 || 204
|-
| 4094 || 4092
|-
| 8190 || 774
|-
| 16382 || 16380
|}
 
:::: And 3^(2 .. 14) -3:
::::{| class="wikitable"
|-
! input ''(deck size)'' !! output ''(number of shuffles)''
|-
| 24 || 11
|-
| 78 || 30
|-
| 240 || 119
|-
| 726 || 140
|-
| 2184 || 1044
|-
| 6558 || 3198
|-
| 19680 || 2980
|-
| 59046 || 168
|-
| 177144 || 43332
|-
| 531438 || 6776
|-
| 1594320 || 397380
|}
 
:::: That last value might be excessive, but looking at the original task, for a sequence of 9950 numbers I get a cycle length of 9948. So if we are being true to the original task description I imagine we should include something similar in the updated requirements? Or is the 9950 example already an unreasonable burden? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 11:44, 16 June 2015 (UTC)
 
::::: I think 1020->1018 is sufficient as a "high number" example. There's nothing really to be gained by going higher, except for performance bench-marking but that's not what rosettacode is supposed to be about. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 13:04, 16 June 2015 (UTC)
 
: I felt like doing some improved HTML diagrams, so I went and updated the whole task while I was at it, using a list of values similar as I suggested above, but amended slightly to include 52 (the size of a standard card deck) and 8 (the example given in the introduction). It also has two powers of 10, two powers of 2, one factorial, and one number where the result is almost as big as the deck size (and also pretty right in absolute terms). I think that should cover everything of interest. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 13:01, 16 June 2015 (UTC)
Anonymous user