fork download
  1. <?php
  2.  
  3. //
  4.  
  5. function palpitex002($rant)
  6.  
  7.  
  8. {
  9. $fibo=[1,2,3,5,8,13,21];
  10.  
  11.  
  12. $primo=[2,3,5,7,11,13,17,19,23];
  13.  
  14.  
  15.  
  16. $par=[4,6,10,12,14,16,18,20,22,24];
  17.  
  18.  
  19. $impar=[9,15,21,25];
  20.  
  21.  
  22.  
  23. $m3=[3,6,9,12,15,18,21,24];
  24. $m4=[4,8,12,16,20,24];
  25. $m5=[5,10,15,20,25];
  26. $m6=[6,12,18,24];
  27. $m7=[7,14,21];
  28. $m8=[8,16,24];
  29.  
  30. $col1=[1,6,11,16,21];
  31. $col2=[2,7,12,17,22];
  32. $col3=[3,8,13,18,23];
  33. $col4=[4,9,14,19,24];
  34. $col5=[5,10,15,20,25];
  35.  
  36. $lin1=[1,2,3,4,5];
  37. $lin2=[6,7,8,9,10];
  38. $lin3=[11,12,13,14,15];
  39. $lin4=[16,17,18,19,20];
  40. $lin5=[21,22,23,24,25];
  41.  
  42. $dezgold1=[3,8,10,11,13,17,13,20,21];
  43.  
  44. $novo=true;
  45. $itera=0;
  46. while ($novo == true)
  47. {
  48. $palpitex=array();
  49.  
  50. $ndez=0;
  51. $vai=true;
  52. while ($vai == true)
  53. {
  54. $p1=rand(1,25);
  55. if (in_array($p1, $palpitex)) continue;
  56. array_push($palpitex,$p1);
  57.  
  58. $ndez++;
  59. if ($ndez == 15) $vai=false;
  60. }
  61.  
  62.  
  63. foreach ($palpitex as $v)
  64. {
  65. echo "-".$v."-";
  66. }
  67.  
  68. $nant=0;
  69. $npar=0;
  70. $nimpar=0;
  71. $nprimo=0;
  72. $nfibo=0;
  73. $ncol1=0;
  74. $ncol2=0;
  75. $ncol3=0;
  76. $ncol4=0;
  77. $ncol5=0;
  78. $nlin1=0;
  79. $nlin2=0;
  80. $nlin3=0;
  81. $nlin4=0;
  82. $nlin5=0;
  83. $ndezgold1=0;
  84. foreach($palpitex as $v)
  85. {
  86. if (($v % 2) == 0) $npar++; else $nimpar++;
  87. if (in_array($v, $rant)) $nant++;
  88. if (in_array($v, $primo)) $nprimo++;
  89. if (in_array($v, $fibo)) $nfibo++;
  90.  
  91. if (in_array($v, $col1)) $ncol1++;
  92. if (in_array($v, $col2)) $ncol2++;
  93. if (in_array($v, $col3)) $ncol3++;
  94. if (in_array($v, $col4)) $ncol4++;
  95. if (in_array($v, $col5)) $ncol5++;
  96. if (in_array($v, $lin1)) $nlin1++;
  97. if (in_array($v, $lin2)) $nlin2++;
  98. if (in_array($v, $lin3)) $nlin3++;
  99. if (in_array($v, $lin4)) $nlin4++;
  100. if (in_array($v, $lin5)) $nlin5++;
  101.  
  102. if (in_array($v, $dezgold1)) $ndezgold1++;
  103.  
  104. }
  105.  
  106. $soma=array_sum($palpitex);
  107. $snlinhas=$nlin1*$nlin2*$nlin3*$nlin4*$nlin5;
  108. $sncols=$ncol1*$ncol2*$ncol3*$ncol4*$ncol5;
  109. $colcheia= ($ncol1%5==0)
  110. or ($ncol2%5==0)
  111. or ($ncol3%5==0)
  112. or ($ncol4%5==0)
  113. or ($ncol5%5==0);
  114. //sort($palpitex);
  115. $posit=($palpitex[0] < 4)
  116. and ($palpitex[1]<7)
  117. and ($palpitex[2]<9)
  118. and ($palpitex[3]<11)
  119. and ($palpitex[4]<12)
  120. and ($palpitex[5]<14)
  121. and ($palpitex[6]>7
  122. and $palpitex[6]<16)
  123. and ($palpitex[7]>8
  124. and $palpitex[7]<17)
  125. and ($palpitex[8]>10)
  126. and ($palpitex[8]<19)
  127. and ($palpitex[9]>11)
  128. and ($palpitex[9]<20)
  129. and ($palpitex[10]>14)
  130. and ($palpitex[11]>16)
  131. and ($palpitex[12]>18)
  132. and ($palpitex[13]>20)
  133. and ($palpitex[14]>22);
  134. $ndigit=0;
  135. $somadigit=0;
  136. foreach ($palpitex as $v)
  137. {
  138. if ($v <= 9) $ndigit++; else $ndigit+=2;
  139. $intv=intdiv($v,10);
  140. $decv=$v - $intv * 10;
  141. $somadigit=$somadigit+$intv+$decv;
  142. }
  143.  
  144. $m3=0;
  145. $m4=0;
  146. $m5=0;
  147. $m6=0;
  148. $m7=0;
  149. $m8=0;
  150.  
  151. foreach ($palpitex as $v)
  152. {
  153. if ($v % 3 == 0) $m3++;
  154. if ($v % 4 == 0) $m4++;
  155. if ($v % 5 == 0) $m5++;
  156. if ($v % 6 == 0) $m6++;
  157. if ($v % 7 == 0) $m7++;
  158. if ($v % 8 == 0) $m8++;
  159. }
  160. $serv=true;
  161. $serve=($nprimo >= 4);
  162. $serve=$serve and ($nprimo <= 8);
  163. $serve=$serve and ($nfibo >=2);
  164. $serve=$serve and ($nfibo <= 6);
  165. $serve=$serve and ($soma >=161);
  166. $serve=$serve and ($soma <= 227);
  167. $serve=$serve and ($snlinhas <> 0);
  168. $serve=$serve and ($sncols <> 0);
  169. $serve=$serve and ( $colcheia == false );
  170. $serve=$serve and ( $npar >=5);
  171. $serve=$serve and ($npar <= 9);
  172. $serve=$serve and ( $nimpar >=6);
  173. $serve=$serve and ($nimpar <= 10);
  174. $serve=$serve and ( $nant >= 7);
  175. $serve=$serve and ($nant <= 11 );
  176. //$serve=$serve and ($posit == true);
  177. $serve=$serve and ($ndigit >= 22);
  178. $serve=$serve and ($ndigit <= 27);
  179. $serve=$serve and ($somadigit >= 63);
  180. $serve=$serve and ($somadigit <= 87);
  181. $serve=$serve and ($m3>3);
  182. $serve=$serve and ($m3 <8);
  183. $serve=$serve and ($m4>1);
  184. $serve=$serve and ($m4 <6);
  185. $serve=$serve and ($m5>0);
  186. $serve=$serve and ($m5 <5);
  187. $serve=$serve and ($m6>0);
  188. $serve=$serve and ($m6 <4);
  189. $serve=$serve and ($m7>0);
  190. $serve=$serve and ($m7 <4);
  191. $serve=$serve and ($m8>0);
  192. $serve=$serve and ($m8 <4);
  193. $serve=$serve and ($ndezgold1 >= 4);
  194.  
  195. if ($serve==true)
  196. {
  197. echo $serve;
  198. $novo=false;
  199. }
  200. $itera++;
  201. }
  202. echo "(".$itera.")";
  203. return $palpitex;
  204. }
  205. // r1639
  206. $r=palpitex002([1,3,5,6,7,8,9,10,11,14,15,19,20,22,25]);
  207. sort($r);
  208. foreach ($r as $v)
  209. {
  210. echo "-".$v."-";
  211. }
Success #stdin #stdout 0.02s 23720KB
stdin
Standard input is empty
stdout
-7--9--1--12--22--16--10--17--3--5--23--18--14--15--25-1(1)-1--3--5--7--9--10--12--14--15--16--17--18--22--23--25-