Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would process as below :</p> <p><strong>First you can shuffle each 4 decks (using FYK algorithm)</strong> </p> <p><strong>Then generate a 4 partitions (* I define partition below) of your 52 cards of 4 decks</strong> with the constraint of having not more than 3 element in each set of the partition :</p> <p>For example :</p> <pre><code>(1,3,0,3,2,0,1) would be a partition of 10 with this constraint (1,1,1,1,1,1,1,1,1,1) would be a partition of 10 too with this constraint </code></pre> <p><strong>Then Mix the 4 decks based on these partition.</strong></p> <p>For example if you have :</p> <pre><code>(3,2,1) (2,2,2) </code></pre> <p>you take the 3 first of deck one then 2 of deck 2 then 2 of deck one the 2 of deck 2 then 1 of deck 1 then 2 of deck 2. (okay ?)</p> <p>All partitions are not valid, so you need to add one more constraint :</p> <p>for example with this method :</p> <pre><code>(1,2,1,1,1,1,1,1) (3,3,3) </code></pre> <p>will end up having 4 elements of deck 1 at the end.</p> <p><strong>So the last partition must satisfy a constraint, I wrote a little python program to generate these partitions.</strong></p> <pre><code>from random import randint,choice def randomPartition(maxlength=float('inf'),N=52): ''' the max length is the last constraint in my expanation: you dont want l[maxlength:len(l)]) to be more than 3 in this case we are going to randomly add +1 to all element in the list that are less than 3 N is the number of element in the partition ''' l=[] # it's your result partition while(sum(l)&lt;N ): if (len(l)&gt;maxlength and sum(l[maxlength:len(l)])&gt;=3): #in the case something goes wrong availableRange=[i for i in range(len(l)) if l[i]&lt;3] #create the list of available elements to which you can add one while(sum(l)&lt;N): temp=choice(availableRange) #randomly pick element in this list l[temp]+=1 availableRange=[i for i in range(len(l)) if l[i]&lt;3] #actualize the list if availableRange==[]: #if this list gets empty your program cannot find a solution print "NO SOLUTION" break break else: temp=randint(0,min(N-sum(l),3)) # If everything goes well just add the next element in the list until you get a sum of N=52 l.append(temp) return l </code></pre> <p>Now you can generate the 4 partitions and mix the decks according to these partitions :</p> <pre><code>def generate4Partitions(): l1=randomPartition(); l2=randomPartition(); l3=randomPartition(); m=max(len(l1),len(l2),len(l3)) l4=randomPartition(m); return l1,l2,l3,l4 </code></pre> <p>This 4 partitions will always be admissible based on their definitions. </p> <p><strong>NOte:</strong></p> <p>There might be more cases where it's not admissible , for example :</p> <pre><code>(3,0,0,3) (0,3,3,0) </code></pre> <p>I guess this code needs to be modified a bit to take more constraints into account.</p> <p>But it should be easy, just to delete unwanted zeros,like this:</p> <pre><code>(3,0,3) (0,3,3,0) </code></pre> <p>Hope it's understandable and it helps</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload