珠心算出题类

演示例子:http://zxs.fenhaokj.com/suanfa/index/example

先说一下具体思路:

1、建立出题规则

<?php
namespace app\suanfa\controller;
class Topic {
    /*检索*/
    public function jiansuo(){
        $res=array(
            '1'=>'onetofour',
            '2'=>'addfive',
            '3'=>'remfive',
            '4'=>'addsix',
            '5'=>'remsix',
            '6'=>'addseven',
            '7'=>'remseven',
            '8'=>'addeight',
            '9'=>'remeight',
            '10'=>'addnine',
            '11'=>'remnine',
            '12'=>'onetonine',
            '13'=>'addonefullfive',
            '14'=>'addtwofullfive',
            '15'=>'addthreefullfive',
            '16'=>'addfourfullfive',
            '17'=>'fullfive',
            '18'=>'remonekillfive',
            '19'=>'remtwokillfive',
            '20'=>'remthreekillfive',
            '21'=>'remfourkillfive',
            '22'=>'killfive',
            '23'=>'addonefullposition',
            '24'=>'addtwofullposition',
            '25'=>'addthreefullposition',
            '26'=>'addfourfullposition',
            '27'=>'addfivefullposition',
            '28'=>'addsixfullposition',
            '29'=>'addsevenfullposition',
            '30'=>'addeightfullposition',
            '31'=>'addninefullposition',
            '32'=>'fullposition',
            '33'=>'remonekillposition',
            '34'=>'remtwokillposition',
            '35'=>'remthreekillposition',
            '36'=>'remfourkillposition',
            '37'=>'remfivekillposition',
            '38'=>'remsixkillposition',
            '39'=>'remsevenkillposition',
            '40'=>'remeightkillposition',
            '41'=>'remninekillposition',
            '42'=>'killposition',
            '43'=>'addsixfullpositionkillfive',
            '44'=>'addsevenfullpositionkillfive',
            '45'=>'addeightfullpositionkillfive',
            '46'=>'addninefullpositionkillfive',
            '47'=>'fullpositionkillfive',
            '48'=>'remsexkillpositionfullfive',
            '49'=>'remsevenkillpositionfullfive',
            '50'=>'remeightkillpositionfullfive',
            '51'=>'remninekillpositionfullfive',
            '52'=>'killpositionfullfive',
            '53'=>'onetoall',
        );
        return $res;
    }
 /*1-4 直加直减*/
    public function onetofour() {
        $res['next'] = [1, 2, 3, 4];
        $res['first'] = [1, 2, 3, 4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
        );
        $res['nrelation']=[];
        $res['yuqijieguo'] = [1, 2, 3, 4];
        $res['level'] = 1;
        $res['bixu'] = [];
        return $res;
    }
    //+5
    public function addfive(){
        $res['next'] = [1, 2, 3, 4, 5];
        $res['first'] = [1, 2, 3, 4, 5];
        $res['relation'] = array(
            '0' => [1,2,3,4,5],
            '1' => [1,2,3,5],
            '2' => [1,2,-1,5],
            '3' => [1,-1,-2,5],
            '4' => [-1,-2,-3,5],
            '5' => [1,2,3,4],
            '6' => [1,2,3,-1],
            '7' => [1,2,-1,-2],
            '8' => [1,-1,-2,-3],
            '9' => [-1,-2,-3,-4]
        );
        $res['nrelation']=[];
        $res['bixu'] = [+5];
        $res['lavel'] = 2;
        return $res;
    }

    //-5
    public function remfive(){
        $res['next'] = [1,2,3,4,5,6,7,8,9];
        $res['first'] = [1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => [],
            '1' => [],
            '2' => [],
            '3' => [],
            '4' => [],
            '5' => [-5],
            '6' => [-5],
            '7' => [-5],
            '8' => [-5],
            '9' => [-5]
        );
        $res['nrelation']=[];
        $res['bixu'] = [-5];
        $res['lavel'] = 3;
        return $res;
    }
    public function addsix(){
        $res['next'] = [1, 2, 3, 4, 5];
        $res['first'] = [1, 2, 3, 4, 5,6];
        $res['relation'] = array(
            '0' => [1,2,3,4],
            '1' => [1,2,3,6],
            '2' => [1,2,6,-1],
            '3' => [1,6,-1,-2],
            '4' => [-1,-2,-3],
            '5' => [1,2,3,4,-4],
            '6' => [1,2,3,-1],
            '7' => [1,2,-1,-2],
            '8' => [1,-1,-2,-3],
            '9' => [-1,-2,-3,-4]
        );
        $res['nrelation']=[];
        $res['bixu'] = [+6];
        $res['lavel'] = 4;
        return $res;
    }
    //-6
    public function remsix()
    {

        $res['next'] = [1,2,3,4,5,6,7,8,9];
        $res['first'] = [6,7,8,9];
        $res['relation'] = array(
            '0' => [1,2,3,4],
            '1' => [1,2,3],
            '2' => [1,2,-1],
            '3' => [1,-1,-2],
            '4' => [-1,-2,-3],
            '5' => [1,2,3,4],
            '6' => [-6,1,2,3,-1],
            '7' => [-6,1,2,-1,-2],
            '8' => [-6,1,-1,-2,-3],
            '9' => [-6,-1,-2,-3,-4]
        );
        $res['bixu'] = [-6];
        $res['lavel'] = 5;
        return $res;
    }
    //+7
    public function addseven(){
        $res['next'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['first']=[1,2];
        $res['relation']=array(
            '0'=>[1,2,3,4,7],
            '1'=>[1,2,3,7],
            '2'=>[1,2,7,-1],
            '3'=>[1,-1,-2],
            '4'=>[-1,-2,-3],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2],
            '8'=>[1,-1,-2,-3],
            '9'=>[-1,-2,-3,-4]
        );
        $res['bixu']=[+7];
        $res['lavel']=6;
        return $res;
    }

