Thread: Almost Daily Contest #1

  1. #16
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    i submmited the first and the third.. but did not understand the 2nd question..

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Could you re-explain the intermediate problem?
    You have 8 sticks of any length (though you can assume that the shortest sticks possible are 1. A triangle cannot be made with any three of these 8 sticks if the length of the third is greater than or equal to the sum of the first two. Find the shortest possible length of the longest stick out of all 8.
    My best code is written with the delete key.

  3. #18
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    could you give an example please.. it is still confusing.. i dont get it.. the question


    edited
    --------

    and what ever the question menas.. it is better you also give the function prototype......
    Last edited by vasanth; 08-03-2003 at 10:48 AM.

  4. #19
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >could you give an example please..
    I'm afraid I can't do that. Any example would tell you what the solution is, that's why I didn't give one to begin with.

    >it is better you also give the function prototype......
    Whatever you want is fine, but if you need a function definition:
    Code:
    int stickLen(int n); /* Variant number of sticks */
    
    or
    
    int stickLen(void); /* Hard code the number of sticks */
    My best code is written with the delete key.

  5. #20
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    hmmm... not even matched? I wonder why. I couldn't think of anything faster. But then I did only spend 5 minutes on it. Oh well. First contest anyway.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #21
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >hmmm... not even matched? I wonder why. I couldn't think of anything faster.
    I used a sneaky optimization, you'll see when I post the results. I'll include my test functions. Your mileage may vary though depending on the profiler, compiler, and settings you use.
    My best code is written with the delete key.

  7. #22
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    is inline assembler allowed?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  8. #23
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Having a complexity of O(n) would mean that it only loops through the entire string once, right?

    If so, darn. What I was thinking of would have to loop twice.

  9. #24
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    No, it can loop over it twice and still be O(N). Remember that the coefficients are taken off.

  10. #25
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    -KEN-, your algorithm is no doubt the same as mine which is O(n) even though it steps through 2 times. Prelude apparently has an optimization on that or a single loop method ( I couldn't come up with one ).
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  11. #26
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Mine's pretty efficient... I hope. I loop through once and then through a list of the possible characters. It can never go up to 2n, but it has to be at least n.

    Meh... I'll work on the other two.

  12. #27
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    well I guess we're giving too much of our algorithms away, so we should probably shut up about that.

    I want to just say thanks to Prelude for taking over the contest master role. I haven't done this before but it looks like it should be a lot of fun.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  13. #28
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Question on the beginner:

    for the prototype, I assume you mean just a 'long' and not a 'long double'?

  14. #29
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    long double because the reversed number might overflow an int or a long
    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
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Hmm... too bad I submitted mine with just a long.

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 #2
    By Prelude in forum Contests Board
    Replies: 37
    Last Post: 08-09-2003, 10:51 PM