开篇语:好久没写博客了,其中有项目是关于彩票的(彩票可以娱乐,这东西不能沉迷,计划软件仅仅是辅助,没有推荐算法是必中的,倍投风险很大,长久玩,赢只是过程,输是最终结果)
做号:
function combination($a, $m)
{
$r = array();
$n = count($a);
if ($m <= 0 || $m > $n) {
return $r;
}
for ($i = 0; $i < $n; $i++) {
$t = array($a[$i]);
if ($m == 1) {
$r[] = $t;
} else {
$b = array_slice($a, $i + 1);
$c = combination($b, $m - 1);
foreach ($c as $v) {
$r[] = array_merge($t, $v);
}
}
}
return $r;
}
function zero_bu($num)
{
if (strlen($num) < 2) {
return '0' . $num;
} else {
return $num;
}
}
function array_newcp($arr)
{
$new_arr = array();
foreach ($arr as $value) {
//var_dump($value);
$str = '';
foreach ($value as $value2) {
$str .= zero_bu($value2) . ',';
}
$str = rtrim($str, ',');
$new_arr[] = $str;
}
return $new_arr;
}
function array_cp_reduce($a1, $new_r1, $num)
{
$new_r2 = array();
foreach ($new_r1 as $key => $value) {
$temp_n = 0;
foreach ($a1 as $key2 => $value2) {
if(strpos($value, zero_bu($value2)) !== false)
{
$temp_n++;
}
}
if($num==$temp_n)
{
$new_r2[] = $value;
}
}
$new_r1 = array_unique($new_r2);
return $new_r1;
}
function calc_dm($dm_data,$dm_cx,$r_new)
{
$new_r11 = array();
$new_r22 = array();
$new_r33 = array();
$new_r44 = array();
$new_r55 = array();
$new_r66 = array();
$a1 = $dm_data;
foreach ($dm_cx as $myvalue) {
if ($myvalue == 0) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$flag = false;
foreach ($a1 as $value2) {
if (strpos($value0, zero_bu($value2)) !== false) {
$flag = true;
break;
}
}
if (!$flag) {
$new_r2[] = $value0;
}
}
$new_r11 = $new_r2;
}
if ($myvalue == 1) {
$new_r1 = array();
$new_r1 = array_cp_reduce($a1,$r_new, 1);
$new_r22 = $new_r1;
}
if ($myvalue == 2) {
$new_r1 = array();
$new_r1 = array_cp_reduce($a1,$r_new, 2);
$new_r33 = $new_r1;
}
if ($myvalue == 3) {
$new_r1 = array();
$new_r1 = array_cp_reduce($a1,$r_new, 3);
$new_r44 = $new_r1;
}
if ($myvalue == 4) {
$new_r1 = array();
$new_r1 = array_cp_reduce($a1,$r_new, 4);
$new_r55 = $new_r1;
}
if ($myvalue == 5) {
$new_r1 = array();
$new_r1 = array_cp_reduce($a1,$r_new, 5);
$new_r66 = $new_r1;
}
}
$new_r_all01 = array();
return array_unique(array_merge($new_r11, $new_r22, $new_r33, $new_r44, $new_r55, $new_r66));
}
public function zuohao()
{
$a = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
$r = combination($a, 5);
$r_new = array_newcp($r);
$post_data = I('post.');
//胆一
if ($post_data['dan1'] && $post_data['dan1cx']) {
$new_r_all01 = calc_dm($post_data['dan1'], $post_data['dan1cx'], $r_new);
}
//胆二
if ($post_data['dan2'] && $post_data['dan2cx']) {
$new_r_all01 = calc_dm($post_data['dan2'], $post_data['dan2cx'], $r_new);
}
//胆三
if ($post_data['dan3'] && $post_data['dan3cx']) {
$new_r_all01 = calc_dm($post_data['dan3'], $post_data['dan3cx'], $r_new);
}
//胆四
if ($post_data['dan4'] && $post_data['dan4cx']) {
$new_r_all01 = calc_dm($post_data['dan4'], $post_data['dan4cx'], $r_new);
}
//胆五
if ($post_data['dan5'] && $post_data['dan5cx']) {
$new_r_all01 = calc_dm($post_data['dan5'], $post_data['dan5cx'], $r_new);
}
$even_arr = I('post.even');
//处理偶数()
if ($even_arr) {
$new_r11 = array();
$new_r22 = array();
$new_r33 = array();
$new_r44 = array();
$new_r55 = array();
$new_r66 = array();
if ($new_r_all01) {
$r_new = $new_r_all01;
} else {
$r_new = $r_new;
}
foreach ($even_arr as $value) {
if ($value == 0) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 0) {
$new_r2[] = $value0;
}
}
$new_r11 = ($new_r2);
}
if ($value == 1) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 1) {
$new_r2[] = $value0;
}
}
$new_r22 = ($new_r2);
}
if ($value == 2) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 2) {
$new_r2[] = $value0;
}
}
$new_r33 = ($new_r2);
}
if ($value == 3) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 3) {
$new_r2[] = $value0;
}
}
$new_r44 = ($new_r2);
}
if ($value == 4) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 4) {
$new_r2[] = $value0;
}
}
$new_r55 = ($new_r2);
}
if ($value == 5) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 % 2 == 0) {
$even_num++;
}
}
if ($even_num == 5) {
$new_r2[] = $value0;
}
}
$new_r66 = ($new_r2);
}
}
$new_r_all01 = array();
$new_r_all = array_merge($new_r11, $new_r22, $new_r33, $new_r44, $new_r55, $new_r66);
$new_r_all01 = array_unique($new_r_all);
}
//处理合数
$composite = $_POST['composite'];
if ($composite) {
$new_r11 = array();
$new_r22 = array();
$new_r33 = array();
$new_r44 = array();
$new_r55 = array();
$new_r66 = array();
if ($new_r_all01) {
$r_new = $new_r_all01;
} else {
$r_new = $r_new;
}
foreach ($composite as $value) {
if ($value == 0) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 0) {
$new_r2[] = $value0;
}
}
$new_r11 = ($new_r2);
}
if ($value == 1) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 1) {
$new_r2[] = $value0;
}
}
$new_r22 = ($new_r2);
}
if ($value == 2) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 2) {
$new_r2[] = $value0;
}
}
$new_r33 = ($new_r2);
}
if ($value == 3) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 3) {
$new_r2[] = $value0;
}
}
$new_r44 = ($new_r2);
}
if ($value == 4) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 4) {
$new_r2[] = $value0;
}
}
$new_r55 = ($new_r2);
}
if ($value == 5) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 == 4 || $value2 == 6 || $value2 == 8 || $value2 == 9 || $value2 == 10) {
$even_num++;
}
}
if ($even_num == 5) {
$new_r2[] = $value0;
}
}
$new_r66 = ($new_r2);
}
}
$new_r_all01 = array();
$new_r_all = array_merge($new_r11, $new_r22, $new_r33, $new_r44, $new_r55, $new_r66);
$new_r_all01 = array_unique($new_r_all);
}
//处理小数 <=5
$small_arr = $_POST['small'];
if ($small_arr) {
$new_r11 = array();
$new_r22 = array();
$new_r33 = array();
$new_r44 = array();
$new_r55 = array();
$new_r66 = array();
if ($new_r_all01) {
$r_new = $new_r_all01;
} else {
$r_new = $r_new;
}
foreach ($small_arr as $value) {
if ($value == 0) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 0) {
$new_r2[] = $value0;
}
}
$new_r11 = ($new_r2);
}
if ($value == 1) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 1) {
$new_r2[] = $value0;
}
}
$new_r22 = ($new_r2);
}
if ($value == 2) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 2) {
$new_r2[] = $value0;
}
}
$new_r33 = ($new_r2);
}
if ($value == 3) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 3) {
$new_r2[] = $value0;
}
}
$new_r44 = ($new_r2);
}
if ($value == 4) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 4) {
$new_r2[] = $value0;
}
}
$new_r55 = ($new_r2);
}
if ($value == 5) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $value2) {
if ($value2 <= 5) {
$even_num++;
}
}
if ($even_num == 5) {
$new_r2[] = $value0;
}
}
$new_r66 = ($new_r2);
}
}
$new_r_all01 = array();
$new_r_all = array_merge($new_r11, $new_r22, $new_r33, $new_r44, $new_r55, $new_r66);
$new_r_all01 = array_unique($new_r_all);
}
//处理连号 相邻两数相减绝对值为1
$lianhao_arr = $_POST['lianhao'];
if ($lianhao_arr) {
$new_r11 = array();
$new_r22 = array();
$new_r33 = array();
$new_r44 = array();
$new_r55 = array();
$new_r66 = array();
if ($new_r_all01) {
$r_new = $new_r_all01;
} else {
$r_new = $r_new;
}
foreach ($lianhao_arr as $value) {
if ($value == 0) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 0) {
$new_r2[] = $value0;
}
}
$new_r11 = ($new_r2);
}
if ($value == 1) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 1) {
$new_r2[] = $value0;
}
}
$new_r22 = ($new_r2);
}
if ($value == 2) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 2) {
$new_r2[] = $value0;
}
}
$new_r33 = ($new_r2);
}
if ($value == 3) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 3) {
$new_r2[] = $value0;
}
}
$new_r44 = ($new_r2);
}
if ($value == 4) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 4) {
$new_r2[] = $value0;
}
}
$new_r55 = ($new_r2);
}
if ($value == 5) {
$new_r2 = array();
foreach ($r_new as $key => $value0) {
$r_new_temp = explode(',', $value0);
$flag = false;
$even_num = 0;
foreach ($r_new_temp as $key => $value2) { //5个数 0-4
if ($key >= 1) {
$lianhao_z = abs($r_new_temp[$key] - $r_new_temp[$key - 1]);
if ($lianhao_z == 1) {
$even_num++;
}
}
}
if ($even_num == 5) {
$new_r2[] = $value0;
}
}
$new_r66 = ($new_r2);
}
}
$new_r_all01 = array();
$new_r_all = array_merge($new_r11, $new_r22, $new_r33, $new_r44, $new_r55, $new_r66);
$new_r_all01 = array_unique($new_r_all);
}
if (!$new_r_all01) {
$new_r_all01 = $r_new;
}
$new_r_all02 = '';
$new_r_all01 = array_unique($new_r_all01);
sort($new_r_all01);
//处理数组输出
foreach ($new_r_all01 as $key => $value) {
$nvalue = ltrim($value, ',');
$nvalue = str_replace(',', ' ', $nvalue);
$new_r_all02 .= $nvalue . "\r\n";
}
$return_msg = array('info' => count($new_r_all01), 'data' => $new_r_all02, 'status' => 0);
echo json_encode($return_msg);
die;
}
遗漏:
$inp_data = $g['list'];
$keyword_arr = explode("\r\n", $inp_data);
foreach ($keyword_arr as $key => $value) {
$keyword_arrn[] = str_replace(' ', ',', $value);
}
$data = array_reverse($data);
foreach ($data as $key => $value) {
$nn = explode(',', ($value['num']));
$nn_arr = array();
foreach ($nn as $key1 => $value1) {
$nn_arr[] = $value1;
}
sort($nn_arr);
$str = '';
foreach ($nn_arr as $key3 => $value3) {
$str .= $value3.',';
}
$str = rtrim($str,',');
$flag = false;
$false_num = 0;
foreach ($keyword_arrn as $key5 => $value5) {
if($value5==$str)
{
$flag = true;
break;
}else
{
$flag = false;
}
}
if($flag)
{
$false_num=0;
}else
{
$false_num++;
}
$n_arr['zj'] = $flag;
$n_arr['qi'] = $value['qi'];
$n_arr['false'] = $false_num;
$new_arr[] = $n_arr;
}
$lian_cuo = 0;
$temp_j = array();
foreach ($new_arr as $key => $value) {
if($new_arr[$key]['false']!=$new_arr[$key-1]['false'] && !$new_arr[$key]['false'])
{
if($new_arr[$key-1])
{
$temp_j[] = $new_arr[$key-1];
}
}
if(!$new_arr[$key]['false'])
{
$temp_j[] = $new_arr[$key];
}
//old
// if($value['false'])
// {
// $qi .= $value['qi'].',';
// $false .= $value['false'].',';
// }else
// {
// $qi .= $value['qi'].',';
// $false .= $value['false'].',';
// }
//先找到交接点
// if($key>0 )
// {
// if($new_arr[$key]['false']+$new_arr[$key-1]['false']==1)
// {
// $value['id'] = $key;
// $temp_j[] = $temp = $value;
// }
// if($new_arr[$key]['false']+$new_arr[$key+1]['false']==1)
// {
// if($temp['qi']==$value['qi'])
// {
// }else
// {
// $value['id'] = $key;
// $temp_j[] = $value;
// }
// }
// }
}
foreach ($temp_j as $key => $value) {
if($key==0)
{
$temp_j[0]['show_q'] = $this->riqi_handle($temp_j[0]['qi'],$new_arr[0]['qi'], $g['c_id'])+1;
}
if($key==(count($temp_j)-1)){
$temp_j[$key]['show_q'] = $this->riqi_handle($temp_j[$key]['qi'], $temp_j[$key-1]['qi'], $g['c_id']) ;
if( $new_arr[count($new_arr)-1]['qi'] - $temp_j[$key]['qi']>=1)
{
$temp_j[$key+1] = $new_arr[count($new_arr)-1];
$temp_j[$key+1]['show_q'] = $this->riqi_handle($new_arr[count($new_arr)-1]['qi'],$temp_j[$key]['qi'], $g['c_id']);
}
break;
}
if($key>0)
{
$temp_j[$key]['show_q'] = $this->riqi_handle($temp_j[$key]['qi'],$temp_j[$key-1]['qi'], $g['c_id']);
}
}
if(!$temp_j)
{
$new_arr_t = $new_arr[count($new_arr)-1];
$new_arr_t['show_q'] = count($new_arr);
$temp_j[] = $new_arr_t;
}
$yl_arr = array();
foreach ($temp_j as $key => $value) {
if($value['false'])
{
$qi .= substr($value['qi'], 3).',';
$false .= $value['show_q'].',';
$sum_yi += $value['show_q'];
$yl_arr[] = $value['show_q'];
}else
{
$qi .= substr($value['qi'], 3).',';
$false .= $value['false'].',';
}
}