1. How are the submissions coming along? I'm interested in seeing the advanced solutions ^^

2. Originally Posted by nielsie95
How are the submissions coming along? I'm interested in seeing the advanced solutions ^^
No advanced solutions thus far But mixster is working on one, and has said even if he doesn't complete it by the date, he will still share with us

I only have solutions for the intermediate challenge (several).

3. Only thing I can say to this is +1 Daniel

4. Originally Posted by Daniel
No advanced solutions thus far But mixster is working on one, and has said even if he doesn't complete it by the date, he will still share with us

I only have solutions for the intermediate challenge (several).
Easy is <4 lines, Intermediate is <10 lines, Advanced is some several hundred lines. Really, you need to tone it down a bit or tone it up a bit.

5. Hey guys,

Really sorry! This has to be postponed for about a day due to excessive schoolwork I have to complete. So, unfortunately, you all get an extra day to submit your things

6. Pfft, he's taking forever like a little female dog.

Simba Code:
program BigNumLibrary;type  BigNumBase = LongWord;const  HIGHBIT = High(BigNumBase) xor (High(BigNumBase) shr 1);  HIGHBITS = High(BigNumBase);function IntToBinary(value: Integer): string;  function BoolToInt(value: Boolean): Integer;  begin    if (value) then      Result := 1    else      Result := 0;  end;begin  if (value = 0) then    Result := ''  else    Result := IntToBinary(value shr 1) + IntToStr(BoolToInt(value and 1 = 1));end;type  PBigNumPart = ^BigNumPart;  BigNumPart = record    data: BigNumBase;    next: PBigNumPart;  end;  BigNum = record    root: PBigNumPart;    sign: Boolean; // false = neg; true = pos  end;function BigNumNew(value: Integer): BigNum;begin  New(Result.root);  Result.root^.next := nil;  Result.sign := value >= 0;  Result.root^.data := value;end;function BigNumCopyPart(part: BigNumPart): PBigNumPart;begin  New(Result);  Result^.data := part.data;  Result^.next := nil;end;function BigNumCopy(value: BigNum): BigNum;var  part, position: PBigNumPart;begin  Result.root := nil;  Result.sign := value.sign;  if (value.root = nil) then Exit;  part := value.root;  Result.root := BigNumCopyPart(part^);  position := Result.root;  while (part^.next <> nil) do  begin    position^.next := BigNumCopyPart(part^);    position := position^.next;    part := part^.next;  end;end;procedure BigNumDispose(var value: BigNum);var  partN, partC: PBigNumPart;begin  partC := value.root;  while (partC <> nil) do  begin    partN := partC^.next;    Dispose(partC);    partC := partN;  end;  value.root := nil;  value.sign := True;end;function BigNumAdd(a, b: BigNum): BigNum; forward;function BigNumInvert(value: BigNum): BigNum;var  partN, partR: PBigNumPart;  bigTemp, bigOne: BigNum;begin  bigTemp.sign := not value.sign;  partN := value.root;  if (partN = nil) then    partR := nil  else    partR := BigNumCopyPart(partN^);  bigTemp.root := partR;  while (partN <> nil) do  begin    partR^.data := partR^.data xor HIGHBITS;    partR^.next := BigNumCopyPart(partN^);    partR := partR^.next;    partN := partN^.next;  end;  partR^.data := partR^.data xor HIGHBITS;  Writeln(IntToBinary(value.root^.data));  Writeln(IntToBinary(partR^.data));  bigOne := BigNumNew(1);  Result := BigNumAdd(bigTemp, bigOne);  BigNumDispose(bigTemp);  BigNumDispose(bigOne);end;function BigNumGreaterThan(a, b: BigNum): Integer;  function BigNumPartGreaterThan(a, b: PBigNumPart): Integer;  var    ta, tb: BigNumBase;  begin    if (a = nil) xor (b = nil) then    begin      if (a = nil) then        Exit(-1)      else        Exit(1);    end;    if (a = nil) then      Exit(0);    Result := BigNumPartGreaterThan(a^.next, b^.next);    if (Result = 0) then    begin      ta := a^.data;      tb := b^.data;      repeat        if ((ta xor tb) and HIGHBIT) = HIGHBIT then        begin          if (ta and HIGHBIT) = HIGHBIT then            Exit(1)          else            Exit(-1);        end;        ta := ta shl 1;        tb := tb shl 1;      until((ta = 0) and (tb = 0));      Exit(0);    end;  end;var  ta, tb: BigNum;begin  if (a.sign) then    ta := BigNumCopy(a)  else    ta := BigNumInvert(a);  if (b.sign) then    tb := BigNumCopy(b)  else    tb := BigNumInvert(b);  Result := BigNumPartGreaterThan(ta.root, tb.root);  BigNumDispose(ta);  BigNumDispose(tb);end;function BigNumAdd(a, b: BigNum): BigNum;  function AddPart(a, b: BigNumPart; out c: Boolean): PBigNumPart;  begin    New(Result);    Result^.data := a.data + b.data;    c := Result^.data < a.data;    Result^.next := nil;  end;var  carry, carryNext: Boolean;  partA, partB, partR, temp, partOne: PBigNumPart;begin  partA := a.root;  partB := b.root;  New(partOne);  partOne^.data := 1;  if (partA = nil) then    Exit(BigNumCopy(b))  else if (partB = nil) then    Exit(BigNumCopy(a));  partR := AddPart(partA^, partB^, carryNext);  Result.root := partR;  partA := partA^.next;  partB := partB^.next;  while ((partA <> nil) and (partB <> nil)) do  begin    carry := carry or carryNext;    temp := AddPart(partA^, partB^, carry);    if (carry) then      temp := AddPart(partA^, partOne^, carry)    else      temp := BigNumCopyPart(partA^);    partR^.next := AddPart(temp^, partB^, carryNext);    Dispose(temp);    partR := partR^.next;    partA := partA^.next;    partB := partB^.next;  end;  if (partA = nil) then    partA := partB;  carryNext := carry or carryNext;  while (partA <> nil) do  begin    if (carryNext) then      partR^.next := AddPart(partA^, partOne^, carryNext)    else      partR^.next := BigNumCopyPart(partA^);    partR := partR^.next;    partA := partA^.next;  end;  if (a.sign = b.sign) then    Result.sign := a.sign  else  begin    if (BigNumGreaterThan(a, b) <> -1) then      Result.sign := a.sign    else      Result.sign := b.sign;  end;  if (carryNext and (a.sign = b.sign)) then  begin    partR^.next := partOne;    if (not Result.sign) then    begin      if ((partR^.data and HIGHBIT) <> HIGHBIT) then        partOne^.data := (partOne^.data xor HIGHBITS)      else      begin        Dispose(partOne);        partR^.next := nil;      end;    end;  end  else    Dispose(partOne);end;function BigNumToBinary(value: BigNum): string;var  partC: PBigNumPart;begin  partC := value.root;  Result := '';  while (partC <> nil) do  begin    Result := PadL(IntToBinary(partC^.data), 32, '0') + Result;    partC := partC^.next;  end;end;