    //-7
    public function remseven(){
        $res['next'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['first']=[7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4],
            '1'=>[1,2,3],
            '2'=>[1,2,-1],
            '3'=>[1,-1,-2],
            '4'=>[-1,-2,-3],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2,-7],
            '8'=>[1,-1,-2,-3,-7],
            '9'=>[-1,-2,-3,-4,-7]
        );
        $res['bixu']=[-7];
        $res['lavel']=7;
        return $res;
    }
    //+8
    public function addeight(){
        $res['next'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['first']=[1];
        $res['relation']=array(
            '0'=>[1,2,3,4,8],
            '1'=>[1,2,3,8],
            '2'=>[1,2,-1],
            '3'=>[1,-1],
            '4'=>[-1,-2,-3],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2],
            '8'=>[1,-1,-2,-3],
            '9'=>[-1,-2,-3,-4]
        );
        $res['bixu']=[+8];
        $res['lavel']=8;
        return $res;
    }
    //-8
    public function remeight(){
        $res['next'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['first']=[8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4],
            '1'=>[1,2,3],
            '2'=>[1,2,-1],
            '3'=>[1,-1,-2],
            '4'=>[-1,-2,-3],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2],
            '8'=>[1,-1,-2,-3,-8],
            '9'=>[-1,-2,-3,-4,-8]
        );
        $res['bixu']=[-8];
        $res['lavel']=9;
        return $res;
    }
    //+9
    public function addnine(){
        $res['next'] = [9];
        $res['first']=[9];
        $res['relation']=array(
            '0'=>[1,2,3,4,9],
            '1'=>[1,2,3],
            '2'=>[1,2,-1],
            '3'=>[1,-1,-2],
            '4'=>[-1,-2,-3,-4],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2],
            '8'=>[1,-1,-2,-3],
            '9'=>[-9,-1,-2,-3,-4,-5,-6,-7,-8]
        );
        $res['bixu']=[];
        $res['lavel']=10;
        return $res;
    }
    //-9
    public function remnine(){
        $res['next'] = [9];
        $res['first']=[9];
        $res['relation']=array(
            '0'=>[1,2,3,4,9],
            '1'=>[1,2,3],
            '2'=>[1,2,-1],
            '3'=>[1,-1,-2],
            '4'=>[-1,-2,-3,-4],
            '5'=>[1,2,3,4],
            '6'=>[1,2,3,-1],
            '7'=>[1,2,-1,-2],
            '8'=>[1,-1,-2,-3],
            '9'=>[-9,-1,-2,-3,-4,-5,-6,-7,-8]
        );
        $res['bixu']=[];
        $res['lavel']=11;
        return $res;
    }
    /*1-9直加直减*/
    public function onetonine() {
        $res['next'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['first'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9),
            '1' => array(1,2,3,5,6,7,8,-1),
            '2' => array(1,2,5,6,7,-1,-2) ,
            '3' => array(1,5,6,-1,-2,-3) ,
            '4' => array(5,-1,-2,-3,-4) ,
            '5' => array(1,2,3,4,-5),
            '6' => array(1,2,3, -1,-6,-5),
            '7' => array(1,2,-1,-2,-7,-6,-5) ,
            '8' => array(1,-1,-2,-3,-8,-7,-6,-5) ,
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8,-9)
        );
        $res['nrelation']=[];
        $res['yuqijieguo'] = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        $res['bixu'] = [];
        $res['level'] = 12;
        return $res;
    }

    //加1满五
    public function addonefullfive(){
        $res['next'] = [1,2,3,4];
        $res['first'] = [1,2,3,4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5' => array(1,2,3,4),
            '6' => array(1,2,3,-1),
            '7' => array(1,2,-1,-2),
            '8' => array(1,-1,-2,-3),
            '9' => array(-1,-2,-3,-4)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[1],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level'] = 13;
        $res['bixu'] = [];
        return $res;
    }
    //加2满5
    public function addtwofullfive(){
        $res['next'] = [1,2,3,4];
        $res['first'] = [1,2,3,4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5' => array(1,2,3,4),
            '6' => array(1,2,3,-1),
            '7' => array(1,2,-1,-2),
            '8' => array(1,-1,-2,-3),
            '9' => array(-1,-2,-3,-4)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[2],
            '4'=>[2],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level'] = 14;
        $res['bixu'] = [];
        return $res;
    }
    //加3满5
    public function addthreefullfive(){
        $res['next'] = [1,2,3,4];
        $res['first'] = [1,2,3,4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5' => array(1,2,3,4),
            '6' => array(1,2,3,-1),
            '7' => array(1,2,-1,-2),
            '8' => array(1,-1,-2,-3),
            '9' => array(-1,-2,-3,-4)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[3],
            '3'=>[3],
            '4'=>[3],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level'] = 15;
        $res['bixu'] = [];
        return $res;
    }
    //加4满5
    public function addfourfullfive(){
        $res['next'] = [1,2,3,4];
        $res['first'] = [1,2,3,4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5' => array(1,2,3,4),
            '6' => array(1,2,3,-1),
            '7' => array(1,2,-1,-2),
            '8' => array(1,-1,-2,-3),
            '9' => array(-1,-2,-3,-4)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[4],
            '2'=>[4],
            '3'=>[4],
            '4'=>[4],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level'] = 16;
        $res['bixu'] = [];
        return $res;
    }
        //满五加法daixu
    public function fullfive(){
        $res['next'] = [1,2,3,4];
        $res['first'] = [1,2,3,4];
        $res['relation'] = array(
            '0' => array(1,2,3,4) ,
            '1' => array(1,2,3) ,
            '2' => array(-1,1,2) ,
            '3' => array(-1,-2,1) ,
            '4' => array(-1,-2,-3),
            '5' => array(1,2,3,4),
            '6' => array(1,2,3,-1),
            '7' => array(1,2,-1,-2),
            '8' => array(1,-1,-2,-3),
            '9' => array(-1,-2,-3,-4)
        );
        $res['nrelation']=array(
            '0'=>array(),
            '1'=>array(4),
            '2'=>array(3,4),
            '3'=>array(2,3,4),
            '4'=>array(1,2,3,4),
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['yuqijieguo'] = [1, 2, 3, 4];
        $res['level'] = 17;
        $res['bixu'] = [];
        return $res;
    }
    //减1破5
    public function remonekillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-1],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=18;
        $res['bixu']=[];
        return $res;
    }
    //减2破5
    public function remtwokillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-2],
            '6'=>[-2],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=19;
        $res['bixu']=[];
        return $res;
    }
    //减3破5
    public function remthreekillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-3],
            '6'=>[-3],
            '7'=>[-3],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=20;
        $res['bixu']=[];
        return $res;
    }
    //减4破5
    public function remfourkillfive(){
         $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-4],
            '6'=>[-4],
            '7'=>[-4],
            '8'=>[-4],
            '9'=>[],
            );
        $res['level']=21;
        $res['bixu']=[];
        return $res;
    }
    //破五减法daixu
    public function killfive(){
        $res['next']=[1,2,3,4];
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>array(),
            '1'=>array(),
            '2'=>array(),
            '3'=>array(),
            '4'=>array(),
            '5'=>array(-1,-2,-3,-4),
            '6'=>array(-2,-3,-4),
            '7'=>array(-3,-4),
            '8'=>array(-4),
            '9'=>array(),
            );
        $res['level']=22;
        $res['bixu']=[];
        return $res;
    }

    //加1进位
    public function addonefullposition(){
        $res['first']=[9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[1],
            );
        $res['level']=23;
        $res['bixu']=[];
        return $res;
    }
    //加2进位
    public function addtwofullposition(){
        $res['first']=[8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[2],
            '9'=>[2],
            );
        $res['level']=24;
        $res['bixu']=[];
        return $res;
    }
    //加3进位
    public function addthreefullposition(){
        $res['first']=[7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[3],
            '8'=>[3],
            '9'=>[3],
            );
        $res['level']=25;
        $res['bixu']=[];
        return $res;
    }
    //加4进位
    public function addfourfullposition(){
        $res['first']=[6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[4],
            '7'=>[4],
            '8'=>[4],
            '9'=>[4],
            );
        $res['level']=26;
        $res['bixu']=[];
        return $res;
    }
    //加2进位
    public function addfivefullposition(){
        $res['first']=[5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[5],
            '6'=>[5],
            '7'=>[5],
            '8'=>[5],
            '9'=>[5],
            );
        $res['level']=27;
        $res['bixu']=[];
        return $res;
    }
    //加6进位
    public function addsixfullposition(){
        $res['first']=[4,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[6],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[6],
            );
        $res['level']=28;
        $res['bixu']=[];
        return $res;
    }
    //加7进位
    public function addsevenfullposition(){
        $res['first']=[3,4,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[7],
            '4'=>[7],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[7],
            '9'=>[7],
            );
        $res['level']=29;
        $res['bixu']=[];
        return $res;
    }
    //加8进位
    public function addeightfullposition(){
        $res['first']=[2,3,4,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[8],
            '3'=>[8],
            '4'=>[8],
            '5'=>[],
            '6'=>[],
            '7'=>[8],
            '8'=>[8],
            '9'=>[8],
            );
        $res['level']=30;
        $res['bixu']=[];
        return $res;
    }
    //加9进位
    public function addninefullposition(){
        $res['first']=[1,2,3,4,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[9],
            '2'=>[9],
            '3'=>[9],
            '4'=>[9],
            '5'=>[],
            '6'=>[9],
            '7'=>[9],
            '8'=>[9],
            '9'=>[9],
            );
        $res['level']=31;
        $res['bixu']=[];
        return $res;
    }
    //进位
    public function fullposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>array(),
            '1'=>array(9),
            '2'=>array(8,9),
            '3'=>array(7,8,9),
            '4'=>array(6,7,8,9),
            '5'=>array(5),
            '6'=>array(4,5,9),
            '7'=>array(3,4,5,8,9),
            '8'=>array(2,3,4,5,7,8,9),
            '9'=>array(1,2,3,4,5,6,7,8,9),
            );
        $res['level']=32;
        $res['bixu']=[];
        return $res;
    }
    //减1退位
    public function remonekillposition(){
        $res['first']=[0];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-1],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=33;
        $res['bixu']=[];
        return $res;
    }
    public function remtwokillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-2],
            '1'=>[-2],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=34;
        $res['bixu']=[];
        return $res;
    }
    //减3退位
    public function remthreekillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-3],
            '1'=>[-3],
            '2'=>[-3],
            '3'=>[],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=35;
        $res['bixu']=[];
        return $res;
    }
     //减4退位
    public function remfourkillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-4],
            '1'=>[-4],
            '2'=>[-4],
            '3'=>[-4],
            '4'=>[],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=36;
        $res['bixu']=[];
        return $res;
    }
    //减5退位
     public function remfivekillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-5],
            '1'=>[-5],
            '2'=>[-5],
            '3'=>[-5],
            '4'=>[-5],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=37;
        $res['bixu']=[];
        return $res;
    }
    //减6退位
    public function remsixkillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-6],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-6],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=38;
        $res['bixu']=[];
        return $res;
    }
    //减7退位
    public function remsevenkillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9),
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-7],
            '1'=>[-7],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[-7],
            '6'=>[-7],
            '7'=>[],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=39;
        $res['bixu']=[];
        return $res;
    }
    //减8退位
    public function remeightkillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9),
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-8],
            '1'=>[-8],
            '2'=>[-8],
            '3'=>[],
            '4'=>[],
            '5'=>[-8],
            '6'=>[-8],
            '7'=>[-8],
            '8'=>[],
            '9'=>[],
            );
        $res['level']=40;
        $res['bixu']=[];
        return $res;
    }
    //减9退位
    public function remninekillposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9),
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>[-9],
            '1'=>[-9],
            '2'=>[-9],
            '3'=>[-9],
            '4'=>[],
            '5'=>[-9],
            '6'=>[-9],
            '7'=>[-9],
            '8'=>[-9],
            '9'=>[],
            );
        $res['level']=41;
        $res['bixu']=[];
        return $res;
    }
    //破位
    public function killposition(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation'] = array(
            '0' => array(1,2,3,4,5,6,7,8,9) ,
            '1' => array(1,2,3,4,5,6,7,8) ,
            '2' => array(-1,1,2,3,4,5,6,7) ,
            '3' => array(-1,-2,1,2,3,4,5,6) ,
            '4' => array(-1,-2,-3,1,2,3,4,5),
            '5' => array(1,2,3,4,-1,-2,-3,-4),
            '6' => array(1,2,3,-1,-2,-3,-4,-5),
            '7' => array(1,2,-1,-2,-3,-4,-5,-6),
            '8' => array(1,-1,-2,-3,-4,-5,-6,-7),
            '9' => array(-1,-2,-3,-4,-5,-6,-7,-8)
        );
        $res['nrelation']=array(
            '0'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9),
            '1'=>array(-2,-3,-4,-5,-7,-8,-9),
            '2'=>array(-3,-4,-5,-8,-9),
            '3'=>array(-4,-5,-9),
            '4'=>array(-5),
            '5'=>array(-6,-7,-8,-9),
            '6'=>array(-7,-8,-9),
            '7'=>array(-8,-9),
            '8'=>array(-9),
            '9'=>array(),
            );
        $res['level']=42;
        $res['bixu']=[];
        return $res;
    }
    //加6破5进位
    public function addsixfullpositionkillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[6],
            '6'=>[6],
            '7'=>[6],
            '8'=>[6],
            '9'=>[]
            );
        $res['level']=43;
        $res['bixu']=[];
        return $res;
    }
    //加7破5进位
    public function addsevenfullpositionkillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[7],
            '6'=>[7],
            '7'=>[7],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=44;
        $res['bixu']=[];
        return $res;
    }
    //加8破5进位
    public function addeightfullpositionkillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[8],
            '6'=>[8],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=45;
        $res['bixu']=[];
        return $res;
    }
    //加9破5进位 addsevenFullpositionKillfive
    public function addninefullpositionkillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[9],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=46;
        $res['bixu']=[];
        return $res;
    }
    public function fullpositionkillfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[],
            '5'=>[9,8,7,6],
            '6'=>[8,7,6],
            '7'=>[7,6],
            '8'=>[6],
            '9'=>[]
            );
        $res['level']=47;
        $res['bixu']=[];
        return $res;
    }
    //减6退位满5
    public function remsexkillpositionfullfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[-6],
            '2'=>[-6],
            '3'=>[-6],
            '4'=>[-6],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=48;
        $res['bixu']=[];
        return $res;
    }
    //减7退位满5
    public function remsevenkillpositionfullfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[-7],
            '3'=>[-7],
            '4'=>[-7],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=49;
        $res['bixu']=[];
        return $res;
    }
    //减8退位满5
    public function remeightkillpositionfullfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[-8],
            '4'=>[-8],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=50;
        $res['bixu']=[];
        return $res;
    }
    //减9退位满5
    public function remninekillpositionfullfive(){
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[],
            '2'=>[],
            '3'=>[],
            '4'=>[-9],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=51;
        $res['bixu']=[];
        return $res;
    }
    //破位满5
    public function killpositionfullfive(){
         $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>[1,2,3,4,5,6,7,8,9],
            '1'=>[1,2,3,4,5,6,7,8],
            '2'=>[-1,1,2,3,4,5,6,7],
            '3'=>[-1,-2,1,2,3,4,5,6],
            '4'=>[-1,-2,-3,1,2,3,4,5],
            '5'=>[-1,-2,-3,-4,1,2,3,4],
            '6'=>[-1,-2,-3,-4,-5,1,2,3],
            '7'=>[-1,-2,-3,-4,-5,-6,1,2],
            '8'=>[-1,-2,-3,-4,-5,-6,-7,1],
            '9'=>[-1,-2,-3,-4,-5,-6,-7,-8],
        );
        $res['nrelation']=array(
            '0'=>[],
            '1'=>[-6],
            '2'=>[-7,-6],
            '3'=>[-8,-7,-6],
            '4'=>[-9,-8,-7,-6],
            '5'=>[],
            '6'=>[],
            '7'=>[],
            '8'=>[],
            '9'=>[]
            );
        $res['level']=52;
        $res['bixu']=[];
        return $res;
    }
    //综合题型
    public function onetoall(){
        $res['next']=[1,2,3,4,5,6,7,8,9];
        $res['first']=[1,2,3,4,5,6,7,8,9];
        $res['relation']=array(
            '0'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '1'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '2'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '3'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '4'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '5'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '6'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '7'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '8'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9),
            '9'=>array(-1,-2,-3,-4,-5,-6,-7,-8,-9,1,2,3,4,5,6,7,8,9)
        );
        $res['nrelation']=[];
        $res['yuqijieguo']=[1,2,3,4,5,6,7,8,9];
        $res['bixu']=[];
        $res['level']=53;
        return $res;
    }
}

