February 25th contest results

This is a discussion on February 25th contest results within the Contests Board forums, part of the Community Boards category; I simply can't find time to judge this entry-- sorry. However, we do have one judge (Sang-Drax) that did. Seeing ...

  1. #1
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    February 25th contest results

    I simply can't find time to judge this entry-- sorry. However, we do have one judge (Sang-Drax) that did. Seeing how there were only 5 contestants, I don't see this being a major problem.

    Here it is:


    Throughout the entries, I missed the support for "const std::string" and the prevention of 'evil' or pointless code.

    const string s = "12345";
    cout << Mid(s,1,2);
    Mid("12345",1,2) = "abc";

    Here are the results:

    ===================
    =Sebastian McKelvy=
    ===================

    Fidelity 0/10
    --------
    Basic test incorrect : 234
    First test incorrect : 123
    Second test incorrect : 123
    Third test incorrect : abc

    I also had to comment away these lines in my test code:
    //s2 = Mid("0123456789",1,4);
    //Mid(s1, 1, 1) = Mid(s4,1);

    Efficiency 0/10
    ----------

    The code is very short, but doesn't do much right

    Elegance 1/5
    --------

    No commenting
    The solution is not very elegant.


    Portability 5/5
    -----------

    No problems


    -== TOTAL: 6 ==-











    ==================
    =Travis Dane=
    ==================


    Fidelity 1/10
    --------

    Didn't provide a function, which was required.
    Didn't understand what Mid()=Mid() should do.

    Basic functionality doesn't work, the program outputs "hel " instead
    of "hel"

    He has an operator= though.


    Efficiency 2/10
    ----------

    Short and simple code, but lacking functionality.


    Elegance 2/5
    --------

    Nice commenting
    Not very good solution with the (non-static) function inside the class

    Portability 4.5/5
    -----------

    He used conio.h, but only in the main() function.



    -== TOTAL: 9.5 ==-















    ==============
    =Dorian Boyce=
    ==============


    Fidelity 7/10
    --------

    Doesn't work with C-strings:
    s2 = Mid("0123456789",1,4);

    Unable to handle constant strings


    Efficiency 8/10
    ----------

    Could've used member functions instead of for-loops in the = operator No member initialization list Manual copying of the string in operator= instead of non-reference argument


    Elegance 2/5
    --------

    Constructor is public
    No private copy-constructor (to prevent use outside the Mid() function) No commenting

    Good solution

    Portability 5/5
    -----------

    No problems

    -== TOTAL: 23 ==-












    ===============
    = CodePlug =
    ===============


    Fidelity 8/10
    --------

    Compiled and succeeded all tests (on MS VC++.NET only -- see
    portability) Great!

    No support for const std::string though
    Evil code did compile.

    Efficiency 10/10
    ----------

    Very short code!


    Elegance 3/5
    --------

    Well commented!
    C-style pointer casts
    Global variables
    Constructor is public (btw, why didn't he call the class Mid to get rid of the redundant functions?)


    Portability 3/5
    -----------

    Code is not standard -- problem with reference class members when copying Doesn't compile with CodeWarrior Doesn't compile with Comeau C++ -- The absolutely best compiler when it comes to standard compliance. http://www.comeaucomputing.com/tryitout/


    -== TOTAL: 24 ==-












    ======
    =DavT=
    ======

    Fidelity 8/10
    --------

    Compiled and succeeded all tests (on MS VC++.NET only -- see
    portability) Great!

    No support for const std::string though
    Evil code did compile.

    Efficiency 9/10
    ----------

    Short code!

    Elegance 4/5
    --------

    Well commented!
    C-style pointer casts (unnecessary, too)


    Portability 3/5
    -----------

    Code is not standard -- problem with reference class members when copying Doesn't compile with CodeWarrior Doesn't compile with Comeau C++ -- The absolutely best compiler when it comes to standard compliance. http://www.comeaucomputing.com/tryitout/


    -== TOTAL: 24 ==-
    It's a tie! DavT and CodePlug are the winners. I'll attach the entries, as well as mine and Sang-Drax's attempt at the contest.

    Note: There will be a speed coding contest tommorow. Details to come.
    Attached Files Attached Files
    Last edited by Sang-drax; 10-24-2007 at 10:50 PM. Reason: Fixed my own quote

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Hmmm. Seeing as this was a C++ only contest, i dont think it was very fair to test C-style strings. For the other stuff, I was just being lazy :/

    Anyways, congrats to the winners... i guess. (damnit i never win )
    C Code. C Code Run. Run Code Run... Please!

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

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    wheres the test code?
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    I believe this is what Sang-Drax was using:
    Originally posted by Sang-drax
    You can try your functions using this test program.
    It tests various syntactic constructions and the resulting strings.
    Code:
    int main()
    {
        using namespace std;
          
        bool correct = true;
        string s1,s2;  
      
        //Basic test
        s2 = "0123456789";
        string s3 = Mid(s2,1,4);
        s1 = Mid(s2,1,4);
        s2 = Mid("0123456789",1,4);
        if (s1 != "1234" or s2 != "1234" or s3 != "1234")
            cout << "Basic test incorrect : " << s1, correct=false;
        
        
        //First test
        s1 = "abcdefg";
        Mid(s1, 3, 0) = "123";
        if (s1 != "abc123defg")
            cout << "First test incorrect : " << s1, correct=false;
            
            
        //Second test
        s1 = "abcdefg";
        s2 = "123";
        Mid(s1, 3, s2.size()) = s2;
        if (s1 != "abc123g")
            cout << "Second test incorrect : " << s1, correct=false;
    
        //Third test
        s1 = "abc";
        s2 = "123";
        Mid(s1, 1, 1) = Mid(s2,1);
        if (s1 != "a23c")
            cout << "Third test incorrect : " << s1, correct=false;    
        
        if (correct)
            cout << "All tests correct!";
    }

  5. #5
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    That version of my code is an early version. I modified it later to prevent the code discussed in the other thread, which I still believe shouldn't compile.

    Good work DavT and CodePlug! I liked the inheritance-solution.
    Last edited by Sang-drax; 03-26-2003 at 04:20 PM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #6
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by *ClownPimp*
    Hmmm. Seeing as this was a C++ only contest, i dont think it was very fair to test C-style strings.
    IMO, it was.
    String constants in source code are still const char*, not std::string.
    String functions must consider that string constants may be passed as arguments.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Contest Results - Snake Numbers
    By pianorain in forum Contests Board
    Replies: 4
    Last Post: 06-22-2006, 10:14 AM
  2. May Monthly Contest Results
    By PJYelton in forum Contests Board
    Replies: 28
    Last Post: 05-27-2005, 02:43 AM
  3. Results of March Monthly Contest
    By PJYelton in forum Contests Board
    Replies: 23
    Last Post: 04-17-2005, 10:46 AM
  4. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  5. Results for *easy* contest:
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-27-2002, 12:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21