Thread: Almost Daily Contest #1

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897

    Almost Daily Contest #1

    To start of my tenure as contest master, I'll test the waters with some quick contests. If everyone likes them then I'll make some more on a (hopefully) almost daily basis. I say almost daily because it's not easy coming up with something good and my time is limited.

    Please PM me with suggestions and comments so that I can adjust my methods to meet the demand.

    The Almost Daily Contest will run for a set amount of time. Anyone may participate by emailing their submission to [email protected] with the subject "Almost Daily Contest Entry". Be sure to specify which difficulty level you're solving. There's no need to sign up ahead of time.

    Almost Daily Contest #1

    Beginner:

    Write a function in C or C++:

    long double digRev ( int val )

    that takes any valid integer and reverses the digits. Your function should work for every valid int from INT_MAX to INT_MIN. Example:

    digRev ( 12345 );

    This should result in 54321. You will be graded on the following categories:

    Speed: Nice and toasty.
    Elegance: Easy on the eyes.
    Portability: It needs to run wherever I test it.


    Intermediate:

    A triangle can be formed with side lengths 4, 5, and 8. It's not possible to form a triangle with side lengths of 4, 5, and 9.

    You have eight sticks, no three of which can be used to form a triangle. Write a program to calculate the shortest possible length of the longest stick where the shortest stick is length 1.

    Correctness: Does it work right?
    Speed: Is efficient?
    Elegance: Elegant solutions are most welcome

    Hints: Triangle Inequality


    Advanced:

    Write a function in C or low level C++ (no STL):

    char findFirstNonRepeat ( char *s );

    that returns the first character that is not repeated in the string. For example, in "google", the first nonrepeated character is 'l', in "better", the first nonrepeated character is 'b'.

    You may use any number and type of helper functions and data structures, but the algorithm must have a complexity of O(n) or better. Your function will be graded on:

    Speed: Pedal to the metal
    Elegance: Nifty algorithms are always good

    Contest End: Tuesday, August 5, 2003
    Last edited by Prelude; 08-02-2003 at 12:21 PM.
    My best code is written with the delete key.

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