在列之间随机分配整数值

时间:2012-07-10 22:27:44

标签: php mysql math statistics

我正在制作纸牌游戏,我需要先创建卡片并将它们存储在mysql表格中。我正在试图弄清楚如何制作一个PHP脚本来创建它们。 好吧,有6种类型的值从0到12不等,每张卡都有每个类别的值。每张卡片中各类别的价值总和必须为36.所以每张卡片都是这样的:

  • 6 - 9 - 2 - 10 - 6 - 3

OR

  • 0 - 12 - 0 - 12 - 0 - 12

或偶然

  • 6 - 6 - 6 - 6 - 6 - 6

我认为如果我可以随机生成50或60张牌,那就太棒了。

提前致谢。

3 个答案:

答案 0 :(得分:5)

这样的事情应该有效 - 逻辑可能有点偏,我还没有测试过。

function generate_card() {
    $max_card = 12;  // What's the highest value of a card number?
    $min_card = 0;   // What's the lowest value of a card number?
    $num_cards = 6;  // How many numbers on a card?
    $total = 36;     // What's the desired sum?
    $numbers = array();
    $running_total = 0;
    for ($i = 0; $i < $num_cards; ++$i) {
        $max = min($max_card, $total - $running_total); //The highest number we can choose
        $min = max($min_card, $total - $running_total - ($max_card * ($num_cards - ($i + 1)))); //The lowest number we can choose

        //- how much is left ? $total - $running total
        //- min is amount_left - ($max_card

        $number = rand($min, $max);
        $running_total += $number;
        $numbers[] = $number;
    }

    return $numbers;
}

编辑:我错放了一个括号和一个索引,它现在正常工作。

答案 1 :(得分:2)

一种非常天真的方法是:

/* return an array of 6 numbers between 0 and 12 that sum to 36 */
generate_card() {
    $numbers = array();
    for($i = 0; $i < 6; $i += 1) {
        $numbers[$i] = rand(0, 12);
    }
    if (array_sum($numbers) !== 36) {
        return generate_card(); // repeat until we find one that does sum to 36
    } else {
        return $numbers; // yay!
    }
}

我认为这对于“简单的纸牌游戏”来说效果还不错。

答案 2 :(得分:0)

我知道你已经为此选择了答案,但我认为无论如何我都会考虑我的解决方案,因为我觉得它带来了一些东西。

问题的一部分是“随机手”的含义在这里有点模糊。如果你想要一张真正随机的6张卡牌总数达到36张,那么你必须有相同的机会从所有可能的牌中挑选总数为36的牌。

数字可以求和的方式称为 partitioning 。我写了一个算法来生成36的所有可能的分区。那是17000个分区。然后我淘汰了使用超过12的数字的任何分区,然后我淘汰了涉及6个以上数字的任何分区。这让我有676张可能的6手牌总数达到36手。

我将采取的方法,即确保完全随机性,是从所有可能的手的数组中随机选择。它的存储密集程度更高(你必须存储数组),但比任何建议的方法都要快得多(因为你只选择一个随机数,然后将其从数组中取出)。这是缩写代码(完整代码):

$allHands = array(
    array(12,12,12,0,0,0),
    array(12,12,11,1,0,0),
    array(12,12,10,2,0,0),
    array(12,12,10,1,1,0),
    // ...etc
);
$hand = $allHands[ rand( 0, count($allHands)-1 ) ];
shuffle( $hand );
// $hand is now a completely random hand of 6 cards summing to 36

以下是所有可能的牌的完整数组:

