Page 4 of 4 FirstFirst ... 234
Results 76 to 93 of 93

Thread: Project Sigma!

  1. #76
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    How are the submissions coming along? I'm interested in seeing the advanced solutions ^^
    Hup Holland Hup!

  2. #77
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    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).
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  3. #78
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Only thing I can say to this is +1 Daniel

    I will try to answer all Runescape related questions!

  4. #79
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    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.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #80
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    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
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  6. #81
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    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.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  7. #82
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    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.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  8. #83
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    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. #84
    Join Date
    Dec 2011
    Posts
    733
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    In too late >.>
    Last edited by m34tcode; 03-30-2012 at 05:18 PM.
    My scripts: LunarPlanker
    ---
    My Utilities: Cross Platform, Open Source, SPS Path Generator

    Join the Unoficial SRL Skype Group by clicking here, or visiting this thread.

  10. #85
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by m34tcode View Post
    In too late >.>
    Except he said he's delaying it 'til tomorrow/Sunday (depending on your timezone.)
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  11. #86
    Join Date
    Dec 2011
    Posts
    733
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Wasnt sure if he meant the start of the next one, or the end of this one. My function works perfect lol
    My scripts: LunarPlanker
    ---
    My Utilities: Cross Platform, Open Source, SPS Path Generator

    Join the Unoficial SRL Skype Group by clicking here, or visiting this thread.

  12. #87
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

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

  13. #88
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Dan was complaining about real life or something.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  14. #89
    Join Date
    Dec 2011
    Posts
    733
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Has school
    My scripts: LunarPlanker
    ---
    My Utilities: Cross Platform, Open Source, SPS Path Generator

    Join the Unoficial SRL Skype Group by clicking here, or visiting this thread.

  15. #90
    Join Date
    Feb 2012
    Posts
    168
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ugh, I can't figure out the syntax for loops in Lape, I had scripts 1 & 2 done otherwise :/

  16. #91
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Imagine View Post
    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
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  17. #92
    Join Date
    Feb 2012
    Posts
    168
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sex View Post
    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
    I had
    for i := 0 to 10 do
    and for some reason it was giving me an error, I'll try that then I guess

  18. #93
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

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

    Will work just fine .
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

Page 4 of 4 FirstFirst ... 234

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •