The perfect shuffling is to evenly divide a deck into two (26) parts, so that the loop repeats for a certain number of times and then changes back to the pre-shuffling order. That is, a_1, a_2 ........ a_n, B _1, B _2 ......... the B _n sequence is changed to B _1, a_1, B _2, a_2 ....... B _n, a_n I know this code is very SHI, just throwing bricks and asking you for better algorithms. Thank you.
The perfect shuffling is to evenly divide a deck into two (26) parts, so that the loop repeats for a certain number of times and then changes back to the pre-shuffling order. That is, a_1, a_2 ........ a_n, B _1, B _2 ......... the B _n sequence is changed to B _1, a_1, B _2, a_2 ....... B _n, a_n I know this code is very SHI, just throwing bricks and asking you for better algorithms. Thank you.
The perfect shuffling is to evenly divide a deck into two (26) parts, so that the loop repeats for a certain number of times and then changes back to the pre-shuffling order.
That is, a_1, a_2 ........ a_n, B _1, B _2 ......... the B _n sequence is changed to B _1, a_1, B _2, a_2 ....... B _n, a_n
I know this code is very SHI. I just threw bricks and asked everyone about better algorithms. Thank you!
<无>
// Perfect shuffling // $ time is the shuffling count function pshuffle ($ time = 8) {$ num = 52; $ res = $ data = range (1, $ num ); for ($ j = 0; $ j <$ time; $ j ++) {if ($ newdata) $ data = $ newdata; for ($ I = 0; $ I
<$num 2){$newdata[$i*2]="$data[$i];}else{$key" = $i * 2 - $num + 1;$newdata[$key]="$data[$i];}}//返回次数//" if($newdata="=" $res){ return $j+1; break; }}ksort($newdata);return $newdata;}< pre><$num>