#!/usr/bin/php = 1); $res = $sed; for ($p=2; $p<=$n; $p++) $res = sed_mul($res, $sed); return $res; } function sed_is_immortal($sed, $power) { $sedpow = sed_int_power($sed, $power); for ($i=0; $i<16; $i++) { $x1 = bcabs($sed[$i]); $x2 = bcabs($sedpow[$i]); if (substr($x2, -strlen($x1)) != $x1) return false; } return $sedpow; } function _go($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, &$progr, &$found) { $sed = [$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p]; $sedpower = sed_is_immortal($sed, $power); if ($sedpower !== false) { $a_ = $sedpower[0]; $b_ = $sedpower[1]; $c_ = $sedpower[2]; $d_ = $sedpower[3]; $e_ = $sedpower[4]; $f_ = $sedpower[5]; $g_ = $sedpower[6]; $h_ = $sedpower[7]; $i_ = $sedpower[8]; $j_ = $sedpower[9]; $k_ = $sedpower[10]; $l_ = $sedpower[11]; $m_ = $sedpower[12]; $n_ = $sedpower[13]; $o_ = $sedpower[14]; $p_ = $sedpower[15]; if (($i!=0) || ($j!=0) || ($k!=0) || ($l!=0) || ($m!=0) || ($n!=0) || ($o!=0) || ($p!=0)) { $str = "SED "; } else if (($e!=0) || ($f!=0) || ($g!=0) || ($h!=0)) { $str = "OCT "; } else if (($c!=0) || ($d!=0)) { $str = "QUAD "; } else if ($b!=0) { $str = "CPLX "; } else { $str = "REAL "; } $str .= "| Distance=$distance | "; $str .= "[$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p] ^ $power = [$a_, $b_, $c_, $d_, $e_, $f_, $g_, $h_, $i_, $j_, $k_, $l_, $m_, $n_, $o_, $p_]"; # if (!in_array($str,$found)) { # echo "$str\n"; # $found[] = $str; file_put_contents('/tmp/daniel_immortal_sedenions', "$str\n", FILE_APPEND); $found++; # } } #if ($progr++ % 10000 == 0) { # echo "(Dist=$distance) Processing ($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p) with power $power \r"; #} } if (file_exists(__DIR__.'/savestate.txt')) { $start_distance = trim(file_get_contents(__DIR__.'/savestate.txt')); } else { $start_distance = 0; } for ($distance=$start_distance; $distance<=MAX_DISTANCE; $distance++) { $str = "--------- Distance: $distance ---------"; echo " \r"; echo "$str\n"; $found = 0; $progr = 0; if (file_exists("/tmp/daniel_immortal_sedenions")) system("rm /tmp/daniel_immortal_sedenions"); $a = $distance; for ($b=0; $b<=$distance; $b++) { for ($c=0; $c<=$distance; $c++) { for ($d=0; $d<=$distance; $d++) { for ($e=0; $e<=$distance; $e++) { for ($f=0; $f<=$distance; $f++) { for ($g=0; $g<=$distance; $g++) { for ($h=0; $h<=$distance; $h++) { for ($i=0; $i<=$distance; $i++) { for ($j=0; $j<=$distance; $j++) { for ($k=0; $k<=$distance; $k++) { for ($l=0; $l<=$distance; $l++) { for ($m=0; $m<=$distance; $m++) { for ($n=0; $n<=$distance; $n++) { for ($o=0; $o<=$distance; $o++) { for ($p=0; $p<=$distance; $p++) { if ($p == 0) echo "\r".round(memory_get_usage()/1024/1024, 2)." MiB ($found found); ($a), $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p "; for ($power=2; $power<=MAX_POWER; $power++) { _go($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $a, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $a, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $a, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $a, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $a, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $a, $h, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $a, $i, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $a, $j, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $a, $k, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $a, $l, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $a, $m, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $a, $n, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $a, $o, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $a, $p, $power, $distance, $progr, $found); _go($b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $a, $power, $distance, $progr, $found); } } } } } } } } } } } } } } } } # file_put_contents(__DIR__.'/result.txt', "$str\n", FILE_APPEND); # chdir(__DIR__); # system("cat /tmp/daniel_immortal_sedenions | sort | uniq >> result.txt"); # system("rm /tmp/daniel_immortal_sedenions"); system("mv /tmp/daniel_immortal_sedenions result_distance{$distance}_maxpower".MAX_POWER.".txt"); system("sort -us -o result_distance{$distance}_maxpower".MAX_POWER."_unique.txt result_distance{$distance}_maxpower".MAX_POWER.".txt"); file_put_contents(__DIR__.'/savestate.txt', $distance+1); }