Code: Select all
a
A
aa
aA
Aa
AA
aaa
Aaa
aAa
aaA
AAa
aAA
AaA
AAA
Code: Select all
a
aa
aaa
aaaa
A
aA
aaA
aaaA
AA
aAA
aaAA
AAA
aAAA
AAAA
...I just can't find a working logic to script it.
Please.
Code: Select all
a
A
aa
aA
Aa
AA
aaa
Aaa
aAa
aaA
AAa
aAA
AaA
AAA
Code: Select all
a
aa
aaa
aaaa
A
aA
aaA
aaaA
AA
aAA
aaAA
AAA
aAAA
AAAA
...Code: Select all
$num = 3;
$bin="2+ 4+ 8+ 16+ 32+ 64+ 128+ 256+ 512+ 1024";
$sellist= gettoken($bin, $num, "+", t, 1);
$count1= eval($sellist);
// Up to here is fine - first line is max length of string.
// $count1 = number of non repeated combinations possible.
// After was a way of creating binary numbers - not what you want.
// At this point in the past i've tried to use arrays unsuccessfully.
$count1=$count1 - 1; $lst="";
while( $count1>0){
$i= $count1;
while($i> 0){
$cvt= $i % 2;
$lst= "$lst $cvt " ;
$i= floor($i / 2);
}
$count1=$count1 - 1;
if ($count1==0){
$lst= "$lst <crlf> 0";
}
else{
$lst= "$lst <crlf>";
}
}
text $lst;Code: Select all
$num = 5;
$max = 1023;
$bin = 2;
$tk = 2;
// step;
while ($tk < $max) {
$fct = 2;
$tk = $tk * $fct;
$bin = $bin . "+ " . $tk;
}
$bin = trim($bin, "+ ");
// $bin="2+ 4+ 8+ 16+ 32+ 64+ 128+ 256+ 512+ 1024";
$sellist= gettoken($bin, $num, "+", t, 1);
$count1= eval($sellist);
// Up to here is fine - first line is max length of string.
// $count1 = number of non repeated combinations possible.
// After was a way of creating binary numbers - not what you want.
// At this point in the past i've tried to use arrays unsuccessfully.
$count1=$count1 - 1; $lst="";
while( $count1>0){
$i= $count1;
while($i> 0){
$cvt= $i % 2;
$lst= "$lst $cvt " ;
$i= floor($i / 2);
}
$count1=$count1 - 1;
if ($count1==0){
$lst= "$lst <crlf> 0";
}
else{
$lst= "$lst <crlf>";
}
}
$lst = regexreplace("$lst", "1", "A");
$lst = regexreplace("$lst", "0", "a");
$lst = regexreplace("$lst", " ", "");
text $lst;Code: Select all
set $lst;
foreach($j, "2|4|8"){
set $i;
$a = ($j<4)? "property" : "";
$b = ($j<8)? "property" : "";
while($i++ < $j){
$lst = $lst.eval($b($i/4%2)).eval($a($i/2%2)).$i%2."<crlf>";
}
}
$lst = regexreplace("$lst", "1", "A");
$lst = regexreplace("$lst", "0", "a");
text $lst;Code: Select all
set $lst;
foreach($j, "2|4|8|16"){
set $i;
$a = ($j<4)? "property" : "";
$b = ($j<8)? "property" : "";
$c = ($j<16)? "property" : "";
while($i++ < $j){
$lst = $lst.eval($c($i/8%2)).eval($b($i/4%2)).eval($a($i/2%2)).$i%2."<crlf>";
}
}
$lst = regexreplace("$lst", "1", "A");
$lst = regexreplace("$lst", "0", "a");
text $lst;Code: Select all
$length = 3;
$permutations = "";
$top_counter = 1;
while ($top_counter <= $length) {
$counter = 0;
$format = strrepeat("0", $length);
$max = bintodec(strrepeat("1", $length));
while ($counter <= $max) {
$string = format(dectobin($counter), $format);
$permutations = $permutations . $string . <crlf>;
};
};
$permutations = regexreplace($permutations, 1, A);
$permutations = regexreplace($permutations, 0, a);Code: Select all
// as Leo Cohen would say, "aaaah!, the wonders of a Load()..." :P
//============== test tool, beta:
//$tst = formatlist(<clipboard>, c, <crlf>); $otkCNT = gettoken($tst, count, <crlf>); $tst = formatlist($tst, d, <crlf>); echo "original: $otkCNT<crlf>" . "now it haves: " . gettoken($tst, count, <crlf>) . " items.";
$max = 102; // needed for reference progression table
$LalphaU = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z";
status "$max items on the go. Cya!";
$bin = 2;
$tk = 2;
while ($tk < $max) {
$fct = 2;
$tk = $tk * $fct;
$bin = $bin . "|" . $tk;
}
$re = "";
$reX = "";
$bin = trim($bin, "|");
$tt = gettoken($bin, count, "|");
$a1 = <<<#
set $lst;
foreach($j, "$bin"){
set $i;
#;
$a3 = ' while($i++ < $j){' . "<crlf>";
foreach($tk1, "$bin", "|") {
if($tk == "") { step; break; }
else { }
$tk = $tk1 * 2; // lazy fix
$tst = gettoken($bin, -1, "|");
$tst2 = strpos("$bin", "$tk");
if($tst2 == "-1") { break; }
else { }
$op++;
$reX = '.eval($' . gettoken($LalphaU, $op, "|") . '($i/' . "$tk1" . '%2))' . "$reX";
$z = ' $' . gettoken($LalphaU, $op, "|") . " = ($j<" . "$tk" . ")? " . quote("property") . " : " . quote("") . ";";
$re = "$re" . "$z" . "<crlf>";
}
$a2 = "$re" . "<crlf>";
$a4 = ' $' . 'lst = $' . lst . "$reX" . '.$' . 'i' . '%' . '2.' . quote('<crlf>') . ';';
$a5 = "<crlf> }" . "<crlf> }" . "<crlf>" . ' $' . 'lst = regexreplace("$' . 'lst", ' . quote("1") . ', ' . quote("A") . ');' . "<crlf>";
$a6 = ' $' . 'lst = regexreplace("$' . 'lst", ' . quote("0") . ', ' . quote("a") . ');' . "<crlf>";
$a7 = "<crlf>" . ' status "done!"; text ' . quote("$" . 'cnt items:<crlf 2>$' . 'tst') . ";" . ' status "";';
$a7c = "<crlf>" . ' $' . 'tst = gettoken($' . 'lst, $' . 'max, <crlf>, , 1);';
$a7d = "<crlf>" . ' $' . 'cnt = gettoken($' . 'tst, count, <crlf>);';
$a7A = "<crlf>" . ' $' . 'max = ' . "$max" . ';';
$a8 = "$a1" . "$a2" . "$a3" . "$a4" . "$a5" . "$a6" . "$a7A" . "$a7c" . "$a7d" . "$a7";
wait 1000;
if($max <= "1023") {
status "Please wait..."; wait 1000;
}
else { beep 800,100; status "Please wait, this WILL take a time!", "FF0000", "alert"; }
load $a8, , s;
these should be enough for this case:SkyFrontier wrote:Once I played with bin 2 dec 2 bin and I recall one of them was error-prone. If someone has such a code, I'd like to ask for a release.
Code: Select all
//lite conversion: unsigned, no fractions, no funny business
FUNCTION dectobin($d){ set $b; while ($d != 0){$b = ($d%2).$b; $d = floor($d/2);} return $b; }
FUNCTION bintodec($b){ $l=strlen($b); $i=0; while ($i < $l){$d=$d + (2^($l-$i-1))*substr($b,$i,1); $i++;} return $d; }