2、创建基本算法类

<?php
namespace app\suanfa\controller;
class Index extends Topic {
    public function example() {
        return view();
    }
    public function setlog($name, $val) {
        $fileName = $name . ".txt";
        @$data = fopen($fileName, 'a+');
        fwrite($data, $val);
        fclose($data);
    }

    public function chuti() {
        $json = file_get_contents("php://input");
    }
    public function index() {
        // $json='{"degital":[{"position":1,"line":3},{"position":2,"line":2}],"topic":["onetofour"],"topic_num":2,"group_num":2}';
        $json = file_get_contents("php://input");
        $data = json_decode($json, true);
        $dajishuqi = 0;
        if ($data == "") {
            $arr['code'] = 400;
            $arr['msg'] = '错误请求,参数空';
        } else if (!isset($data['topic']) || is_array($data['topic']) === false || count($data['topic']) == 0) {
            $arr['code'] = 401;
            $arr['msg'] = '错误请求,没有传入题目类型';
        } else if (!isset($data['degital']) || is_array($data['degital']) == false || count($data['degital']) == 0) {
            $arr['code'] = 402;
            $arr['msg'] = '请求错误,没有传入笔数位数';
        } else if (!isset($data['minresult'])) {
            $arr['code'] = 409;
            $arr['msg'] = '请求错误,没有传入预期最小结果';
        } else if (!isset($data['maxresult'])) {
            $arr['code'] = 409;
            $arr['msg'] = '请求错误,没有传入预期最大结果';
        } else if (!isset($data['minus_num'])) {
            $arr['code'] = 409;
            $arr['msg'] = '请求错误,没有传入减号数';
        } else if (!isset($data['group_num'])) {
            $arr['code'] = 403;
            $arr['msg'] = '没有传入题目行数';
        } else if (!isset($data['topic_num'])) {
            $arr['code'] = 404;
            $arr['msg'] = '没有传入题目列数';
        } else if ($data['group_num'] < 1 || $data['group_num'] > 50) {
            $arr['code'] = 405;
            $arr['msg'] = '传入行数错误,限制1-50';
        } else if ($data['topic_num'] < 1 || $data['group_num'] > 10) {
            $arr['code'] = 406;
            $arr['msg'] = '列数传入错误,限制1-10';
        }
        // else if(in_array('12',$data['topic'])){
        //  if(!in_array('1',$data['topic']) || !in_array('2',$data['topic']) || !in_array('3',$data['topic']) || !in_array('4',$data['topic']) || !in_array('5',$data['topic']) || !in_array('6',$data['topic']) || !in_array('7',$data['topic']) || !in_array('8',$data['topic']) || !in_array('9',$data['topic']) || !in_array('10',$data['topic']) || !in_array('11',$data['topic']))
        //  {
        //      $arr['code']=407;
        //      $arr['msg']='选择直加直减必须选中子选项';
        //  }
        // }
        // else if(in_array('17',$data['topic']))
        // {
        //  if(!in_array('13',$data['topic']) || !in_array('14',$data['topic']) || !in_array('15',$data['topic']) || !in_array('16',$data['topic']))
        //  {
        //      $arr['code']=408
        //  }
        // }
        else {
            $heli = true;
            foreach ($data['degital'] as $key => $value) {
                if ($value['position'] > 10) {
                    $arr['code'] = 407;
                    $arr['msg'] = '位数不能超过10';
                    $heli = false;
                }
            }
            if ($heli = true) {
                //定义特殊关系数组
                $bixurelation = array(); //必须包含什么
                $fullfiverelation = array(); //满五特殊关系
                $killfiverelation = array(); //破五特殊关系
                $fullpositionrelation = array(); //进位特殊关系
                $killpositionrelation = array(); //退位特殊关系
                $fullpositionkillfiverelation = array(); //进位破五关系
                $killpositionfullfiverelation = array(); //退位满五关系
                sort($data['topic']);
                foreach ($data['topic'] as $key => $value) {
                    //分情况填充特殊关系数组
                    if ($value >= 1 && $value <= 52) {
                        switch ($value) {
                            case $value < 12:
                                array_push($bixurelation, $value);
                                break;

                            case $value == 12:
                                $bixurelation = [12];
                                break;

                            case $value > 12 && $value < 17:
                                array_push($fullfiverelation, $value);
                                break;

                            case $value == 17:
                                $fullfiverelation = [17];
                                break;

                            case $value > 17 && $value < 22:
                                array_push($killfiverelation, $value);
                                break;

                            case $value == 22:
                                $killfiverelation = [22];
                                break;

                            case $value > 22 && $value < 32:
                                array_push($fullpositionrelation, $value);
                                break;

                            case $value == 32:
                                $fullpositionrelation = [32];
                                break;

                            case $value > 32 && $value < 42:
                                array_push($killpositionrelation, $value);
                                break;

                            case $value == 42:
                                $killpositionrelation = [42];
                                break;

                            case $value > 42 && $value < 47:
                                array_push($fullpositionkillfiverelation, $value);
                                break;

                            case $value == 47:
                                $fullpositionkillfiverelation = [47];
                                break;

                            case $value > 47 && $value < 52:
                                array_push($killpositionfullfiverelation, $value);
                                break;

                            case $value == 52:
                                $killpositionfullfiverelation = [52];
                                break;
                        }
                    }
                }
                $res = array();
                for ($i = 0; $i < $data['group_num']; $i++) {
                    for ($j = 0; $j < $data['topic_num']; $j++) {
                        //从每个特殊关系数组中取一个值传入core框架
                        if (empty($bixurelation)) {
                            $bixurelation = '';
                            $bixurls = [12];
                        } else {
                            $bixurelationb = array_rand($bixurelation);
                            $bixurls = $bixurelation[$bixurelationb];
                        }
                        if (empty($fullfiverelation)) {
                            $fullfiverls = '';
                        } else {
                            $fullfiverelationb = array_rand($fullfiverelation);
                            $fullfiverls = $fullfiverelation[$fullfiverelationb];
                        }
                        if (empty($killfiverelation)) {
                            $killfiverls = '';
                        } else {
                            $killfiverelationb = array_rand($killfiverelation);
                            $killfiverls = $killfiverelation[$killfiverelationb];
                        }
                        if (empty($fullpositionrelation)) {
                            $fullpositionrls = '';
                        } else {
                            $fullpositionrelationb = array_rand($fullpositionrelation);
                            $fullpositionrls = $fullpositionrelation[$fullpositionrelationb];
                        }
                        if (empty($killpositionrelation)) {
                            $killpositionrls = '';
                        } else {
                            $killpositionrelationb = array_rand($killpositionrelation);
                            $killpositionrls = $killpositionrelation[$killpositionrelationb];
                        }
                        if (empty($fullpositionkillfiverelation)) {
                            $fullpositionkillfiverls = '';
                        } else {
                            $fullpositionkillfiverelationb = array_rand($fullpositionkillfiverelation);
                            $fullpositionkillfiverls = $fullpositionkillfiverelation[$fullpositionkillfiverelationb];
                        }
                        if (empty($killpositionfullfiverelation)) {
                            $killpositionfullfiverls = '';
                        } else {
                            $killpositionfullfiverelationb = array_rand($killpositionfullfiverelation);
                            $killpositionfullfiverls = $killpositionfullfiverelation[$killpositionfullfiverelationb];
                        }
                        //刹车程序
                        if ($dajishuqi > 5000) {
                            $i = $data['group_num']; //如果大计数器大于5000,这时就是返回空或重复算式的情况连续大于5000次,终止掉for循环,将得到的算式返回

                        } else {
                            //红框之间关系的一次调整,调整前为和的关系,之后为或的关系
                            if ($fullfiverls != '' || $killfiverls != '' || $fullpositionrls != '' || $killpositionrls != '' || $fullpositionkillfiverls != '' || $killpositionfullfiverls != '') {
                                $abelarr[0]['value'] = $fullfiverls;
                                $abelarr[0]['name'] = 'fullfiverls';
                                $abelarr[1]['value'] = $killfiverls;
                                $abelarr[1]['name'] = 'killfiverls';
                                $abelarr[2]['value'] = $fullpositionrls;
                                $abelarr[2]['name'] = 'fullpositionrls';
                                $abelarr[3]['value'] = $killpositionrls;
                                $abelarr[3]['name'] = 'killpositionrls';
                                $abelarr[4]['value'] = $fullpositionkillfiverls;
                                $abelarr[4]['name'] = 'fullpositionkillfiverls';
                                $abelarr[5]['value'] = $killpositionfullfiverls;
                                $abelarr[5]['name'] = 'killpositionfullfiverls';
                                do {
                                    $abel = rand(0, 5);
                                } while ($abelarr[$abel]['value'] == '');
                                for ($k = 0; $k <= 5; $k++) {
                                    if ($k == $abel) {
                                        $bianliangming = $abelarr[$k]['name'];
                                        $$bianliangming = $abelarr[$k]['value'];
                                    } else {
                                        $bianliangming = $abelarr[$k]['name'];
                                        $$bianliangming = '';
                                    }
                                }
                            }
                            //判断如果是综合题,所有的选择均作废,只传入$zonghe=1
                            $zonghe = $data['zonghe'];
                            if ($zonghe == 1) {
                                $fullfiverls = '';
                                $killfiverls = '';
                                $fullpositionrls = '';
                                $killpositionrls = '';
                                $fullpositionkillfiverls = '';
                                $killpositionfullfiverls = '';
                            }
                            if ($data['tongmashu'] == 1) {
                                $result = $this->tmcore($data['degital'], $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $data['minresult'], $data['maxresult'], $data['minus_num'], $zonghe, 0);
                            } else {
                                $result = $this->core($data['degital'], $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $data['minresult'], $data['maxresult'], $data['minus_num'], $zonghe, 0);
                            }
                            //如果请求core框架 result为空 大计数器++ j--
                            if ($result == '') {
                                $j--; //j--重新来过
                                $dajishuqi++;
                            } else {
                                //根据返回结果中的算式得到数组
                                for ($u = 0; $u <= count($result) - 1; $u++) {
                                    if ($result[$u]['thisfuhao'] == '-') {
                                        if ($data['xiaoshudian'] == 1) {
                                            $suanshiarr[$u] = '-' . $result[$u]['thisnum'] / 10;
                                        } else if ($data['xiaoshudian'] == 2) {
                                            $suanshiarr[$u] = '-' . $result[$u]['thisnum'] / 100;
                                        } else {
                                            $suanshiarr[$u] = '-' . $result[$u]['thisnum'];
                                        }
                                        if ($data['qianfenwei'] == 1) {
                                            $wqshuzhi = substr((string)$suanshiarr[$u], 1, strlen($suanshiarr[$u]));
                                            $suanshiarr[$u] = '-' . preg_replace('/(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))/', ',', $wqshuzhi);
                                        }
                                    } else {
                                        if ($data['xiaoshudian'] == 1) {
                                            $suanshiarr[$u] = $result[$u]['thisnum'] / 10;
                                        } else if ($data['xiaoshudian'] == 2) {
                                            $suanshiarr[$u] = $result[$u]['thisnum'] / 100;
                                        } else {
                                            $suanshiarr[$u] = $result[$u]['thisnum'];
                                        }
                                        if ($data['qianfenwei'] == 1) {
                                            if (substr((string)$suanshiarr[$u], 0, 1) == '-') {
                                                $wqfuhao = '-';
                                                $wqshuzhi = substr((string)$suanshiarr[$u], 1, strlen($suanshiarr[$u]));
                                                $suanshiarr[$u] = '-' . preg_replace('/(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))/', ',', $wqshuzhi);
                                            } else {
                                                $suanshiarr[$u] = preg_replace('/(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))/', ',', $suanshiarr[$u]);
                                            }
                                        }
                                    }
                                }
                                $suanshi = $result[count($result) - 1]['suanshi'];
                                if ($data['xiaoshudian'] == 1) {
                                    $jieguo = $result[count($result) - 1]['thisjieguo'] / 10;
                                } else if ($data['xiaoshudian'] == 2) {
                                    $jieguo = $result[count($result) - 1]['thisjieguo'] / 100;
                                } else {
                                    $jieguo = $result[count($result) - 1]['thisjieguo'];
                                }
                                //如果重复 大计数器++ j--
                                if (strpos(json_encode($res) , (string)$suanshi) !== false) {
                                    $j--; //j--重新来过
                                    $dajishuqi++;
                                } else {
                                    $dajishuqi = 0; //大计数器归零
                                    $res[$i][$j]['topic'] = $suanshi;
                                    $res[$i][$j]['suanshiarr'] = $suanshiarr;
                                    $res[$i][$j]['jieguo'] = $jieguo;
                                }
                            }
                        }
                        //$res[$i][$j]=$i.$j;

                    }
                }
                if ($res) {
                    $arr['code'] = 200;
                    $arr['msg'] = '成功';
                    $arr['data'] = $res;
                    $arr['message'] = 1;
                } else {
                    $arr['code'] = 404;
                    $arr['msg'] = '作业不存在';
                    $arr['data'] = $res;
                    $arr['message'] = 2;
                }
            }
        }
        return json_encode($arr);
    }
    //核心
    /*

      @param

      detail 笔数 位数 详情数组

      bixurls 第一个红框里的随机的关系

      fullfiverls 满五红框里随机的关系

      killfiverls 破五红框里随机的关系

      fullpositionrls 进位红框里随机的关系

      killpositionrls 退位红框里随机的关系

      fullpositionkillfiverls 破五进位红框里的随机关系

      killpositionfullfiverls 满五退位红框里的随机关系

      minresult 最小预期结果值

      maxresult 最大预期结果值

      minus_num 减号数

      zonghe 是否为综合题

      diguicishu 递归次数

      @return

      thisfuhao 当前符号 + -

      thisnum 当前数字符 1 2 3

      thisnumstr 当前数字符记录变量 1 12 123

      thisres 当前位的结果

      thisjieguo 当前算式的结果

      suanshi 当前算式

      PS:XXb为当前值所在可随机选当前值数组中的下标

    */
    public function core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu) {
        //判断递归次数是否小于500 大于等于500,不再继续下去
        if ($diguicishu < 500) {
            $line = 0;
            $positionarray = [];
            /*接收detail值获取总笔数 最大位数 以及具体几笔几位*/
            foreach ($detail as $key => $value) {
                $line+= $value['line']; //得到总笔数
                $temp = $value['line'];
                while ($temp) {
                    array_push($positionarray, $value['position']);
                    $temp--;
                }
            } //通过用户传入的笔数位数数组算出排列组合
            $maxposition = max($positionarray); //最大位数
            //print_r($positionarray);
            shuffle($positionarray); //打乱顺序随机让X位出现在第Y笔
            $this->setlog('positionarray', json_encode($positionarray));
            //得到基本算法 如果综合题直接投机
            if ($zonghe == 1) {
                $bixude = '';
                $jibensuanfa = 'onetoall';
            } else {
                if ($bixurls == '') {
                    $bixude = '';
                    $jibensuanfa = 'onetonine';
                } else {
                    $bixufunc = $this->jiansuo() [$bixurls];
                    $bixude = $this->$bixufunc();
                    $jibensuanfa = $bixufunc; //如果第一个框选择的不是1-4或1-9 需要把bixude传入必须出现的字符

                }
            }
            //将得到的特殊关系安排在某一笔某一位上
            if ($fullfiverls == '') {
                $fullfivede = '';
                $fullfiveteshu['line'] = 0;
                $fullfiveteshu['weishu'] = - 1;
            } else {
                $fullfivefunc = $this->jiansuo() [$fullfiverls];
                $fullfivede = $this->$fullfivefunc();
                $fullfiveteshu['line'] = rand(1, $line - 1);
                $fullfiveteshu['weishu'] = rand($maxposition - $positionarray[$fullfiveteshu['line']], $maxposition - 1);
            }
            if ($killfiverls == '') {
                $killfivede = '';
                $killfiveteshu['line'] = 0;
                $killfiveteshu['weishu'] = - 1;
            } else {
                $killfivefunc = $this->jiansuo() [$killfiverls];
                $killfivede = $this->$killfivefunc();
                do {
                    $killfiveteshu['line'] = rand(1, $line - 1);
                    $killfiveteshu['weishu'] = rand($maxposition - $positionarray[$killfiveteshu['line']], $maxposition - 1);
                } while ($killfiveteshu['line'] == $fullfiveteshu['line'] && $killfiveteshu['weishu'] == $fullfiveteshu['weishu']);
            }
            if ($fullpositionrls == '') {
                $fullpositionde = '';
                $fullpositionteshu['line'] = 0;
                $fullpositionteshu['weishu'] = - 1;
            } else {
                $fullpositionfunc = $this->jiansuo() [$fullpositionrls];
                $fullpositionde = $this->$fullpositionfunc();
                do {
                    $fullpositionteshu['line'] = rand(1, $line - 1);
                    $fullpositionteshu['weishu'] = rand($maxposition - $positionarray[$fullpositionteshu['line']], $maxposition - 1);
                } while (($fullpositionteshu['line'] == $fullfiveteshu['line'] && $fullpositionteshu['weishu'] == $fullfiveteshu['weishu']) || ($fullpositionteshu['line'] == $killfiveteshu['line'] && $fullpositionteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($killpositionrls == '') {
                $killpositionde = '';
                $killpositionteshu['line'] = 0;
                $killpositionteshu['weishu'] = - 1;
            } else {
                $killpositionfunc = $this->jiansuo() [$killpositionrls];
                $killpositionde = $this->$killpositionfunc();
                do {
                    $killpositionteshu['line'] = rand(1, $line - 1);
                    $killpositionteshu['weishu'] = rand($maxposition - $positionarray[$killpositionteshu['line']], $maxposition - 1);
                } while (($killpositionteshu['line'] == $fullfiveteshu['line'] && $killpositionteshu['weishu'] == $fullfiveteshu['weishu']) || ($killpositionteshu['line'] == $fullpositionteshu['line'] && $killpositionteshu['weishu'] == $fullpositionteshu['weishu']) || ($killpositionteshu['line'] == $killfiveteshu['line'] && $killpositionteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($fullpositionkillfiverls == '') {
                $fullpositionkillfivede = '';
                $fullpositionkillfiveteshu['line'] = 0;
                $fullpositionkillfiveteshu['weishu'] = - 1;
            } else {
                $fullpositionkillfivefunc = $this->jiansuo() [$fullpositionkillfiverls];
                $fullpositionkillfivede = $this->$fullpositionkillfivefunc();
                do {
                    $fullpositionkillfiveteshu['line'] = rand(1, $line - 1);
                    $fullpositionkillfiveteshu['weishu'] = rand($maxposition - $positionarray[$fullpositionkillfiveteshu['line']], $maxposition - 1);
                } while (($fullpositionkillfiveteshu['line'] == $fullfiveteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $fullfiveteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $killpositionteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $killpositionteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $fullpositionteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $fullpositionteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $killfiveteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($killpositionfullfiverls == '') {
                $killpositionfullfivede = '';
                $killpositionfullfiveteshu['line'] = 0;
                $killpositionfullfiveteshu['weishu'] = - 1;
            } else {
                $killpositionfullfivefunc = $this->jiansuo() [$killpositionfullfiverls];
                $killpositionfullfivede = $this->$killpositionfullfivefunc();
                do {
                    $killpositionfullfiveteshu['line'] = rand(1, $line - 1);
                    $killpositionfullfiveteshu['weishu'] = rand($maxposition - $positionarray[$killpositionfullfiveteshu['line']], $maxposition - 1);
                } while (($killpositionfullfiveteshu['line'] == $fullfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullfiveteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $fullpositionkillfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullpositionkillfiveteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $killpositionteshu['line'] && $killpositionfullfiveteshu['weishu'] == $killpositionteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $fullpositionteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullpositionteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $killfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $killfiveteshu['weishu']));
            }
            $res = $this->$jibensuanfa();
            //打乱这个组合
            /*外层循环 循环笔数 内层循环 循环位数 位数不够先补0*/
            $waiceng = 0;
            for ($i = 0; $i < $line; $i++) {
                $thisnum = ''; //初始化当前数字符 1 2 3
                $thisnumstr = ''; //初始化当前数字符记录变量 1 12 123
                $suanshi = '';
                if ($killpositionde != "") {
                    if ($killpositionteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($killfivede != "") {
                    if ($killfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($killpositionfullfivede != "") {
                    if ($killpositionfullfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($fullpositionkillfivede != "") {
                    if ($fullpositionkillfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                if ($fullpositionde != "") {
                    if ($fullpositionteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                if ($fullfivede != "") {
                    if ($fullfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                //这里求到了满足特殊关系的特殊符号,以待后期优化
                for ($j = 0; $j < $maxposition; $j++) {
                    //$res=$this->onetofour();
                    $res = $this->$jibensuanfa(); //获取算法名这里现在只支持单算法,不支持综合
                    $chawei = $maxposition - $positionarray[$i] - $j; //差位补零
                    /*这里做了分情况处理 第一笔和剩下的笔区分对待*/
                    if ($i == 0) {
                        $thisfuhao = '+'; //第一笔默认符号为+
                        if ($chawei > 0) {
                            //差位补0
                            $thisnumstr = $thisnumstr . '0';
                            $thisnum = 0;
                            $thisres = 0;
                        } else if ($chawei == 0) {
                            // $res['next'] = array_merge($res['next']);//重新排序
                            $thisnumb = array_rand($res['next'], 1);
                            $thisnum = $res['next'][$thisnumb];
                            $thisnumstr = $thisnumstr . $res['next'][$thisnumb];
                            $thisres = $thisnum;
                        } else {
                            foreach ($res['first'] as $key => $value) {
                                // code...
                                if ($j > 0) {
                                    if ($jiyiarr[$i][$j - 1]['thisnum'] == $value) {
                                        unset($res['first'][$key]); //从可随机字符中去除与上一位所选字符相同的一个

                                    }
                                }
                            }
                            $res['first'] = array_merge($res['first']); //重新排序
                            if (empty($res['first'])) {
                                $diguicishu++;
                                return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                            }
                            $thisnumb = array_rand($res['first'], 1);
                            $thisnum = $res['first'][$thisnumb];
                            $thisnumstr = $thisnumstr . $res['first'][$thisnumb];
                            $thisres = $thisnum;
                        }
                    } else {
                        if ($chawei > 0) {
                            //差位补0
                            $thisnumstr = $thisnumstr . '0';
                            $thisnum = 0;
                            if (isset($teshufuhao[$i])) {
                                $thisfuhao = $teshufuhao[$i];
                            }
                            $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'];
                        } else {
                            $shangcijieguo = $jiyiarr[$i - 1][$j]['thisjieguo']; //取出来上笔该位的结果
                            $res = $this->$jibensuanfa();
                            $next = $res['relation'][$shangcijieguo]; //通过结果和算法对应关系的数组获取当前位的可随机选数组
                            //如果该笔存在特殊关系,则从特殊关系数组的特殊关系中获取当前位的可随机选数组
                            if ($fullfivede != "") {
                                if ($fullfiveteshu['line'] == $i && $fullfiveteshu['weishu'] == $j) {
                                    $next = $fullfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killfivede != "") {
                                if ($killfiveteshu['line'] == $i && $killfiveteshu['weishu'] == $j) {
                                    $next = $killfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($fullpositionde != "") {
                                if ($fullpositionteshu['line'] == $i && $fullpositionteshu['weishu'] == $j) {
                                    $next = $fullpositionde['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killpositionde != "") {
                                if ($killpositionteshu['line'] == $i && $killpositionteshu['weishu'] == $j) {
                                    $next = $killpositionde['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($fullpositionkillfivede != "") {
                                if ($fullpositionkillfiveteshu['line'] == $i && $fullpositionkillfiveteshu['weishu'] == $j) {
                                    $next = $fullpositionkillfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killpositionfullfivede != "") {
                                if ($killpositionfullfiveteshu['line'] == $i && $killpositionfullfiveteshu['weishu'] == $j) {
                                    $next = $killpositionfullfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            foreach ($next as $key => $value) {
                                //判断正负获取绝对值
                                if (substr($value, 0, -1) == "-") {
                                    $thisfuhao1 = '-';
                                    $v = substr($value, 1, strlen($value));
                                } else {
                                    $thisfuhao1 = "+";
                                    $v = $value;
                                }
                                // if ($j == 0) {
                                //     if ($zonghe == 1) {
                                //         if ($jiyiarr[$i - 1][$j]['thisjieguo'] - $v < 2 && $thisfuhao1 == '-') {
                                //             unset($next[$key]);
                                //         }
                                //         if ($jiyiarr[$i - 1][$j]['thisjieguo'] + $v > 9 && $thisfuhao1 == '+') {
                                //             unset($next[$key]);
                                //         }
                                //     }
                                // }
                                if ($jyarr[$i - 1]['zzyuqifuhao'] != '') {
                                    if ($thisfuhao1 != $jyarr[$i - 1]['zzyuqifuhao']) {
                                        unset($next[$key]);
                                    }
                                }
                                //如果不是第一位时
                                if ($j > 0) {
                                    if (isset($jiyiarr[$i][$j - 1]['thisfuhao']) && $jiyiarr[$i][$j - 1]['thisfuhao'] != '') {
                                        if ($jiyiarr[$i][$j - 1]['thisfuhao'] != $thisfuhao1) {
                                            unset($next[$key]); //判断与前一位不相等符号的去除

                                        }
                                    }
                                    if ($jiyiarr[$i][$j - 1]['thisnum'] == $v) {
                                        unset($next[$key]); //判断与前一位数字符相等的去除

                                    }
                                }
                                if ($line >= 3) {
                                    if ($jiyiarr[$i - 1][$j]['thisnum'] == $v && $jiyiarr[$i - 1][$j]['thisfuhao'] != $thisfuhao1) {
                                        unset($next[$key]); //与上笔同位的字符相等的去除

                                    }
                                }
                            }
                            $next = array_merge($next); //重新排列数组
                            if (count($next) <= 0) {
                                $diguicishu++;
                                $yqsuanshi = '';
                                for ($x = 0; $x < $j; $x++) {
                                    $yqsuanshi = $yqsuanshi . $jiyiarr[$i][$x]['thisnum'];
                                }
                                $this->setlog('meizhile', '上笔算式' . $jyarr[$i - 1]['suanshi'] . '=====' . json_encode($positionarray) . '====' . $yqsuanshi . '======' . $thisfuhao . '=====' . $i . ',' . $j . "\r\n");
                                return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                            }
                            $thisnumb = array_rand($next);
                            $thisnuma = $next[$thisnumb];
                            //分开加减已求结果和算式
                            if (substr($thisnuma, 0, 1) == '-') {
                                $thisnum = substr($thisnuma, 1, strlen($thisnuma));
                                $thisnumstr = $thisnumstr . substr($thisnuma, 1, strlen($thisnuma));
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] - $thisnum;
                                if ($thisres < 0) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 5) {
                                                if ($killfivede != "" && $killfiverls == 18) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 4;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        }
                                    }
                                    $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + 10 - $thisnum;
                                }
                                $thisfuhao = '-';
                            } else {
                                $thisnum = $thisnuma;
                                $thisnumstr = $thisnumstr . $thisnuma;
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + $thisnuma;
                                if ($thisres >= 10) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                                if ($fullfivede != "" && $fullfiverls == 13) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        }
                                        if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                            $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                        } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                            if ($fullfivede != "" && $fullfiverls == 13) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                            } else {
                                                $diguicishu++;
                                                return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                            }
                                        } else {
                                            $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                            $y = 0;
                                        }
                                    }
                                    $thisres = substr($thisres, 1, 1);
                                }
                                $thisfuhao = '+';
                            }
                        }
                    }
                    //得到内层的记忆数组[$i][$j]里的具体内容
                    $jiyiarr[$i][$j] = array(
                        'thisnum' => $thisnum,
                        'thisnumstr' => $thisnumstr,
                        'thisfuhao' => $thisfuhao,
                        'thisjieguo' => $thisres
                    );
                }
                $thisnum = (int)$thisnumstr; //从内层出来将thisnumstr值赋给$thisnum开始算外层
                //分笔数 第一笔和剩下的笔
                if ($i == 0) {
                    $thisjieguo = $thisnum;
                    $suanshi = $thisnum;
                    $shangcisuanshi = '';
                } else {
                    if ($thisfuhao == '-') {
                        $thisjieguo = $jyarr[$i - 1]['thisjieguo'] - $thisnum;
                        $suanshi = $jyarr[$i - 1]['suanshi'] . '-' . $thisnum;
                    } else {
                        $thisjieguo = $jyarr[$i - 1]['thisjieguo'] + $thisnum;
                        $suanshi = $jyarr[$i - 1]['suanshi'] . '+' . $thisnum;
                    }
                    $shangcisuanshi = $jyarr[$i - 1]['suanshi'];
                }
                if ($thisjieguo < 0) {
                    $diguicishu++;
                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
                $jieguolength = strlen($thisjieguo);
                //王强的预期符号
                $jiaheli = true;
                $wqyuqifuhao = '+';
                for ($u = 0; $u < $jieguolength; $u++) {
                    $wqjieguo = substr($thisjieguo, $u, 1); //获得上次结果每一位的值
                    $wqnum = substr($thisnum, $u, 1); //获得上笔每一位的值
                    $jbsfres = $this->$jibensuanfa();
                    $wqnext = $jbsfres['relation'][$wqjieguo];
                    foreach ($wqnext as $key => $value) {
                        //判断正负获取绝对值
                        if (substr($value, 0, -1) == "-") {
                            $thisfuhao2 = '-';
                            $v = substr($value, 1, strlen($value));
                        } else {
                            $thisfuhao2 = "+";
                            $v = $value;
                        }
                        //如果不是第一位时
                        if ($thisfuhao2 != $wqyuqifuhao) {
                            unset($wqnext[$key]); //判断与前一位不相等符号的去除

                        }
                        if ($wqnum == $v) {
                            unset($wqnext[$key]); //判断与前一笔数字符相等的去除

                        }
                    }
                    $wqnext = array_merge($wqnext);
                    if (empty($wqnext)) {
                        $jiaheli = false;
                    }
                }
                $jianheli = true;
                $wqyuqifuhao = '-';
                for ($u = 0; $u < $jieguolength; $u++) {
                    $wqjieguo = substr($thisjieguo, $u, 1); //获得上次结果每一位的值
                    $wqnum = substr($thisnum, $u, 1); //获得上笔每一位的值
                    $jbsfres = $this->$jibensuanfa();
                    $wqnext = $jbsfres['relation'][$wqjieguo];
                    foreach ($wqnext as $key => $value) {
                        //判断正负获取绝对值
                        if (substr($value, 0, -1) == "-") {
                            $thisfuhao2 = '-';
                            $v = substr($value, 1, strlen($value));
                        } else {
                            $thisfuhao2 = "+";
                            $v = $value;
                        }
                        //如果不是第一位时
                        if ($thisfuhao2 != $wqyuqifuhao) {
                            unset($wqnext[$key]); //判断与前一位不相等符号的去除

                        }
                        if ($wqnum == $v) {
                            unset($wqnext[$key]); //判断与前一笔数字符相等的去除

                        }
                    }
                    $wqnext = array_merge($wqnext);
                    if (empty($wqnext)) {
                        $jianheli = false;
                    }
                    if ($i < $line - 1) {
                        if ($positionarray[$i] < $positionarray[$i + 1]) {
                            $jianheli = false;
                        }
                    }
                }
                // if($i<$line-1){
                //     $this->setlog('jiajianheli','===+==='.$jiaheli.'===-==='.$jianheli.'==='.$thisjieguo.'==='.$thisnum.'==='.$positionarray[$i+1]."\r\n");
                // }
                $zzheli = true;
                if ($jiaheli == true && $jianheli == true) {
                    $wqzzyuqifuhao = '';
                } else if ($jiaheli == false && $jianheli == true) {
                    $wqzzyuqifuhao = '-';
                } else if ($jiaheli == true && $jianheli == false) {
                    $wqzzyuqifuhao = '+';
                } else if ($jiaheli == false && $jianheli == false) {
                    $wqzzyuqifuhao = '';
                    $zzheli = false;
                    // $zzheli=false;
                    // $i--;
                    // $diguicishu++;
                    // return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $diguicishu);
                    // exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
                if ($minresult != "") {
                    if ($thisjieguo < $minresult) {
                        $diguicishu++;
                        return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                }
                if ($maxresult != "") {
                    if ($thisjieguo > $maxresult) {
                        $diguicishu++;
                        return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                }
                //得到外层thisjieguo和suanshi
                if ($zzheli == true) {
                    $jyarr[$i] = array(
                        'thisnum' => $thisnum,
                        'thisnumstr' => $thisnumstr,
                        'zzyuqifuhao' => $wqzzyuqifuhao,
                        'thisfuhao' => $thisfuhao,
                        'thisjieguo' => $thisjieguo,
                        'suanshi' => $suanshi
                    );
                    $waiceng = 0;
                } else {
                    $jyarr[$i] = array();
                    $jiyiarr[$i] = array();
                    if ($i > 0 && $waiceng < 20) {
                        $waiceng++;
                        $i--;
                    } else {
                        $waiceng = 0;
                        $diguicishu++;
                        return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                    $thisfuhao = '';
                    $thisnum = '';
                }
            }
            $jyarrcount = count($jyarr);

            if ($minus_num != '') {
                if (substr_count($jyarr[$jyarrcount - 1]['suanshi'], '-') != $minus_num) {
                    $diguicishu++;
                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
            }
            $heli = false;
            $z = count($jyarr) - 1;
            //判断是否必须出现某个值
            if (!empty($res['bixu'])) {
                foreach ($res['bixu'] as $key => $value) {
                    if (substr($value, 0, 1) == '-') {
                        $valuestr = $value;
                    } else {
                        $valuestr = '+' . $value;
                    }
                    if (strpos($jyarr[$z]['suanshi'], (string)$valuestr) !== false) {
                        $heli = true;
                    }
                }
                if ($heli == false) {
                    $diguicishu++;
                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
            }
        } else {
            $jyarr = '';
        }
        return $jyarr;
    }
    //同码数算法核心
    /*

      @param

      detail 笔数 位数 详情数组

      bixurls 第一个红框里的随机的关系

      fullfiverls 满五红框里随机的关系

      killfiverls 破五红框里随机的关系

      fullpositionrls 进位红框里随机的关系

      killpositionrls 退位红框里随机的关系

      fullpositionkillfiverls 破五进位红框里的随机关系

      killpositionfullfiverls 满五退位红框里的随机关系

      minresult 最小预期结果值

      maxresult 最大预期结果值

      minus_num 减号数

      zonghe 是否为综合题

      diguicishu 递归次数

      @return

      thisfuhao 当前符号 + -

      thisnum 当前数字符 1 2 3

      thisnumstr 当前数字符记录变量 1 12 123

      thisres 当前位的结果

      thisjieguo 当前算式的结果

      suanshi 当前算式

      PS:XXb为当前值所在可随机选当前值数组中的下标

    */
    public function tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu) {
        //判断递归次数是否小于500 大于等于500,不再继续下去
        if ($diguicishu < 500) {
            $line = 0;
            $positionarray = [];
            /*接收detail值获取总笔数 最大位数 以及具体几笔几位*/
            foreach ($detail as $key => $value) {
                $line+= $value['line']; //得到总笔数
                $temp = $value['line'];
                while ($temp) {
                    array_push($positionarray, $value['position']);
                    $temp--;
                }
            } //通过用户传入的笔数位数数组算出排列组合
            $maxposition = max($positionarray); //最大位数
            //print_r($positionarray);
            shuffle($positionarray); //打乱顺序随机让X位出现在第Y笔
            $this->setlog('positionarray', json_encode($positionarray));
            //得到基本算法 如果综合题直接投机
            if ($zonghe == 1) {
                $bixude = '';
                $jibensuanfa = 'onetoall';
            } else {
                if ($bixurls == '') {
                    $bixude = '';
                    $jibensuanfa = 'onetonine';
                } else {
                    $bixufunc = $this->jiansuo() [$bixurls];
                    $bixude = $this->$bixufunc();
                    $jibensuanfa = $bixufunc; //如果第一个框选择的不是1-4或1-9 需要把bixude传入必须出现的字符

                }
            }
            //将得到的特殊关系安排在某一笔某一位上
            if ($fullfiverls == '') {
                $fullfivede = '';
                $fullfiveteshu['line'] = 0;
                $fullfiveteshu['weishu'] = - 1;
            } else {
                $fullfivefunc = $this->jiansuo() [$fullfiverls];
                $fullfivede = $this->$fullfivefunc();
                $fullfiveteshu['line'] = rand(1, $line - 1);
                $fullfiveteshu['weishu'] = $maxposition - $positionarray[$fullfiveteshu['line']];
            }
            if ($killfiverls == '') {
                $killfivede = '';
                $killfiveteshu['line'] = 0;
                $killfiveteshu['weishu'] = - 1;
            } else {
                $killfivefunc = $this->jiansuo() [$killfiverls];
                $killfivede = $this->$killfivefunc();
                do {
                    $killfiveteshu['line'] = rand(1, $line - 1);
                    $killfiveteshu['weishu'] = $maxposition - $positionarray[$killfiveteshu['line']];
                } while ($killfiveteshu['line'] == $fullfiveteshu['line'] && $killfiveteshu['weishu'] == $fullfiveteshu['weishu']);
            }
            if ($fullpositionrls == '') {
                $fullpositionde = '';
                $fullpositionteshu['line'] = 0;
                $fullpositionteshu['weishu'] = - 1;
            } else {
                $fullpositionfunc = $this->jiansuo() [$fullpositionrls];
                $fullpositionde = $this->$fullpositionfunc();
                do {
                    $fullpositionteshu['line'] = rand(1, $line - 1);
                    $fullpositionteshu['weishu'] = $maxposition - $positionarray[$fullpositionteshu['line']];
                } while (($fullpositionteshu['line'] == $fullfiveteshu['line'] && $fullpositionteshu['weishu'] == $fullfiveteshu['weishu']) || ($fullpositionteshu['line'] == $killfiveteshu['line'] && $fullpositionteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($killpositionrls == '') {
                $killpositionde = '';
                $killpositionteshu['line'] = 0;
                $killpositionteshu['weishu'] = - 1;
            } else {
                $killpositionfunc = $this->jiansuo() [$killpositionrls];
                $killpositionde = $this->$killpositionfunc();
                do {
                    $killpositionteshu['line'] = rand(1, $line - 1);
                    $killpositionteshu['weishu'] = $maxposition - $positionarray[$killpositionteshu['line']];
                } while (($killpositionteshu['line'] == $fullfiveteshu['line'] && $killpositionteshu['weishu'] == $fullfiveteshu['weishu']) || ($killpositionteshu['line'] == $fullpositionteshu['line'] && $killpositionteshu['weishu'] == $fullpositionteshu['weishu']) || ($killpositionteshu['line'] == $killfiveteshu['line'] && $killpositionteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($fullpositionkillfiverls == '') {
                $fullpositionkillfivede = '';
                $fullpositionkillfiveteshu['line'] = 0;
                $fullpositionkillfiveteshu['weishu'] = - 1;
            } else {
                $fullpositionkillfivefunc = $this->jiansuo() [$fullpositionkillfiverls];
                $fullpositionkillfivede = $this->$fullpositionkillfivefunc();
                do {
                    $fullpositionkillfiveteshu['line'] = rand(1, $line - 1);
                    $fullpositionkillfiveteshu['weishu'] = $maxposition - $positionarray[$fullpositionkillfiveteshu['line']];
                } while (($fullpositionkillfiveteshu['line'] == $fullfiveteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $fullfiveteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $killpositionteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $killpositionteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $fullpositionteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $fullpositionteshu['weishu']) || ($fullpositionkillfiveteshu['line'] == $killfiveteshu['line'] && $fullpositionkillfiveteshu['weishu'] == $killfiveteshu['weishu']));
            }
            if ($killpositionfullfiverls == '') {
                $killpositionfullfivede = '';
                $killpositionfullfiveteshu['line'] = 0;
                $killpositionfullfiveteshu['weishu'] = - 1;
            } else {
                $killpositionfullfivefunc = $this->jiansuo() [$killpositionfullfiverls];
                $killpositionfullfivede = $this->$killpositionfullfivefunc();
                do {
                    $killpositionfullfiveteshu['line'] = rand(1, $line - 1);
                    $killpositionfullfiveteshu['weishu'] = $maxposition - $positionarray[$killpositionfullfiveteshu['line']];
                } while (($killpositionfullfiveteshu['line'] == $fullfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullfiveteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $fullpositionkillfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullpositionkillfiveteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $killpositionteshu['line'] && $killpositionfullfiveteshu['weishu'] == $killpositionteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $fullpositionteshu['line'] && $killpositionfullfiveteshu['weishu'] == $fullpositionteshu['weishu']) || ($killpositionfullfiveteshu['line'] == $killfiveteshu['line'] && $killpositionfullfiveteshu['weishu'] == $killfiveteshu['weishu']));
            }
            $res = $this->$jibensuanfa();
            //打乱这个组合
            /*外层循环 循环笔数 内层循环 循环位数 位数不够先补0*/
            $waiceng = 0;
            for ($i = 0; $i < $line; $i++) {
                $thisnum = ''; //初始化当前数字符 1 2 3
                $thisnumstr = ''; //初始化当前数字符记录变量 1 12 123
                $suanshi = '';
                if ($killpositionde != "") {
                    if ($killpositionteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($killfivede != "") {
                    if ($killfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($killpositionfullfivede != "") {
                    if ($killpositionfullfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '-';
                    }
                }
                if ($fullpositionkillfivede != "") {
                    if ($fullpositionkillfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                if ($fullpositionde != "") {
                    if ($fullpositionteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                if ($fullfivede != "") {
                    if ($fullfiveteshu['line'] == $i) {
                        $teshufuhao[$i] = '+';
                    }
                }
                //这里求到了满足特殊关系的特殊符号,以待后期优化
                for ($j = 0; $j < $maxposition; $j++) {
                    //$res=$this->onetofour();
                    $res = $this->$jibensuanfa(); //获取算法名这里现在只支持单算法,不支持综合
                    $chawei = $maxposition - $positionarray[$i] - $j; //差位补零
                    /*这里做了分情况处理 第一笔和剩下的笔区分对待*/
                    if ($i == 0) {
                        $thisfuhao = '+'; //第一笔默认符号为+
                        if ($chawei > 0) {
                            //差位补0
                            $thisnumstr = $thisnumstr . '0';
                            $thisnum = 0;
                            $thisres = 0;
                        } else if ($chawei == 0) {
                            // $res['next'] = array_merge($res['next']);//重新排序
                            $thisnumb = array_rand($res['next'], 1);
                            $thisnum = $res['next'][$thisnumb];
                            $thisnumstr = $thisnumstr . $res['next'][$thisnumb];
                            $thisres = $thisnum;
                        } else {
                            $thisnum = $jiyiarr[$i][$j - 1]['thisnum'];
                            $thisnumstr = $thisnumstr . $res['first'][$thisnumb];
                            $thisres = $thisnum;
                        }
                    } else {
                        if ($chawei > 0) {
                            //差位补0
                            $thisnumstr = $thisnumstr . '0';
                            $thisnum = 0;
                            if (isset($teshufuhao[$i])) {
                                $thisfuhao = $teshufuhao[$i];
                            }
                            $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'];
                        } else if ($chawei == 0) {
                            $shangcijieguo = $jiyiarr[$i - 1][$j]['thisjieguo'];
                            $res = $this->$jibensuanfa();
                            $next = $res['relation'][$shangcijieguo];
                            //如果该笔存在特殊关系,则从特殊关系数组的特殊关系中获取当前位的可随机选数组
                            if ($fullfivede != "") {
                                if ($fullfiveteshu['line'] == $i && $fullfiveteshu['weishu'] == $j) {
                                    $next = $fullfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killfivede != "") {
                                if ($killfiveteshu['line'] == $i && $killfiveteshu['weishu'] == $j) {
                                    $next = $killfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($fullpositionde != "") {
                                if ($fullpositionteshu['line'] == $i && $fullpositionteshu['weishu'] == $j) {
                                    $next = $fullpositionde['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killpositionde != "") {
                                if ($killpositionteshu['line'] == $i && $killpositionteshu['weishu'] == $j) {
                                    $next = $killpositionde['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($fullpositionkillfivede != "") {
                                if ($fullpositionkillfiveteshu['line'] == $i && $fullpositionkillfiveteshu['weishu'] == $j) {
                                    $next = $fullpositionkillfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            if ($killpositionfullfivede != "") {
                                if ($killpositionfullfiveteshu['line'] == $i && $killpositionfullfiveteshu['weishu'] == $j) {
                                    $next = $killpositionfullfivede['nrelation'][$shangcijieguo];
                                }
                            }
                            foreach ($next as $key => $value) {
                                //判断正负获取绝对值
                                if (substr($value, 0, -1) == "-") {
                                    $thisfuhao1 = '-';
                                    $v = substr($value, 1, strlen($value));
                                } else {
                                    $thisfuhao1 = "+";
                                    $v = $value;
                                }
                                if ($j == 0) {
                                    // if($zonghe==1)
                                    // {
                                    //     if($jiyiarr[$i-1][$j]['thisjieguo']-$v<2 && $thisfuhao1=='-')
                                    //     {
                                    //         unset($next[$key]);
                                    //     }
                                    //     if($jiyiarr[$i-1][$j]['thisjieguo']+$v>9 && $thisfuhao1=='+')
                                    //     {
                                    //         unset($next[$key]);
                                    //     }
                                    // }

                                }
                                if ($jyarr[$i - 1]['zzyuqifuhao'] != '') {
                                    if ($thisfuhao1 != $jyarr[$i - 1]['zzyuqifuhao']) {
                                        unset($next[$key]);
                                    }
                                }
                                //如果不是第一位时
                                if ($j > 0) {
                                    if (isset($jiyiarr[$i][$j - 1]['thisfuhao']) && $jiyiarr[$i][$j - 1]['thisfuhao'] != '') {
                                        if ($jiyiarr[$i][$j - 1]['thisfuhao'] != $thisfuhao1) {
                                            unset($next[$key]); //判断与前一位不相等符号的去除

                                        }
                                    }
                                }
                                if ($line >= 3) {
                                    if ($jiyiarr[$i - 1][$j]['thisnum'] == $v && $jiyiarr[$i - 1][$j]['thisfuhao'] != $thisfuhao1) {
                                        unset($next[$key]); //与上笔同位的字符相等的去除

                                    }
                                }
                            }
                            $next = array_merge($next); //重新排列数组
                            if (count($next) <= 0) {
                                $diguicishu++;
                                return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                            }
                            $thisnumb = array_rand($next);
                            $thisnuma = $next[$thisnumb];
                            //分开加减已求结果和算式
                            if (substr($thisnuma, 0, 1) == '-') {
                                $thisnum = substr($thisnuma, 1, strlen($thisnuma));
                                $thisnumstr = $thisnumstr . substr($thisnuma, 1, strlen($thisnuma));
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] - $thisnum;
                                if ($thisres < 0) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 5) {
                                                if ($killfivede != "" && $killfiverls == 18) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 4;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        }
                                    }
                                    $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + 10 - $thisnum;
                                }
                                $thisfuhao = '-';
                            } else {
                                $thisnum = $thisnuma;
                                $thisnumstr = $thisnumstr . $thisnuma;
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + $thisnuma;
                                if ($thisres >= 10) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                                if ($fullfivede != "" && $fullfiverls == 13) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        }
                                        if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                            $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                        } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                            if ($fullfivede != "" && $fullfiverls == 13) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                            } else {
                                                $diguicishu++;
                                                return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                            }
                                        } else {
                                            $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                            $y = 0;
                                        }
                                    }
                                    $thisres = substr($thisres, 1, 1);
                                }
                                $thisfuhao = '+';
                            }
                        } else {
                            if ($jiyiarr[$i][$j - 1]['thisfuhao'] == '+') {
                                $thisnuma = $jiyiarr[$i][$j - 1]['thisnum'];
                            } else {
                                $thisnuma = '-' . $jiyiarr[$i][$j - 1]['thisnum'];
                            }
                            if (substr($thisnuma, 0, 1) == '-') {
                                $thisnum = substr($thisnuma, 1, strlen($thisnuma));
                                $thisnumstr = $thisnumstr . substr($thisnuma, 1, strlen($thisnuma));
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] - $thisnum;
                                if ($thisres < 0) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 0) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 9;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 5) {
                                                if ($killfivede != "" && $killfiverls == 18) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 4;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] - 1;
                                                $y = 0;
                                            }
                                        }
                                    }
                                    $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + 10 - $thisnum;
                                }
                                $thisfuhao = '-';
                            } else {
                                $thisnum = $thisnuma;
                                $thisnumstr = $thisnumstr . $thisnuma;
                                $thisres = $jiyiarr[$i - 1][$j]['thisjieguo'] + $thisnuma;
                                if ($thisres >= 10) {
                                    for ($y = $j - 1; $y >= 0; $y--) {
                                        if ($zonghe == 1) {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        } else {
                                            if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                            } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                                if ($fullfivede != "" && $fullfiverls == 13) {
                                                    $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                                } else {
                                                    $diguicishu++;
                                                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                    exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                                }
                                            } else {
                                                $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                                $y = 0;
                                            }
                                        }
                                        if ($jiyiarr[$i][$y]['thisjieguo'] == 9) {
                                            $jiyiarr[$i][$y]['thisjieguo'] = 0;
                                        } else if ($jiyiarr[$i][$y]['thisjieguo'] == 4) {
                                            if ($fullfivede != "" && $fullfiverls == 13) {
                                                $jiyiarr[$i][$y]['thisjieguo'] = 5;
                                            } else {
                                                $diguicishu++;
                                                return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                                                exit; //这里是执行到没有值可以选择 暂定递归  有待优化

                                            }
                                        } else {
                                            $jiyiarr[$i][$y]['thisjieguo'] = $jiyiarr[$i][$y]['thisjieguo'] + 1;
                                            $y = 0;
                                        }
                                    }
                                    $thisres = substr($thisres, 1, 1);
                                }
                                $thisfuhao = '+';
                            }
                        }
                    }
                    //得到内层的记忆数组[$i][$j]里的具体内容
                    $jiyiarr[$i][$j] = array(
                        'thisnum' => $thisnum,
                        'thisnumstr' => $thisnumstr,
                        'thisfuhao' => $thisfuhao,
                        'thisjieguo' => $thisres
                    );
                }
                $thisnum = (int)$thisnumstr; //从内层出来将thisnumstr值赋给$thisnum开始算外层
                //分笔数 第一笔和剩下的笔
                if ($i == 0) {
                    $thisjieguo = $thisnum;
                    $suanshi = $thisnum;
                    $shangcisuanshi = '';
                } else {
                    if ($thisfuhao == '-') {
                        $thisjieguo = $jyarr[$i - 1]['thisjieguo'] - $thisnum;
                        $suanshi = $jyarr[$i - 1]['suanshi'] . '-' . $thisnum;
                    } else {
                        $thisjieguo = $jyarr[$i - 1]['thisjieguo'] + $thisnum;
                        $suanshi = $jyarr[$i - 1]['suanshi'] . '+' . $thisnum;
                    }
                    $shangcisuanshi = $jyarr[$i - 1]['suanshi'];
                }
                if ($thisjieguo <= 0) {
                    $diguicishu++;
                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
                $jieguolength = strlen($thisjieguo);
                //王强的预期符号
                $jiaheli = true;
                $wqyuqifuhao = '+';
                for ($u = 0; $u < $jieguolength; $u++) {
                    $wqjieguo = substr($thisjieguo, $u, 1); //获得上次结果每一位的值
                    $wqnum = substr($thisnum, $u, 1); //获得上笔每一位的值
                    $jbsfres = $this->$jibensuanfa();
                    $wqnext = $jbsfres['relation'][$wqjieguo];
                    foreach ($wqnext as $key => $value) {
                        //判断正负获取绝对值
                        if (substr($value, 0, -1) == "-") {
                            $thisfuhao2 = '-';
                            $v = substr($value, 1, strlen($value));
                        } else {
                            $thisfuhao2 = "+";
                            $v = $value;
                        }
                        //如果不是第一位时
                        if ($thisfuhao2 != $wqyuqifuhao) {
                            unset($wqnext[$key]); //判断与前一位不相等符号的去除

                        }
                        if ($wqnum == $v) {
                            unset($wqnext[$key]); //判断与前一笔数字符相等的去除

                        }
                    }
                    $wqnext = array_merge($wqnext);
                    if (empty($wqnext)) {
                        $jiaheli = false;
                    }
                }
                $jianheli = true;
                $wqyuqifuhao = '-';
                for ($u = 0; $u < $jieguolength; $u++) {
                    $wqjieguo = substr($thisjieguo, $u, 1); //获得上次结果每一位的值
                    $wqnum = substr($thisnum, $u, 1); //获得上笔每一位的值
                    $jbsfres = $this->$jibensuanfa();
                    $wqnext = $jbsfres['relation'][$wqjieguo];
                    foreach ($wqnext as $key => $value) {
                        //判断正负获取绝对值
                        if (substr($value, 0, -1) == "-") {
                            $thisfuhao2 = '-';
                            $v = substr($value, 1, strlen($value));
                        } else {
                            $thisfuhao2 = "+";
                            $v = $value;
                        }
                        //如果不是第一位时
                        if ($thisfuhao2 != $wqyuqifuhao) {
                            unset($wqnext[$key]); //判断与前一位不相等符号的去除

                        }
                        if ($wqnum == $v) {
                            unset($wqnext[$key]); //判断与前一笔数字符相等的去除

                        }
                    }
                    $wqnext = array_merge($wqnext);
                    if (empty($wqnext)) {
                        $jianheli = false;
                    }
                    if ($i < $line - 1) {
                        if ($positionarray[$i] < $positionarray[$i + 1]) {
                            $jianheli = false;
                        }
                    }
                }
                if ($i < $line - 1) {
                    $this->setlog('jiajianheli', '===+===' . $jiaheli . '===-===' . $jianheli . '===' . $thisjieguo . '===' . $thisnum . '===' . $positionarray[$i + 1] . "\r\n");
                }
                $zzheli = true;
                if ($jiaheli == true && $jianheli == true) {
                    $wqzzyuqifuhao = '';
                } else if ($jiaheli == false && $jianheli == true) {
                    $wqzzyuqifuhao = '-';
                } else if ($jiaheli == true && $jianheli == false) {
                    $wqzzyuqifuhao = '+';
                } else if ($jiaheli == false && $jianheli == false) {
                    $wqzzyuqifuhao = '';
                    $zzheli = false;
                    // $zzheli=false;
                    // $i--;
                    // $diguicishu++;
                    // return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $diguicishu);
                    // exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
                //得到外层thisjieguo和suanshi

                if ($minresult != "") {
                    if ($thisjieguo < $minresult) {
                        $diguicishu++;
                        return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                }
                if ($maxresult != "") {
                    if ($thisjieguo > $maxresult) {
                        $diguicishu++;
                        return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                }

                if ($zzheli == true) {
                    $jyarr[$i] = array(
                        'thisnum' => $thisnum,
                        'thisnumstr' => $thisnumstr,
                        'zzyuqifuhao' => $wqzzyuqifuhao,
                        'thisfuhao' => $thisfuhao,
                        'thisjieguo' => $thisjieguo,
                        'suanshi' => $suanshi
                    );
                    $waiceng = 0;
                } else {
                    $jyarr[$i] = array();
                    $jiyiarr[$i] = array();
                    if ($i > 0 && $waiceng < 20) {
                        $waiceng++;
                        $i--;
                    } else {
                        $waiceng = 0;
                        $diguicishu++;
                        return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                        exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                    }
                    $thisfuhao = '';
                    $thisnum = '';
                }
            }
            $jyarrcount = count($jyarr);

            if ($minus_num != '') {
                if (substr_count($jyarr[$jyarrcount - 1]['suanshi'], '-') != $minus_num) {
                    $diguicishu++;
                    return $this->tmcore($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化

                }
            }
            $heli = false;
            $z = count($jyarr) - 1;
            //判断是否必须出现某个值
            if (!empty($res['bixu'])) {
                foreach ($res['bixu'] as $key => $value) {
                    if (substr($value, 0, 1) == '-') {
                        $valuestr = $value;
                    } else {
                        $valuestr = '+' . $value;
                    }
                    if (strpos($jyarr[$z]['suanshi'], (string)$valuestr) !== false) {
                        $heli = true;
                    }
                }
                if ($heli == false) {
                    $diguicishu++;
                    return $this->core($detail, $bixurls, $fullfiverls, $killfiverls, $fullpositionrls, $killpositionrls, $fullpositionkillfiverls, $killpositionfullfiverls, $minresult, $maxresult, $minus_num, $zonghe, $diguicishu);
                    exit; //这里如果必须出现某个字符但是算式中不包含则暂定递归 待优化
                }
            }
        } else {
            $jyarr = '';
        }
        return $jyarr;
    }
}

3、模板调试

<html>
<head>
<title>客户例子</title>
<meta charset="utf-8" />
</head>
<body>
    <style type="text/css">
        *{margin:0px; padding:0px;}
        .wqform{width:1200px; margin:10px auto;}
        .topicdk{width:1200px; border:1px solid #ccc;}
        .topicdk p{text-align: center; font-size:1.5em;}
        .topick{width:198px; height:150px; border:1px solid #f00; padding:10px; margin:10px;float:left;}
        .topick p{text-align: center; line-height: 50px; font-size:1em;}
        .topick input{margin-left:20px;}
    </style>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script src="__STATIC__/jquery.serializejson.js"></script>
    <div class="wqform">
        <form class="myform">
        <div class="topicdk">
            <p>珠心算出题选择规则</p>
            <div class="topick">
                <p>直加直减</p>
            <input type="checkbox" name="topic[]"  value="1">+-1-4
            <input type="checkbox" name="topic[]"  value="2">+5
            <input type="checkbox" name="topic[]"  value="3">-5
            <input type="checkbox" name="topic[]"  value="4">+6
            <input type="checkbox" name="topic[]"  value="5">-6
            <input type="checkbox" name="topic[]"  value="6">+7
            <input type="checkbox" name="topic[]"  value="7">-7
            <input type="checkbox" name="topic[]"  value="8">+8
            <input type="checkbox" name="topic[]"  value="9">-8
            <input type="checkbox" name="topic[]"  value="10">+9
            <input type="checkbox" name="topic[]"  value="11">-9
            <input type="checkbox" name="topic[]" checked=""  value="12"> 1-9

            </div>

            <div class="topick">
                <p>满5加法</p>
                <input type="checkbox" name="topic[]"  value="13">+1
                <input type="checkbox" name="topic[]"  value="14">+2
                <input type="checkbox" name="topic[]"  value="15">+3
                <input type="checkbox" name="topic[]"  value="16">+4
                <input type="checkbox" name="topic[]"  value="17">+ 1-4
            </div>
            <div class="topick">
                <p>破5减法</p>
                <input type="checkbox" name="topic[]"  value="18">-1
                <input type="checkbox" name="topic[]"  value="19">-2
                <input type="checkbox" name="topic[]"  value="20">-3
                <input type="checkbox" name="topic[]"  value="21">-4
                <input type="checkbox" name="topic[]"  value="22">- 1-4
            </div>
            <div class="topick">
                <p>直减进位加法</p>
                <input type="checkbox" name="topic[]"  value="23">+1
                <input type="checkbox" name="topic[]"  value="24">+2
                <input type="checkbox" name="topic[]"  value="25">+3
                <input type="checkbox" name="topic[]"  value="26">+4
                <input type="checkbox" name="topic[]"  value="27">+5
                <input type="checkbox" name="topic[]"  value="28">+6
                <input type="checkbox" name="topic[]"  value="29">+7
                <input type="checkbox" name="topic[]"  value="30">+8
                <input type="checkbox" name="topic[]"  value="31">+9
                <input type="checkbox" name="topic[]"  value="32">+ 1-9
            </div>
            <div class="topick">
                <p>直加退位减法</p>
                <input type="checkbox" name="topic[]"  value="33">-1
                <input type="checkbox" name="topic[]"  value="34">-2
                <input type="checkbox" name="topic[]"  value="35">-3
                <input type="checkbox" name="topic[]"  value="36">-4
                <input type="checkbox" name="topic[]"  value="37">-5
                <input type="checkbox" name="topic[]"  value="38">-6
                <input type="checkbox" name="topic[]"  value="39">-7
                <input type="checkbox" name="topic[]"  value="40">-8
                <input type="checkbox" name="topic[]"  value="41">-9
                <input type="checkbox" name="topic[]"  value="42">- 1-9
            </div>
            <div class="topick">
                <p>破5进位加法</p>
                <input type="checkbox" name="topic[]"  value="43">+6
                <input type="checkbox" name="topic[]"  value="44">+7
                <input type="checkbox" name="topic[]"  value="45">+8
                <input type="checkbox" name="topic[]"  value="46">+9
                <input type="checkbox" name="topic[]"  value="47">+ 6-9

            </div>
            <div class="topick">
                <p>满5退位减法</p>

                <input type="checkbox" name="topic[]"  value="48">-6
                <input type="checkbox" name="topic[]"  value="49">-7
                <input type="checkbox" name="topic[]"  value="50">-8
                <input type="checkbox" name="topic[]"  value="51">-9
                <input type="checkbox" name="topic[]"  value="52">- 6-9
            </div>
            综合:<select name="zonghe"><option value='0'>否</option><option value='1'>是</option></select>
            小数点:<select name="xiaoshudian"><option value="0">0位</option><option value="1">1位</option><option value="2">2位</option></select>
            同码数:<select name="tongmashu"><option value="0">否</option><option value="1">是</option></select>
            千分位:<select name="qianfenwei" class="qianfenwei"><option value="0">否</option><option value="1">是</option></select>
            <div style="clear:both"></div>

        </div>
        <input type="number" placeholder="请输入减号数" name="minus_num"><br/>
        <select class="fanwei" name="maxresult">
            <option value="">---请选择结果值范围---</option>
            <option value="10">10以内</option>
            <option value="20">20以内</option>
            <option value="50">50以内</option>
            <option value="100">100以内</option>
            <option value="500">500以内</option>
            <option value="1000">1000以内</option>
        </select>
        <input type="hidden" placeholder="请输入预期最小结果值" name="minresult">
        <br/>
        <input type="number" placeholder="请输入题目组数" value="5" name="group_num">组
        <input type="number" placeholder="请输入每组题数" value="10" name="topic_num">题
        <div class="degitalk">
            <input type="number" name="degital[][line]">笔<input type="number" name="degital[][position]">位<br/>

            <button type="button" class="add">+选项</button>
        </div>
        </form>

        <button type="button" class="sub">出题</button>
        <style type="text/css">
            .suanshiitem{text-align:right; float:left; margin-left:50px; border-bottom:1px solid #000; margin-bottom:50px;}
            .clearitem{clear:both;}
        </style>
        <div class="suanshi">
        </div>
        <script>
        function qfwformat (num) {  

                //var reg=/\d{1,3}(?=(\d{3})+$)/g;  
                var reg=/\d{1,3}(?=(\d{3})+(\.|$))/g;
                return (num + '').replace(reg, '$&,');  

        }
        function isDot(num) {
            var result = (num.toString()).indexOf(".");
            if(result != -1) {
                return false;
            } else {
                return true;
            }
        } 
            $(function(){
                $(".add").click(function(){
                    var linename=''
                    $(this).before('<input type="number" name="degital[][line]">笔<input type="number" name="degital[][position]">位<br/>');
                })
                $(".sub").click(function(){
                    var subdata=JSON.stringify($(".myform").serializeJSON());
                    $(".suanshi").empty();

                    $.ajax({
                        type: "post",
                        dataType: "json",
                        url: "{:url('index/index')}",
                        data: subdata,
                        success: function (data) {
                            var data=JSON.parse(data);
                            console.log(data);
                            if(data['code']==200)
                            {
                                $(".suanshi").empty();
                                for(var i=0;i<data['data'].length;i++){
                                    for(var j=0;j<data['data'][i].length;j++)
                                    {
                                        var suanshi='';

                                        for(var z=0;z<data['data'][i][j]['suanshiarr'].length;z++)
                                        {
                                            // if($(".qianfenwei").val()==1)
                                            // {
                                            //  data['data'][i][j]['suanshiarr'][z]=qfwformat(data['data'][i][j]['suanshiarr'][z].toString());
                                            // }

                                            if(z>0)
                                            {
                                                if(data['data'][i][j]['suanshiarr'][z].toString().substr(0,1)!='-')
                                                {
                                                    data['data'][i][j]['suanshiarr'][z]='+'+data['data'][i][j]['suanshiarr'][z].toString();
                                                }
                                            }
                                            suanshi=suanshi+data['data'][i][j]['suanshiarr'][z]+'<br/>';
                                        }
                                        $(".suanshi").append('<div class="suanshiitem">'+suanshi+'</div>');
                                        //var suanshi=data['data'][i][j]['topic'];

                                        // var re = /\+/g; //定义正则表达式

                                        // var reg= new RegExp("-","g"); //定义正则表达式
                                        // suanshi=suanshi.replace(re,'<br/>+');

                                        // suanshi=suanshi.replace(reg,'<br/>-');

                                        // $(".suanshi").append('<div class="suanshiitem">'+suanshi+'</div>');
                                    }
                                    $(".suanshi").append('<div class="clearitem"></div>');
                                }
                            }
                            else{
                                alert(data['msg']);
                            }

                        }
                    })
                })
            })
        </script>
    </div>
</body>
</html>

评论

(= ̄ω ̄=)··· 暂无内容!

回复

您还未登录,请先登录或者注册