5 $places = strlen($stop);
6 $tryes = 50; //Tryes to find better
12 /////////////////////////////////////////////////////////////////
14 function rada_add($name, $istr) { //Funkce pro pridani do rady -> !!! OPTIMALIZOVAT !!! <-
15 if(!eregi($istr, $GLOBALS[$name])) {
16 if( $istr[0] == $GLOBALS[$name][strlen($GLOBALS[$name])-1] ) {
17 $istr = substr($istr, 1);
18 $GLOBALS[$name] = $GLOBALS[$name].$istr;
19 } elseif( $GLOBALS[$name][0] == $istr[strlen($istr)-1] ) {
20 $GLOBALS[$name] = substr($GLOBALS[$name], 1);
21 $GLOBALS[$name] = $istr.$GLOBALS[$name];
24 //Nahodne na zacetek nebo konec
26 $GLOBALS[$name] = $istr.$GLOBALS[$name];
28 $GLOBALS[$name] = $GLOBALS[$name].$istr;
33 //$GLOBALS[$name]=$GLOBALS[$name].$istr; //Debug
37 function rada_unique($name) { //Funkce pro vyhledani a smazani duplikatu (i potrebnych)
38 $length = $GLOBALS["places"];
41 for($i=0;$i<(strlen($GLOBALS[$name])-$length);$i++
) {
43 $sub = substr($GLOBALS[$name], $i, $length);
44 for($x=0;$x<$length;$x++
) {
45 $GLOBALS[$name][($i+
$x)] = $replacer;
48 $GLOBALS[$name] = str_replace($sub, "", $GLOBALS[$name]); //Smaze duplikaty
51 for($x=0;$x<$length;$x++
) {
52 $replace = $replace.$replacer;
55 $GLOBALS[$name] = str_replace($replace, $sub, $GLOBALS[$name]);
61 function add_zeroes($num, $places) { //Zarovna cislo na $places mist pridanim nul na zacatek
63 for($i=0;$i<$places;$i++
) {
66 //$num = base_convert($num, 10, $base); //BASE CONVERT -> !!! NOT WORKS YET !!! <-
68 $str = substr($str, strlen($str)-$places);
72 ///CODE///////////////////////////////////////////
74 //die(add_zeroes(23, 5));
75 //////////////////////////////////////////////////
78 while($next) { //MAIN LOOP
81 $rada = ""; //Vytvorime prazdnou radu
82 for($i=$start;$i<=$stop;$i++
) { //Pridame vsechna n-cisli
83 $istr = add_zeroes($i, $places);
84 rada_add("rada", $istr);
90 for($i=$start;$i<=$stop;$i++
) {
91 $istr = add_zeroes($i, $places);
92 if(!eregi($istr, $rada)) {
94 //echo("Not found: $i\n");
99 echo("Total not found: $notfound\n"); //Debug
102 if($notfound <= $minnotfound ||
!isset($minnotfound)) {
103 echo("-minnf: $notfound\n"); //Debug
104 $minnotfound = $notfound;
110 if($notfound <= $minnotfound ||
$notfound == 0) $next = false;
115 for($i=$start;$i<=$stop;$i++
) { //Pridame vsechna zbyla n-cisli
116 $istr = add_zeroes($i, $places);
117 rada_add("rada", $istr);
120 /////////OUTPUT///////////////////////////////////
122 echo("Length: ".strlen($rada)." chars\n");
123 echo("Total not found: $notfound\n");
This page took 0.31467 seconds and 4 git commands to generate.