| 1 | <?php\r |
| 2 | $start = 0;\r |
| 3 | $stop = 9999;\r |
| 4 | $length = 4;\r |
| 5 | \r |
| 6 | $rada = "";\r |
| 7 | $notfoundlast = -3;\r |
| 8 | $error = 1;\r |
| 9 | \r |
| 10 | while($error) {\r |
| 11 | \r |
| 12 | for($i=$start;$i<=$stop;$i++) {\r |
| 13 | //$i = base_convert($i, 10, 2);\r |
| 14 | if(strpos($rada, $i) == 0) {\r |
| 15 | $rada = "$rada"."$i";\r |
| 16 | //echo($i);\r |
| 17 | }\r |
| 18 | }\r |
| 19 | \r |
| 20 | for($i=0;$i<(strlen($rada)-$length);$i++) {\r |
| 21 | $sub = substr($rada, $i, $length);\r |
| 22 | for($x=0;$x<$length;$x++) {\r |
| 23 | $rada[($i+$x)] = "R";\r |
| 24 | \r |
| 25 | }\r |
| 26 | $rada = str_replace($sub, "", $rada);\r |
| 27 | \r |
| 28 | $replace="";\r |
| 29 | for($x=0;$x<$length;$x++) {\r |
| 30 | $replace = $replace."R";\r |
| 31 | }\r |
| 32 | \r |
| 33 | $rada = str_replace($replace, $sub, $rada);\r |
| 34 | }\r |
| 35 | \r |
| 36 | //echo($rada);\r |
| 37 | \r |
| 38 | //Test\r |
| 39 | //echo("\n\n");\r |
| 40 | $error = 0;\r |
| 41 | $notfound = 0;\r |
| 42 | for($i=$start;$i<=$stop;$i++) {\r |
| 43 | if(!eregi($i, $rada)) {\r |
| 44 | //echo("Not found: $i\n");\r |
| 45 | $rada = $rada.$i;\r |
| 46 | $error = 1;\r |
| 47 | $notfound++;\r |
| 48 | }\r |
| 49 | }\r |
| 50 | echo("Not found total: $notfound\n");\r |
| 51 | if($notfoundlast == $notfound) { $error = 0; }\r |
| 52 | $notfoundlast = $notfound;\r |
| 53 | }\r |
| 54 | \r |
| 55 | for($i=$start;$i<=$stop;$i++) {\r |
| 56 | if(!eregi($i, $rada)) {\r |
| 57 | $rada = $rada.$i;\r |
| 58 | }\r |
| 59 | }\r |
| 60 | \r |
| 61 | echo("\n\n".$rada);\r |
| 62 | //system("pause");\r |