>>1
The only moment you should ever use uppercase letters in C identifiers is for types. For everything else, use underscore_separated_lowercase_words. I'm begging you, please abide by this.
...Droobs aside, ;)
Anyone wanna do a speedtest on that? It's pretty crude, Easily room to better it.... But i'm thinking it should be pretty darn fast already =)
procedure ThousandFold(xa : IntArray);
var
i : integer;
Top : integer;
begin
Top := xa[RRay];
if Top = high(xa) then
begin
writeln(#13#10'TF MAX!!');
exit;
end;
for i := Top downto 1 do
xa[i+1] := xa[i];
xa[1] := 0;
inc( xa[high(xa)] );
end;
procedure TSDivide(xa : IntArray; xb : IntArray; xc : IntArray);
const
GetRays : integer = 0;
ThouLoop : integer = 0;
var
mCount : IntArray;
VSub : IntArray;
VCount : IntArray;
TCount : IntArray;
OVC : IntArray;
OVM : IntArray;
begin
Set_(VSub, xa);
Set_(VCount, xb);
One_(mCount);
Zero_(TCount);
while isLarger(VSub,VCount) do
begin
(*
Printout(VSub);
write('VC');
Printout(VCount);
Pause_;
*)
while isLarger(VSub,VCount) do { lol, O(n^2) }
begin
Set_(OVC,VCount);
Set_(OVM,mCount);
ThousandFold(VCount);
ThousandFold(mCount);
(*
write('MC');
Printout(mCount);
write('VC');
Printout(VCount);
Pause_;
inc(GetRays);
*)
end;
Set_(VCount, OVC);
Set_(mCount, OVM);
(*dec(GetRays);*)
while isLarger(VSub,VCount) do
begin
Set_(OVC,VCount);
Set_(OVM,mCount);
Add_(VCount, VCount, VCount); { lol }
Add_(mCount, mCount, mCount); { lol }
(*
write('MC');
Printout(mCount);
write('VC');
Printout(VCount);
Pause_;
*)
end;
function isLarger(a : IntArray; b : IntArray) : boolean;
var i : integer;
begin
isLarger := true;
for i := 1 to high(a) do
begin
if i > high(b) then
exit;
if a[i] > b[i] then
exit;
end;
isLarger := false;
end;
procedure Printout(ia : IntArray);
var i : integer;
begin
for i := 1 to high(ia) do
write(ia[i], #8);
writeln;
end;
procedure Pause_;
begin
readkey;
end;
procedure Set_(dest : IntArray; src : IntArray);
var
i : integer;
begin
for i := 1 to high(dest) do
begin
if i > high(src) then
exit;
dest[i] := src[i];
end;
end;
procedure One_(dest : IntArray);
var
i : integer;
begin
for i := 1 to high(dest) do
dest[i] := 1;
end;
procedure Zero_(dest : IntArray);
var
i : integer;
begin
for i := 1 to high(dest) do
dest[i] := 0;
end;
procedure Add_(a1 : IntArray; a2 : IntArray; a3 : IntArray);
begin
{ I can't even imagine what the hell this is supposed to do. }
end;
Had to lol @ >> procedure Add... { I can't even imagine what the hell this is supposed to do. }
//----------------------------------------------
void Add(int xa[], int xb[], int xc[]){
//xa = Input1 // xb = Input2 // xc = Output
int i, iCarry=0, raymax=0;
// i = counter// iCarry = Carry the ones // raymax = Largest Element
raymax = xa[RRay];
if(xb[RRay]>raymax) raymax = xb[RRay];
//Get largest array element
xc[RRay] = raymax;
//Output will be at least that many elements
Awesome code. Great size. Looks concise. Efficient. Elegant. Keep us all posted on your continued progress with any new code factoring or compiler optimization. Show us what you got man. Wanna see how freakin' expressive, efficient, concise and elegant you can get. Thanks for the motivation.
Name:
n3n7i2011-08-18 7:33
if((i==xc[RRay])+(iCarry>=2)==2){
//Need to expand RRay ?
Does anybody know what that's called [the Division Alg(above) in some variant?]
...Its Easily kicking the binary-Step's Butt...
(Probably even Faster than the multiply [/w JumpCount ?]) alg...
Should Work Good On a (2^n Base) * n (Element) array [Larger base's Welcome /vs/ Oversize element lengths ? Can be dealt with =) quite well too i suspect..]
Name:
Anonymous2011-08-18 8:28
>>18
I do the same, I find that it is a superior way of writing code.
...Really, the main problem is that it's just too simple
Surely this can't have not been built already...
...Not that that makes it any better or worse, just -quite likely- previously discovered....
..Bit like the -Lotus- Hash alg i posted, I have no doubt NASA already has something similar[and Better].... But it's just not public.... thereby useless to most people...
While i'm on that, Should give a big shout-out to Bob Gunn, the ex-NASA man who enlightened me on the topic of Factorials, in the context of Cryptography... =)
I built Lotus myself, but none-the-less it would not have happened without him... and many others =D