Talk:Deal cards for FreeCell: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
Line 21: Line 21:
==32 bit Perl fix==
==32 bit Perl fix==


The sample code for Perl works for perl 5.16 64 bit but not for perl 5.8 32 bit. This fix works.
The sample code for Perl works for perl 5.16 64 bit but not for perl 5.8 32 bit. This fix works for both.


<pre># return (($s = ($s * 214013 + 2531011) & 0x7fffffff) >> 16 );
<pre># return (($s = ($s * 214013 + 2531011) & 0x7fffffff) >> 16 );

Revision as of 17:07, 15 January 2013

task?

I see that although shuffle is not specified we have two implementations. But I have no way of knowing if they are correct implementations. Perhaps we should have an example? With this starting seed, we have this deck of cards? --Rdm 11:15, 19 September 2011 (UTC)

Example

I know this doesn't give the shuffle algorithm but ... it gives the result for seed=1 [1] and appears compatible with [2]

  1  2  3  4  5  6  7  8
 JD 2D 9H JC 5D 7H 7C 5H
 KD KC 9S 5S AD QC KH 3H
 2S KS 9D QD JS AS AH 3C
 4C 5C TS QH 4H AC 4D 7S
 3S TD 4S TH 8H 2C JH 7D
 6D 8S 8D QS 6C 3D 8C TC
 6S 9C 2H 6H

There is a reference to the shuffle algorithm here [3]

--Dgamey 14:26, 19 September 2011 (UTC)

32 bit Perl fix

The sample code for Perl works for perl 5.16 64 bit but not for perl 5.8 32 bit. This fix works for both.

#       return (($s = ($s * 214013 + 2531011) & 0x7fffffff) >> 16 );
        return (($s = ($s * 214013 + 2531011) % 2**31     ) >> 16 ); # fix for 32 bit perl