Thread: Almost Daily Contest #2

  1. #16
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >So then we are requiring global buffers then.
    How's that? makeInteger returns an Integer, addInteger and friends take two Integers and return an Integer. toString takes an Integer and returns a string. If you want to use globals then feel free, but it can be done without them.

    >Perhaps you should dock points relative to how well you place in the higher contest.
    Excellent idea. That gives beginners incentive to enter the higher level contests. I'll do that.

    >..(hope i did not give a clue)..
    You didn't. There are several ways to solve the problem.

    >Are you sure those palimdronic numbers are in order the way you posted them?
    Quite.
    My best code is written with the delete key.

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Just so you guys know, my computer decided to die and will take up to 48 hours to fix. Feel free to keep working on entries and sending them in, most likely I'll be up and running in time to meet the deadline, but it could be another couple of days afterward before I get the results in.

    On the plus side, I'm also getting FreeBSD installed while it's being fixed. Kill two birds with one stone.
    My best code is written with the delete key.

  3. #18
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Originally posted by Prelude
    >So then we are requiring global buffers then.
    How's that? makeInteger returns an Integer, addInteger and friends take two Integers and return an Integer. toString takes an Integer and returns a string. If you want to use globals then feel free, but it can be done without them.
    pertaining to toString(), How do you propose (without memory leak) to pass back a pointer to a char buffer that you have not passed in unless it is global or static?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #19
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    crap like this is why I object to C. old programmers and their lack of thread safeness for the sake of a few clock cycles! At the risk of angering some of the board's dinosaurs, C is antiquated C++. It's a primative version of the modern language. The grotesque code that always results from it is not something I wish to work on. I'm not about to debate that topic (I'm sure some will want to), but I think I'm going to pass on this contest. Hopefully some of them wont have that requirement.

    edit: sorry people. I get worked up over that sometimes. I'll learn to control it... once the meds kick in.
    Last edited by FillYourBrain; 08-06-2003 at 11:31 AM.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #20
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Originally posted by FillYourBrain
    pertaining to toString(), How do you propose (without memory leak) to pass back a pointer to a char buffer that you have not passed in unless it is global or static?

    well how about deallocating it from the calling point...

  6. #21
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    that's quite difficult to do in this line of code, wouldn't you say?
    printf("%s\n", toString(mulInteger(a, b)));
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #22
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Originally posted by FillYourBrain
    that's quite difficult to do in this line of code, wouldn't you say?
    hmm... i agree... I was thinking about this from past one hour and posted a question about this in the C++ board...

    Hmm.. I wish OOPS was allowed.. even if she did now.. i have already submitted my programs..

  8. #23
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Can we assume that subInteger(a,b) is a - b and not b - a?

  9. #24
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Originally posted by ygfperson
    Can we assume that subInteger(a,b) is a - b and not b - a?
    and divInteger(a,b) is a/b and not b/a...
    And can i resubmit my entry.. since there is so much of time i can optimize it???

  10. #25
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How do you propose (without memory leak) to pass back a pointer to a char buffer that you have not passed in unless it is global or static?
    My example was just that, an example. Naturally I'll take dynamic memory allocation into account with my tests.

    >but I think I'm going to pass on this contest.
    That's your choice of course.

    >Can we assume that subInteger(a,b) is a - b and not b - a?
    Yes, you should assume that subInteger(a, b) is the equivalent to a - b. I'm sorry I forgot to mention that. The same goes for divInteger.

    >And can i resubmit my entry..
    Yes.

    >old programmers and their lack of thread safeness for the sake of a few clock cycles!
    Contests produce different code than the real world. For the sake of simplicity, we'll generally make a few assumptions. Anyway, before your little rant, did you consider that a future contest may be to make one of these tasks thread and exception safe? Or perhaps wrapping it in a class in the near future? I'm not just making this all up as I go, I put a lot of thought into each task.
    My best code is written with the delete key.

  11. #26
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    prelude, forgive my rant. Sometimes work conditions are reflected in my posts . Obviously I've had better days.

    Anyway, I had a hard time distinguishing between requirements and suggestions in your contest description. When you put a line of code, maybe it is example, maybe it is the actual function prototype. I don't know. That's where that came from.

    Take nothing I said personally.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  12. #27
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    If the integer should hold a value of arbitrary size and we can't use classes (including constructors and especially destructors), can we assume that the user handles all memory deallocation?
    Can we make extra functions, like one for destroying an Integer that the user can use?
    If I missed something obvious here, let me know.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  13. #28
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >can we assume that the user handles all memory deallocation?
    Yes.

    >I had a hard time distinguishing between requirements and suggestions in your contest description.
    Sorry, I'll try to be more explicit next time. Still getting a feel for contest descriptions.
    My best code is written with the delete key.

  14. #29
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    I have a question about toString, when you test that function can we be sure that your only going to be printing the return value from toString one at a time, meaning this

    printf("%s", toString(x));

    as opposed to this

    printf("%s, %s", toString(x), toString(y));

    the second one will print incorrect data if we were to implement the toString function using a global or static buffer. The ony way around that would be to return a buffer but then it wouldnt get deallocated in this case.
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  15. #30
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    ... when will the result be out.. cant wait....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Almost Daily Contest Details
    By dagdarian in forum Contests Board
    Replies: 4
    Last Post: 01-25-2005, 05:03 AM
  2. Almost Daily Contest Details
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 09-19-2004, 10:32 PM
  3. Almost Daily Contest #4
    By Prelude in forum Contests Board
    Replies: 35
    Last Post: 08-25-2003, 08:54 AM
  4. Almost Daily Contest #3
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 08-16-2003, 08:48 PM
  5. Almost Daily Contest #1
    By Prelude in forum Contests Board
    Replies: 32
    Last Post: 08-05-2003, 08:34 AM