$allHands = array(
    array( 12, 12, 12, 0, 0, 0 ),
    array( 12, 12, 11, 1, 0, 0 ),
    array( 12, 12, 10, 2, 0, 0 ),
    array( 12, 12, 10, 1, 1, 0 ),
    array( 12, 12, 9, 3, 0, 0 ),
    array( 12, 12, 9, 2, 1, 0 ),
    array( 12, 12, 9, 1, 1, 1 ),
    array( 12, 12, 8, 4, 0, 0 ),
    array( 12, 12, 8, 3, 1, 0 ),
    array( 12, 12, 8, 2, 2, 0 ),
    array( 12, 12, 8, 2, 1, 1 ),
    array( 12, 12, 7, 5, 0, 0 ),
    array( 12, 12, 7, 4, 1, 0 ),
    array( 12, 12, 7, 3, 2, 0 ),
    array( 12, 12, 7, 3, 1, 1 ),
    array( 12, 12, 7, 2, 2, 1 ),
    array( 12, 12, 6, 6, 0, 0 ),
    array( 12, 12, 6, 5, 1, 0 ),
    array( 12, 12, 6, 4, 2, 0 ),
    array( 12, 12, 6, 4, 1, 1 ),
    array( 12, 12, 6, 3, 3, 0 ),
    array( 12, 12, 6, 3, 2, 1 ),
    array( 12, 12, 6, 2, 2, 2 ),
    array( 12, 12, 5, 5, 2, 0 ),
    array( 12, 12, 5, 5, 1, 1 ),
    array( 12, 12, 5, 4, 3, 0 ),
    array( 12, 12, 5, 4, 2, 1 ),
    array( 12, 12, 5, 3, 3, 1 ),
    array( 12, 12, 5, 3, 2, 2 ),
    array( 12, 12, 4, 4, 4, 0 ),
    array( 12, 12, 4, 4, 3, 1 ),
    array( 12, 12, 4, 4, 2, 2 ),
    array( 12, 12, 4, 3, 3, 2 ),
    array( 12, 12, 3, 3, 3, 3 ),
    array( 12, 11, 11, 2, 0, 0 ),
    array( 12, 11, 11, 1, 1, 0 ),
    array( 12, 11, 10, 3, 0, 0 ),
    array( 12, 11, 10, 2, 1, 0 ),
    array( 12, 11, 10, 1, 1, 1 ),
    array( 12, 11, 9, 4, 0, 0 ),
    array( 12, 11, 9, 3, 1, 0 ),
    array( 12, 11, 9, 2, 2, 0 ),
    array( 12, 11, 9, 2, 1, 1 ),
    array( 12, 11, 8, 5, 0, 0 ),
    array( 12, 11, 8, 4, 1, 0 ),
    array( 12, 11, 8, 3, 2, 0 ),
    array( 12, 11, 8, 3, 1, 1 ),
    array( 12, 11, 8, 2, 2, 1 ),
    array( 12, 11, 7, 6, 0, 0 ),
    array( 12, 11, 7, 5, 1, 0 ),
    array( 12, 11, 7, 4, 2, 0 ),
    array( 12, 11, 7, 4, 1, 1 ),
    array( 12, 11, 7, 3, 3, 0 ),
    array( 12, 11, 7, 3, 2, 1 ),
    array( 12, 11, 7, 2, 2, 2 ),
    array( 12, 11, 6, 6, 1, 0 ),
    array( 12, 11, 6, 5, 2, 0 ),
    array( 12, 11, 6, 5, 1, 1 ),
    array( 12, 11, 6, 4, 3, 0 ),
    array( 12, 11, 6, 4, 2, 1 ),
    array( 12, 11, 6, 3, 3, 1 ),
    array( 12, 11, 6, 3, 2, 2 ),
    array( 12, 11, 5, 5, 3, 0 ),
    array( 12, 11, 5, 5, 2, 1 ),
    array( 12, 11, 5, 4, 4, 0 ),
    array( 12, 11, 5, 4, 3, 1 ),
    array( 12, 11, 5, 4, 2, 2 ),
    array( 12, 11, 5, 3, 3, 2 ),
    array( 12, 11, 4, 4, 4, 1 ),
    array( 12, 11, 4, 4, 3, 2 ),
    array( 12, 11, 4, 3, 3, 3 ),
    array( 12, 10, 10, 4, 0, 0 ),
    array( 12, 10, 10, 3, 1, 0 ),
    array( 12, 10, 10, 2, 2, 0 ),
    array( 12, 10, 10, 2, 1, 1 ),
    array( 12, 10, 9, 5, 0, 0 ),
    array( 12, 10, 9, 4, 1, 0 ),
    array( 12, 10, 9, 3, 2, 0 ),
    array( 12, 10, 9, 3, 1, 1 ),
    array( 12, 10, 9, 2, 2, 1 ),
    array( 12, 10, 8, 6, 0, 0 ),
    array( 12, 10, 8, 5, 1, 0 ),
    array( 12, 10, 8, 4, 2, 0 ),
    array( 12, 10, 8, 4, 1, 1 ),
    array( 12, 10, 8, 3, 3, 0 ),
    array( 12, 10, 8, 3, 2, 1 ),
    array( 12, 10, 8, 2, 2, 2 ),
    array( 12, 10, 7, 7, 0, 0 ),
    array( 12, 10, 7, 6, 1, 0 ),
    array( 12, 10, 7, 5, 2, 0 ),
    array( 12, 10, 7, 5, 1, 1 ),
    array( 12, 10, 7, 4, 3, 0 ),
    array( 12, 10, 7, 4, 2, 1 ),
    array( 12, 10, 7, 3, 3, 1 ),
    array( 12, 10, 7, 3, 2, 2 ),
    array( 12, 10, 6, 6, 2, 0 ),
    array( 12, 10, 6, 6, 1, 1 ),
    array( 12, 10, 6, 5, 3, 0 ),
    array( 12, 10, 6, 5, 2, 1 ),
    array( 12, 10, 6, 4, 4, 0 ),
    array( 12, 10, 6, 4, 3, 1 ),
    array( 12, 10, 6, 4, 2, 2 ),
    array( 12, 10, 6, 3, 3, 2 ),
    array( 12, 10, 5, 5, 4, 0 ),
    array( 12, 10, 5, 5, 3, 1 ),
    array( 12, 10, 5, 5, 2, 2 ),
    array( 12, 10, 5, 4, 4, 1 ),
    array( 12, 10, 5, 4, 3, 2 ),
    array( 12, 10, 5, 3, 3, 3 ),
    array( 12, 10, 4, 4, 4, 2 ),
    array( 12, 10, 4, 4, 3, 3 ),
    array( 12, 9, 9, 6, 0, 0 ),
    array( 12, 9, 9, 5, 1, 0 ),
    array( 12, 9, 9, 4, 2, 0 ),
    array( 12, 9, 9, 4, 1, 1 ),
    array( 12, 9, 9, 3, 3, 0 ),
    array( 12, 9, 9, 3, 2, 1 ),
    array( 12, 9, 9, 2, 2, 2 ),
    array( 12, 9, 8, 7, 0, 0 ),
    array( 12, 9, 8, 6, 1, 0 ),
    array( 12, 9, 8, 5, 2, 0 ),
    array( 12, 9, 8, 5, 1, 1 ),
    array( 12, 9, 8, 4, 3, 0 ),
    array( 12, 9, 8, 4, 2, 1 ),
    array( 12, 9, 8, 3, 3, 1 ),
    array( 12, 9, 8, 3, 2, 2 ),
    array( 12, 9, 7, 7, 1, 0 ),
    array( 12, 9, 7, 6, 2, 0 ),
    array( 12, 9, 7, 6, 1, 1 ),
    array( 12, 9, 7, 5, 3, 0 ),
    array( 12, 9, 7, 5, 2, 1 ),
    array( 12, 9, 7, 4, 4, 0 ),
    array( 12, 9, 7, 4, 3, 1 ),
    array( 12, 9, 7, 4, 2, 2 ),
    array( 12, 9, 7, 3, 3, 2 ),
    array( 12, 9, 6, 6, 3, 0 ),
    array( 12, 9, 6, 6, 2, 1 ),
    array( 12, 9, 6, 5, 4, 0 ),
    array( 12, 9, 6, 5, 3, 1 ),
    array( 12, 9, 6, 5, 2, 2 ),
    array( 12, 9, 6, 4, 4, 1 ),
    array( 12, 9, 6, 4, 3, 2 ),
    array( 12, 9, 6, 3, 3, 3 ),
    array( 12, 9, 5, 5, 5, 0 ),
    array( 12, 9, 5, 5, 4, 1 ),
    array( 12, 9, 5, 5, 3, 2 ),
    array( 12, 9, 5, 4, 4, 2 ),
    array( 12, 9, 5, 4, 3, 3 ),
    array( 12, 9, 4, 4, 4, 3 ),
    array( 12, 8, 8, 8, 0, 0 ),
    array( 12, 8, 8, 7, 1, 0 ),
    array( 12, 8, 8, 6, 2, 0 ),
    array( 12, 8, 8, 6, 1, 1 ),
    array( 12, 8, 8, 5, 3, 0 ),
    array( 12, 8, 8, 5, 2, 1 ),
    array( 12, 8, 8, 4, 4, 0 ),
    array( 12, 8, 8, 4, 3, 1 ),
    array( 12, 8, 8, 4, 2, 2 ),
    array( 12, 8, 8, 3, 3, 2 ),
    array( 12, 8, 7, 7, 2, 0 ),
    array( 12, 8, 7, 7, 1, 1 ),
    array( 12, 8, 7, 6, 3, 0 ),
    array( 12, 8, 7, 6, 2, 1 ),
    array( 12, 8, 7, 5, 4, 0 ),
    array( 12, 8, 7, 5, 3, 1 ),
    array( 12, 8, 7, 5, 2, 2 ),
    array( 12, 8, 7, 4, 4, 1 ),
    array( 12, 8, 7, 4, 3, 2 ),
    array( 12, 8, 7, 3, 3, 3 ),
    array( 12, 8, 6, 6, 4, 0 ),
    array( 12, 8, 6, 6, 3, 1 ),
    array( 12, 8, 6, 6, 2, 2 ),
    array( 12, 8, 6, 5, 5, 0 ),
    array( 12, 8, 6, 5, 4, 1 ),
    array( 12, 8, 6, 5, 3, 2 ),
    array( 12, 8, 6, 4, 4, 2 ),
    array( 12, 8, 6, 4, 3, 3 ),
    array( 12, 8, 5, 5, 5, 1 ),
    array( 12, 8, 5, 5, 4, 2 ),
    array( 12, 8, 5, 5, 3, 3 ),
    array( 12, 8, 5, 4, 4, 3 ),
    array( 12, 8, 4, 4, 4, 4 ),
    array( 12, 7, 7, 7, 3, 0 ),
    array( 12, 7, 7, 7, 2, 1 ),
    array( 12, 7, 7, 6, 4, 0 ),
    array( 12, 7, 7, 6, 3, 1 ),
    array( 12, 7, 7, 6, 2, 2 ),
    array( 12, 7, 7, 5, 5, 0 ),
    array( 12, 7, 7, 5, 4, 1 ),
    array( 12, 7, 7, 5, 3, 2 ),
    array( 12, 7, 7, 4, 4, 2 ),
    array( 12, 7, 7, 4, 3, 3 ),
    array( 12, 7, 6, 6, 5, 0 ),
    array( 12, 7, 6, 6, 4, 1 ),
    array( 12, 7, 6, 6, 3, 2 ),
    array( 12, 7, 6, 5, 5, 1 ),
    array( 12, 7, 6, 5, 4, 2 ),
    array( 12, 7, 6, 5, 3, 3 ),
    array( 12, 7, 6, 4, 4, 3 ),
    array( 12, 7, 5, 5, 5, 2 ),
    array( 12, 7, 5, 5, 4, 3 ),
    array( 12, 7, 5, 4, 4, 4 ),
    array( 12, 6, 6, 6, 6, 0 ),
    array( 12, 6, 6, 6, 5, 1 ),
    array( 12, 6, 6, 6, 4, 2 ),
    array( 12, 6, 6, 6, 3, 3 ),
    array( 12, 6, 6, 5, 5, 2 ),
    array( 12, 6, 6, 5, 4, 3 ),
    array( 12, 6, 6, 4, 4, 4 ),
    array( 12, 6, 5, 5, 5, 3 ),
    array( 12, 6, 5, 5, 4, 4 ),
    array( 12, 5, 5, 5, 5, 4 ),
    array( 11, 11, 11, 3, 0, 0 ),
    array( 11, 11, 11, 2, 1, 0 ),
    array( 11, 11, 11, 1, 1, 1 ),
    array( 11, 11, 10, 4, 0, 0 ),
    array( 11, 11, 10, 3, 1, 0 ),
    array( 11, 11, 10, 2, 2, 0 ),
    array( 11, 11, 10, 2, 1, 1 ),
    array( 11, 11, 9, 5, 0, 0 ),
    array( 11, 11, 9, 4, 1, 0 ),
    array( 11, 11, 9, 3, 2, 0 ),
    array( 11, 11, 9, 3, 1, 1 ),
    array( 11, 11, 9, 2, 2, 1 ),
    array( 11, 11, 8, 6, 0, 0 ),
    array( 11, 11, 8, 5, 1, 0 ),
    array( 11, 11, 8, 4, 2, 0 ),
    array( 11, 11, 8, 4, 1, 1 ),
    array( 11, 11, 8, 3, 3, 0 ),
    array( 11, 11, 8, 3, 2, 1 ),
    array( 11, 11, 8, 2, 2, 2 ),
    array( 11, 11, 7, 7, 0, 0 ),
    array( 11, 11, 7, 6, 1, 0 ),
    array( 11, 11, 7, 5, 2, 0 ),
    array( 11, 11, 7, 5, 1, 1 ),
    array( 11, 11, 7, 4, 3, 0 ),
    array( 11, 11, 7, 4, 2, 1 ),
    array( 11, 11, 7, 3, 3, 1 ),
    array( 11, 11, 7, 3, 2, 2 ),
    array( 11, 11, 6, 6, 2, 0 ),
    array( 11, 11, 6, 6, 1, 1 ),
    array( 11, 11, 6, 5, 3, 0 ),
    array( 11, 11, 6, 5, 2, 1 ),
    array( 11, 11, 6, 4, 4, 0 ),
    array( 11, 11, 6, 4, 3, 1 ),
    array( 11, 11, 6, 4, 2, 2 ),
    array( 11, 11, 6, 3, 3, 2 ),
    array( 11, 11, 5, 5, 4, 0 ),
    array( 11, 11, 5, 5, 3, 1 ),
    array( 11, 11, 5, 5, 2, 2 ),
    array( 11, 11, 5, 4, 4, 1 ),
    array( 11, 11, 5, 4, 3, 2 ),
    array( 11, 11, 5, 3, 3, 3 ),
    array( 11, 11, 4, 4, 4, 2 ),
    array( 11, 11, 4, 4, 3, 3 ),
    array( 11, 10, 10, 5, 0, 0 ),
    array( 11, 10, 10, 4, 1, 0 ),
    array( 11, 10, 10, 3, 2, 0 ),
    array( 11, 10, 10, 3, 1, 1 ),
    array( 11, 10, 10, 2, 2, 1 ),
    array( 11, 10, 9, 6, 0, 0 ),
    array( 11, 10, 9, 5, 1, 0 ),
    array( 11, 10, 9, 4, 2, 0 ),
    array( 11, 10, 9, 4, 1, 1 ),
    array( 11, 10, 9, 3, 3, 0 ),
    array( 11, 10, 9, 3, 2, 1 ),
    array( 11, 10, 9, 2, 2, 2 ),
    array( 11, 10, 8, 7, 0, 0 ),
    array( 11, 10, 8, 6, 1, 0 ),
    array( 11, 10, 8, 5, 2, 0 ),
    array( 11, 10, 8, 5, 1, 1 ),
    array( 11, 10, 8, 4, 3, 0 ),
    array( 11, 10, 8, 4, 2, 1 ),
    array( 11, 10, 8, 3, 3, 1 ),
    array( 11, 10, 8, 3, 2, 2 ),
    array( 11, 10, 7, 7, 1, 0 ),
    array( 11, 10, 7, 6, 2, 0 ),
    array( 11, 10, 7, 6, 1, 1 ),
    array( 11, 10, 7, 5, 3, 0 ),
    array( 11, 10, 7, 5, 2, 1 ),
    array( 11, 10, 7, 4, 4, 0 ),
    array( 11, 10, 7, 4, 3, 1 ),
    array( 11, 10, 7, 4, 2, 2 ),
    array( 11, 10, 7, 3, 3, 2 ),
    array( 11, 10, 6, 6, 3, 0 ),
    array( 11, 10, 6, 6, 2, 1 ),
    array( 11, 10, 6, 5, 4, 0 ),
    array( 11, 10, 6, 5, 3, 1 ),
    array( 11, 10, 6, 5, 2, 2 ),
    array( 11, 10, 6, 4, 4, 1 ),
    array( 11, 10, 6, 4, 3, 2 ),
    array( 11, 10, 6, 3, 3, 3 ),
    array( 11, 10, 5, 5, 5, 0 ),
    array( 11, 10, 5, 5, 4, 1 ),
    array( 11, 10, 5, 5, 3, 2 ),
    array( 11, 10, 5, 4, 4, 2 ),
    array( 11, 10, 5, 4, 3, 3 ),
    array( 11, 10, 4, 4, 4, 3 ),
    array( 11, 9, 9, 7, 0, 0 ),
    array( 11, 9, 9, 6, 1, 0 ),
    array( 11, 9, 9, 5, 2, 0 ),
    array( 11, 9, 9, 5, 1, 1 ),
    array( 11, 9, 9, 4, 3, 0 ),
    array( 11, 9, 9, 4, 2, 1 ),
    array( 11, 9, 9, 3, 3, 1 ),
    array( 11, 9, 9, 3, 2, 2 ),
    array( 11, 9, 8, 8, 0, 0 ),
    array( 11, 9, 8, 7, 1, 0 ),
    array( 11, 9, 8, 6, 2, 0 ),
    array( 11, 9, 8, 6, 1, 1 ),
    array( 11, 9, 8, 5, 3, 0 ),
    array( 11, 9, 8, 5, 2, 1 ),
    array( 11, 9, 8, 4, 4, 0 ),
    array( 11, 9, 8, 4, 3, 1 ),
    array( 11, 9, 8, 4, 2, 2 ),
    array( 11, 9, 8, 3, 3, 2 ),
    array( 11, 9, 7, 7, 2, 0 ),
    array( 11, 9, 7, 7, 1, 1 ),
    array( 11, 9, 7, 6, 3, 0 ),
    array( 11, 9, 7, 6, 2, 1 ),
    array( 11, 9, 7, 5, 4, 0 ),
    array( 11, 9, 7, 5, 3, 1 ),
    array( 11, 9, 7, 5, 2, 2 ),
    array( 11, 9, 7, 4, 4, 1 ),
    array( 11, 9, 7, 4, 3, 2 ),
    array( 11, 9, 7, 3, 3, 3 ),
    array( 11, 9, 6, 6, 4, 0 ),
    array( 11, 9, 6, 6, 3, 1 ),
    array( 11, 9, 6, 6, 2, 2 ),
    array( 11, 9, 6, 5, 5, 0 ),
    array( 11, 9, 6, 5, 4, 1 ),
    array( 11, 9, 6, 5, 3, 2 ),
    array( 11, 9, 6, 4, 4, 2 ),
    array( 11, 9, 6, 4, 3, 3 ),
    array( 11, 9, 5, 5, 5, 1 ),
    array( 11, 9, 5, 5, 4, 2 ),
    array( 11, 9, 5, 5, 3, 3 ),
    array( 11, 9, 5, 4, 4, 3 ),
    array( 11, 9, 4, 4, 4, 4 ),
    array( 11, 8, 8, 8, 1, 0 ),
    array( 11, 8, 8, 7, 2, 0 ),
    array( 11, 8, 8, 7, 1, 1 ),
    array( 11, 8, 8, 6, 3, 0 ),
    array( 11, 8, 8, 6, 2, 1 ),
    array( 11, 8, 8, 5, 4, 0 ),
    array( 11, 8, 8, 5, 3, 1 ),
    array( 11, 8, 8, 5, 2, 2 ),
    array( 11, 8, 8, 4, 4, 1 ),
    array( 11, 8, 8, 4, 3, 2 ),
    array( 11, 8, 8, 3, 3, 3 ),
    array( 11, 8, 7, 7, 3, 0 ),
    array( 11, 8, 7, 7, 2, 1 ),
    array( 11, 8, 7, 6, 4, 0 ),
    array( 11, 8, 7, 6, 3, 1 ),
    array( 11, 8, 7, 6, 2, 2 ),
    array( 11, 8, 7, 5, 5, 0 ),
    array( 11, 8, 7, 5, 4, 1 ),
    array( 11, 8, 7, 5, 3, 2 ),
    array( 11, 8, 7, 4, 4, 2 ),
    array( 11, 8, 7, 4, 3, 3 ),
    array( 11, 8, 6, 6, 5, 0 ),
    array( 11, 8, 6, 6, 4, 1 ),
    array( 11, 8, 6, 6, 3, 2 ),
    array( 11, 8, 6, 5, 5, 1 ),
    array( 11, 8, 6, 5, 4, 2 ),
    array( 11, 8, 6, 5, 3, 3 ),
    array( 11, 8, 6, 4, 4, 3 ),
    array( 11, 8, 5, 5, 5, 2 ),
    array( 11, 8, 5, 5, 4, 3 ),
    array( 11, 8, 5, 4, 4, 4 ),
    array( 11, 7, 7, 7, 4, 0 ),
    array( 11, 7, 7, 7, 3, 1 ),
    array( 11, 7, 7, 7, 2, 2 ),
    array( 11, 7, 7, 6, 5, 0 ),
    array( 11, 7, 7, 6, 4, 1 ),
    array( 11, 7, 7, 6, 3, 2 ),
    array( 11, 7, 7, 5, 5, 1 ),
    array( 11, 7, 7, 5, 4, 2 ),
    array( 11, 7, 7, 5, 3, 3 ),
    array( 11, 7, 7, 4, 4, 3 ),
    array( 11, 7, 6, 6, 6, 0 ),
    array( 11, 7, 6, 6, 5, 1 ),
    array( 11, 7, 6, 6, 4, 2 ),
    array( 11, 7, 6, 6, 3, 3 ),
    array( 11, 7, 6, 5, 5, 2 ),
    array( 11, 7, 6, 5, 4, 3 ),
    array( 11, 7, 6, 4, 4, 4 ),
    array( 11, 7, 5, 5, 5, 3 ),
    array( 11, 7, 5, 5, 4, 4 ),
    array( 11, 6, 6, 6, 6, 1 ),
    array( 11, 6, 6, 6, 5, 2 ),
    array( 11, 6, 6, 6, 4, 3 ),
    array( 11, 6, 6, 5, 5, 3 ),
    array( 11, 6, 6, 5, 4, 4 ),
    array( 11, 6, 5, 5, 5, 4 ),
    array( 11, 5, 5, 5, 5, 5 ),
    array( 10, 10, 10, 6, 0, 0 ),
    array( 10, 10, 10, 5, 1, 0 ),
    array( 10, 10, 10, 4, 2, 0 ),
    array( 10, 10, 10, 4, 1, 1 ),
    array( 10, 10, 10, 3, 3, 0 ),
    array( 10, 10, 10, 3, 2, 1 ),
    array( 10, 10, 10, 2, 2, 2 ),
    array( 10, 10, 9, 7, 0, 0 ),
    array( 10, 10, 9, 6, 1, 0 ),
    array( 10, 10, 9, 5, 2, 0 ),
    array( 10, 10, 9, 5, 1, 1 ),
    array( 10, 10, 9, 4, 3, 0 ),
    array( 10, 10, 9, 4, 2, 1 ),
    array( 10, 10, 9, 3, 3, 1 ),
    array( 10, 10, 9, 3, 2, 2 ),
    array( 10, 10, 8, 8, 0, 0 ),
    array( 10, 10, 8, 7, 1, 0 ),
    array( 10, 10, 8, 6, 2, 0 ),
    array( 10, 10, 8, 6, 1, 1 ),
    array( 10, 10, 8, 5, 3, 0 ),
    array( 10, 10, 8, 5, 2, 1 ),
    array( 10, 10, 8, 4, 4, 0 ),
    array( 10, 10, 8, 4, 3, 1 ),
    array( 10, 10, 8, 4, 2, 2 ),
    array( 10, 10, 8, 3, 3, 2 ),
    array( 10, 10, 7, 7, 2, 0 ),
    array( 10, 10, 7, 7, 1, 1 ),
    array( 10, 10, 7, 6, 3, 0 ),
    array( 10, 10, 7, 6, 2, 1 ),
    array( 10, 10, 7, 5, 4, 0 ),
    array( 10, 10, 7, 5, 3, 1 ),
    array( 10, 10, 7, 5, 2, 2 ),
    array( 10, 10, 7, 4, 4, 1 ),
    array( 10, 10, 7, 4, 3, 2 ),
    array( 10, 10, 7, 3, 3, 3 ),
    array( 10, 10, 6, 6, 4, 0 ),
    array( 10, 10, 6, 6, 3, 1 ),
    array( 10, 10, 6, 6, 2, 2 ),
    array( 10, 10, 6, 5, 5, 0 ),
    array( 10, 10, 6, 5, 4, 1 ),
    array( 10, 10, 6, 5, 3, 2 ),
    array( 10, 10, 6, 4, 4, 2 ),
    array( 10, 10, 6, 4, 3, 3 ),
    array( 10, 10, 5, 5, 5, 1 ),
    array( 10, 10, 5, 5, 4, 2 ),
    array( 10, 10, 5, 5, 3, 3 ),
    array( 10, 10, 5, 4, 4, 3 ),
    array( 10, 10, 4, 4, 4, 4 ),
    array( 10, 9, 9, 8, 0, 0 ),
    array( 10, 9, 9, 7, 1, 0 ),
    array( 10, 9, 9, 6, 2, 0 ),
    array( 10, 9, 9, 6, 1, 1 ),
    array( 10, 9, 9, 5, 3, 0 ),
    array( 10, 9, 9, 5, 2, 1 ),
    array( 10, 9, 9, 4, 4, 0 ),
    array( 10, 9, 9, 4, 3, 1 ),
    array( 10, 9, 9, 4, 2, 2 ),
    array( 10, 9, 9, 3, 3, 2 ),
    array( 10, 9, 8, 8, 1, 0 ),
    array( 10, 9, 8, 7, 2, 0 ),
    array( 10, 9, 8, 7, 1, 1 ),
    array( 10, 9, 8, 6, 3, 0 ),
    array( 10, 9, 8, 6, 2, 1 ),
    array( 10, 9, 8, 5, 4, 0 ),
    array( 10, 9, 8, 5, 3, 1 ),
    array( 10, 9, 8, 5, 2, 2 ),
    array( 10, 9, 8, 4, 4, 1 ),
    array( 10, 9, 8, 4, 3, 2 ),
    array( 10, 9, 8, 3, 3, 3 ),
    array( 10, 9, 7, 7, 3, 0 ),
    array( 10, 9, 7, 7, 2, 1 ),
    array( 10, 9, 7, 6, 4, 0 ),
    array( 10, 9, 7, 6, 3, 1 ),
    array( 10, 9, 7, 6, 2, 2 ),
    array( 10, 9, 7, 5, 5, 0 ),
    array( 10, 9, 7, 5, 4, 1 ),
    array( 10, 9, 7, 5, 3, 2 ),
    array( 10, 9, 7, 4, 4, 2 ),
    array( 10, 9, 7, 4, 3, 3 ),
    array( 10, 9, 6, 6, 5, 0 ),
    array( 10, 9, 6, 6, 4, 1 ),
    array( 10, 9, 6, 6, 3, 2 ),
    array( 10, 9, 6, 5, 5, 1 ),
    array( 10, 9, 6, 5, 4, 2 ),
    array( 10, 9, 6, 5, 3, 3 ),
    array( 10, 9, 6, 4, 4, 3 ),
    array( 10, 9, 5, 5, 5, 2 ),
    array( 10, 9, 5, 5, 4, 3 ),
    array( 10, 9, 5, 4, 4, 4 ),
    array( 10, 8, 8, 8, 2, 0 ),
    array( 10, 8, 8, 8, 1, 1 ),
    array( 10, 8, 8, 7, 3, 0 ),
    array( 10, 8, 8, 7, 2, 1 ),
    array( 10, 8, 8, 6, 4, 0 ),
    array( 10, 8, 8, 6, 3, 1 ),
    array( 10, 8, 8, 6, 2, 2 ),
    array( 10, 8, 8, 5, 5, 0 ),
    array( 10, 8, 8, 5, 4, 1 ),
    array( 10, 8, 8, 5, 3, 2 ),
    array( 10, 8, 8, 4, 4, 2 ),
    array( 10, 8, 8, 4, 3, 3 ),
    array( 10, 8, 7, 7, 4, 0 ),
    array( 10, 8, 7, 7, 3, 1 ),
    array( 10, 8, 7, 7, 2, 2 ),
    array( 10, 8, 7, 6, 5, 0 ),
    array( 10, 8, 7, 6, 4, 1 ),
    array( 10, 8, 7, 6, 3, 2 ),
    array( 10, 8, 7, 5, 5, 1 ),
    array( 10, 8, 7, 5, 4, 2 ),
    array( 10, 8, 7, 5, 3, 3 ),
    array( 10, 8, 7, 4, 4, 3 ),
    array( 10, 8, 6, 6, 6, 0 ),
    array( 10, 8, 6, 6, 5, 1 ),
    array( 10, 8, 6, 6, 4, 2 ),
    array( 10, 8, 6, 6, 3, 3 ),
    array( 10, 8, 6, 5, 5, 2 ),
    array( 10, 8, 6, 5, 4, 3 ),
    array( 10, 8, 6, 4, 4, 4 ),
    array( 10, 8, 5, 5, 5, 3 ),
    array( 10, 8, 5, 5, 4, 4 ),
    array( 10, 7, 7, 7, 5, 0 ),
    array( 10, 7, 7, 7, 4, 1 ),
    array( 10, 7, 7, 7, 3, 2 ),
    array( 10, 7, 7, 6, 6, 0 ),
    array( 10, 7, 7, 6, 5, 1 ),
    array( 10, 7, 7, 6, 4, 2 ),
    array( 10, 7, 7, 6, 3, 3 ),
    array( 10, 7, 7, 5, 5, 2 ),
    array( 10, 7, 7, 5, 4, 3 ),
    array( 10, 7, 7, 4, 4, 4 ),
    array( 10, 7, 6, 6, 6, 1 ),
    array( 10, 7, 6, 6, 5, 2 ),
    array( 10, 7, 6, 6, 4, 3 ),
    array( 10, 7, 6, 5, 5, 3 ),
    array( 10, 7, 6, 5, 4, 4 ),
    array( 10, 7, 5, 5, 5, 4 ),
    array( 10, 6, 6, 6, 6, 2 ),
    array( 10, 6, 6, 6, 5, 3 ),
    array( 10, 6, 6, 6, 4, 4 ),
    array( 10, 6, 6, 5, 5, 4 ),
    array( 10, 6, 5, 5, 5, 5 ),
    array( 9, 9, 9, 9, 0, 0 ),
    array( 9, 9, 9, 8, 1, 0 ),
    array( 9, 9, 9, 7, 2, 0 ),
    array( 9, 9, 9, 7, 1, 1 ),
    array( 9, 9, 9, 6, 3, 0 ),
    array( 9, 9, 9, 6, 2, 1 ),
    array( 9, 9, 9, 5, 4, 0 ),
    array( 9, 9, 9, 5, 3, 1 ),
    array( 9, 9, 9, 5, 2, 2 ),
    array( 9, 9, 9, 4, 4, 1 ),
    array( 9, 9, 9, 4, 3, 2 ),
    array( 9, 9, 9, 3, 3, 3 ),
    array( 9, 9, 8, 8, 2, 0 ),
    array( 9, 9, 8, 8, 1, 1 ),
    array( 9, 9, 8, 7, 3, 0 ),
    array( 9, 9, 8, 7, 2, 1 ),
    array( 9, 9, 8, 6, 4, 0 ),
    array( 9, 9, 8, 6, 3, 1 ),
    array( 9, 9, 8, 6, 2, 2 ),
    array( 9, 9, 8, 5, 5, 0 ),
    array( 9, 9, 8, 5, 4, 1 ),
    array( 9, 9, 8, 5, 3, 2 ),
    array( 9, 9, 8, 4, 4, 2 ),
    array( 9, 9, 8, 4, 3, 3 ),
    array( 9, 9, 7, 7, 4, 0 ),
    array( 9, 9, 7, 7, 3, 1 ),
    array( 9, 9, 7, 7, 2, 2 ),
    array( 9, 9, 7, 6, 5, 0 ),
    array( 9, 9, 7, 6, 4, 1 ),
    array( 9, 9, 7, 6, 3, 2 ),
    array( 9, 9, 7, 5, 5, 1 ),
    array( 9, 9, 7, 5, 4, 2 ),
    array( 9, 9, 7, 5, 3, 3 ),
    array( 9, 9, 7, 4, 4, 3 ),
    array( 9, 9, 6, 6, 6, 0 ),
    array( 9, 9, 6, 6, 5, 1 ),
    array( 9, 9, 6, 6, 4, 2 ),
    array( 9, 9, 6, 6, 3, 3 ),
    array( 9, 9, 6, 5, 5, 2 ),
    array( 9, 9, 6, 5, 4, 3 ),
    array( 9, 9, 6, 4, 4, 4 ),
    array( 9, 9, 5, 5, 5, 3 ),
    array( 9, 9, 5, 5, 4, 4 ),
    array( 9, 8, 8, 8, 3, 0 ),
    array( 9, 8, 8, 8, 2, 1 ),
    array( 9, 8, 8, 7, 4, 0 ),
    array( 9, 8, 8, 7, 3, 1 ),
    array( 9, 8, 8, 7, 2, 2 ),
    array( 9, 8, 8, 6, 5, 0 ),
    array( 9, 8, 8, 6, 4, 1 ),
    array( 9, 8, 8, 6, 3, 2 ),
    array( 9, 8, 8, 5, 5, 1 ),
    array( 9, 8, 8, 5, 4, 2 ),
    array( 9, 8, 8, 5, 3, 3 ),
    array( 9, 8, 8, 4, 4, 3 ),
    array( 9, 8, 7, 7, 5, 0 ),
    array( 9, 8, 7, 7, 4, 1 ),
    array( 9, 8, 7, 7, 3, 2 ),
    array( 9, 8, 7, 6, 6, 0 ),
    array( 9, 8, 7, 6, 5, 1 ),
    array( 9, 8, 7, 6, 4, 2 ),
    array( 9, 8, 7, 6, 3, 3 ),
    array( 9, 8, 7, 5, 5, 2 ),
    array( 9, 8, 7, 5, 4, 3 ),
    array( 9, 8, 7, 4, 4, 4 ),
    array( 9, 8, 6, 6, 6, 1 ),
    array( 9, 8, 6, 6, 5, 2 ),
    array( 9, 8, 6, 6, 4, 3 ),
    array( 9, 8, 6, 5, 5, 3 ),
    array( 9, 8, 6, 5, 4, 4 ),
    array( 9, 8, 5, 5, 5, 4 ),
    array( 9, 7, 7, 7, 6, 0 ),
    array( 9, 7, 7, 7, 5, 1 ),
    array( 9, 7, 7, 7, 4, 2 ),
    array( 9, 7, 7, 7, 3, 3 ),
    array( 9, 7, 7, 6, 6, 1 ),
    array( 9, 7, 7, 6, 5, 2 ),
    array( 9, 7, 7, 6, 4, 3 ),
    array( 9, 7, 7, 5, 5, 3 ),
    array( 9, 7, 7, 5, 4, 4 ),
    array( 9, 7, 6, 6, 6, 2 ),
    array( 9, 7, 6, 6, 5, 3 ),
    array( 9, 7, 6, 6, 4, 4 ),
    array( 9, 7, 6, 5, 5, 4 ),
    array( 9, 7, 5, 5, 5, 5 ),
    array( 9, 6, 6, 6, 6, 3 ),
    array( 9, 6, 6, 6, 5, 4 ),
    array( 9, 6, 6, 5, 5, 5 ),
    array( 8, 8, 8, 8, 4, 0 ),
    array( 8, 8, 8, 8, 3, 1 ),
    array( 8, 8, 8, 8, 2, 2 ),
    array( 8, 8, 8, 7, 5, 0 ),
    array( 8, 8, 8, 7, 4, 1 ),
    array( 8, 8, 8, 7, 3, 2 ),
    array( 8, 8, 8, 6, 6, 0 ),
    array( 8, 8, 8, 6, 5, 1 ),
    array( 8, 8, 8, 6, 4, 2 ),
    array( 8, 8, 8, 6, 3, 3 ),
    array( 8, 8, 8, 5, 5, 2 ),
    array( 8, 8, 8, 5, 4, 3 ),
    array( 8, 8, 8, 4, 4, 4 ),
    array( 8, 8, 7, 7, 6, 0 ),
    array( 8, 8, 7, 7, 5, 1 ),
    array( 8, 8, 7, 7, 4, 2 ),
    array( 8, 8, 7, 7, 3, 3 ),
    array( 8, 8, 7, 6, 6, 1 ),
    array( 8, 8, 7, 6, 5, 2 ),
    array( 8, 8, 7, 6, 4, 3 ),
    array( 8, 8, 7, 5, 5, 3 ),
    array( 8, 8, 7, 5, 4, 4 ),
    array( 8, 8, 6, 6, 6, 2 ),
    array( 8, 8, 6, 6, 5, 3 ),
    array( 8, 8, 6, 6, 4, 4 ),
    array( 8, 8, 6, 5, 5, 4 ),
    array( 8, 8, 5, 5, 5, 5 ),
    array( 8, 7, 7, 7, 7, 0 ),
    array( 8, 7, 7, 7, 6, 1 ),
    array( 8, 7, 7, 7, 5, 2 ),
    array( 8, 7, 7, 7, 4, 3 ),
    array( 8, 7, 7, 6, 6, 2 ),
    array( 8, 7, 7, 6, 5, 3 ),
    array( 8, 7, 7, 6, 4, 4 ),
    array( 8, 7, 7, 5, 5, 4 ),
    array( 8, 7, 6, 6, 6, 3 ),
    array( 8, 7, 6, 6, 5, 4 ),
    array( 8, 7, 6, 5, 5, 5 ),
    array( 8, 6, 6, 6, 6, 4 ),
    array( 8, 6, 6, 6, 5, 5 ),
    array( 7, 7, 7, 7, 7, 1 ),
    array( 7, 7, 7, 7, 6, 2 ),
    array( 7, 7, 7, 7, 5, 3 ),
    array( 7, 7, 7, 7, 4, 4 ),
    array( 7, 7, 7, 6, 6, 3 ),
    array( 7, 7, 7, 6, 5, 4 ),
    array( 7, 7, 7, 5, 5, 5 ),
    array( 7, 7, 6, 6, 6, 4 ),
    array( 7, 7, 6, 6, 5, 5 ),
    array( 7, 6, 6, 6, 6, 5 ),
    array( 6, 6, 6, 6, 6, 6 ),
);