Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well there are is a small problem with the assumptions you have</p> <p>Rule 1</p> <p><code>The overall goal is that each list has no relationship or common pattern to it's previous list.</code></p> <p>Rule 2</p> <p><code>The rule is that the first element of the list and the last element can't be the start and end elements from the previous list.</code></p> <p>Those two contradict each other. First there may be no relationship, so random. So as you said shuffle (did not look at is I take your word). But the second one needs to know about the previous one. What contradicts with your previous rule.</p> <p>But what you could do is have the first and last element of the previous draw (the previous 52). Then you shuffle the current draw. If the first and/or last element are the same, draw again until no match is found. </p> <p>Also I think the word for this is semi-random.</p> <p>Look at the <code>do{ }while();</code> for the trick.</p> <hr> <p>After the comment of not having the same 4 elements after each other the next part came.</p> <p>What you need is way to identify the elements, so lets assume every "item" has an id (for the purpose of the example I only use 5 elements)</p> <p>Lets use the following</p> <pre><code>array( 0 =&gt; array('id' =&gt; 1,), 1 =&gt; array('id' =&gt; 2,), 2 =&gt; array('id' =&gt; 3,), 3 =&gt; array('id' =&gt; 4,), 4 =&gt; array('id' =&gt; 5,), ) </code></pre> <p>The next draw is exaclty the same (just for the purpose of the exaple). What we do is we make an array of the ids that are drawn:</p> <pre><code>array( 0 =&gt; 1, 1 =&gt; 2, 2 =&gt; 3, 3 =&gt; 4, 4 =&gt; 5, ) </code></pre> <p>Then use this array in the following function (not checked but should give you a right start)</p> <pre><code>function check(array $prev, array $draw, $the_same = 4) { $to_check = count($prev) - $the_same; for($i = 0; $i &lt; $to_check; $i++) { if ($array_slice($prev, $i, $the_same) === array_slice($draw, $i, $the_same)) { return false; } } return true; } </code></pre> <p>What is does, you give it the old array and the one you drew, and you give the number with it with how many occurence may be after eachother that maybe the same. Then it just start looping and array slicing to check if they are equal.</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. VO
      singulars
      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