I can't even remember how well addition works, but I'm pretty sure it nearly works perfectly (I think negative + negative is the failing point that I was working on.) It's also so awesome that it's 32/64bit independent and you can alter its base type to Byte or stuff to make it more fine-grained in its memory usage (though, really, if you care about 3 bytes of memory, you suck.)

Anyone doing this using arrays of booleans should just admit how awesome I am as well, since this method uses integer addition to speed up its processing like a boss. It also has little overhead when expanding or contracting how many longwords it uses since it's linked list based rather than array based, so it's really just all round awesome for a BigNum intense program rather than a silly one that just wants to store some number that's slightly too big for an Int64.

Before I forget, I showed this to a female and she bedded me so quickly I barely had time to get my Promise bracelet off. Just saying, chicks dig epic code.

7. Sorry, school work has really picked up this week due to the upcoming holidays. And also when you try out a different OS setup

Might as well further postpone it to this Saturday again, so the timings don't all get screwed up.

8. Originally Posted by Daniel
Sorry, school work has really picked up this week due to the upcoming holidays. And also when you try out a different OS setup

Might as well further postpone it to this Saturday again, so the timings don't all get screwed up.
If you would like a hand judging the results (obvs I can't judge the intermediate one this time) but I am happy to help out.. PM me if you want

9. In too late >.>
Last edited by m34tcode; 03-30-2012 at 05:18 PM.

10. Originally Posted by m34tcode
In too late >.>
Except he said he's delaying it 'til tomorrow/Sunday (depending on your timezone.)

11. Wasnt sure if he meant the start of the next one, or the end of this one. My function works perfect lol

12. I'm just wondering what is happening with this...

13. Dan was complaining about real life or something.

14. Has school

15. SRL Junior Member
Join Date
Feb 2012
Posts
168
Mentioned
0 Post(s)
Quoted
0 Post(s)
Ugh, I can't figure out the syntax for loops in Lape, I had scripts 1 & 2 done otherwise :/

16. Originally Posted by Imagine
Ugh, I can't figure out the syntax for loops in Lape, I had scripts 1 & 2 done otherwise :/
Lol dude, the syntax for loops is exactly the same as PascalScript, however there is also support for the with keyword..

Simba Code:
var  i : integer;begin  for i := 0 to 10 with 2 do    writeln(i);end.
=> 0, 2, 4, 6, 8, 10

17. SRL Junior Member
Join Date
Feb 2012
Posts
168
Mentioned
0 Post(s)
Quoted
0 Post(s)
Originally Posted by Sex
Lol dude, the syntax for loops is exactly the same as PascalScript, however there is also support for the with keyword..

Simba Code:
var  i : integer;begin  for i := 0 to 10 with 2 do    writeln(i);end.
=> 0, 2, 4, 6, 8, 10
for i := 0 to 10 do
and for some reason it was giving me an error, I'll try that then I guess

18. Simba Code:
for i := 0 to 10 do  writeln(i);

Will work just fine .