Contest Sign-Up Thread: Rewrite Mid() from VB

This is a discussion on Contest Sign-Up Thread: Rewrite Mid() from VB within the Contests Board forums, part of the Community Boards category; Your goal is to rewrite the Mid function found in Visual Basic. You can find information on this function here: ...

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

    Contest Sign-Up Thread: Rewrite Mid() from VB

    Your goal is to rewrite the Mid function found in Visual Basic. You can find information on this function here: http://msdn.microsoft.com/library/de...l/refctMid.asp
    Before you go thinking this is a simple task... I assure you it's not. It shouldn't take you too long to code, but it's a real brain buster.

    Your Mid() implementation must satisfy the following syntatic forms:
    std::string mystring = Mid(someotherstring, 2, 5);
    Mid(mystring, 2, 5) = someotherstring;
    Mid(mystring, 0, 3) = Mid(someotherstring, 2, 3); // Very tricky

    This contest is C++ only (you can't do it in C! (OOPs, there's a hint))The contest will be Run from now until March 7th (that's like 10 days). If you have any questions, or if you'd like to be a judge or a contestant please reply to this thread.

    Entries will be sumitted to my email address: ebrooks@hfx.eastlink.ca before 12:00AM (your time) March 7th.

    Judges - 3
    Eibro
    Sang-Drax
    golfinguy4
    [1 Slot free, please apply]

    Contestants - 10
    Polymorphic OOP
    Travis Dane
    *ClownPimp*
    MadHatter
    Vasanth
    Sebastiani
    Captain Penguin
    jverkoey
    Codeplug
    DavT
    Last edited by Eibro; 03-10-2003 at 11:50 AM.

  2. #2
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    i'm confused... what does it return to make:
    Mid(mystring, 2, 5) = someotherstring; //and
    Mid(mystring, 0, 3) = Mid(someotherstring, 2, 3); // Very tricky
    possible? or is that part of the challange..? ah.. i may do it. don't sign me up yet though...

    >This contest is C++ only(you can't do it in C! (OOPs, there's a hint))
    i get it.. but.. eh.. sure.. oh well.
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    i guess i'll be a contestant...
    C Code. C Code Run. Run Code Run... Please!

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

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Sounds easy, Count me in.

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    i'm confused... what does it return to make:
    Mid(mystring, 2, 5) = someotherstring; //and
    Mid(mystring, 0, 3) = Mid(someotherstring, 2, 3); // Very tricky
    possible? or is that part of the challange..?
    Try returning a reference.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640

    Re: Contest Sign-Up Thread: Rewrite Mid() from VB

    Originally posted by Eibro

    Mid(mystring, 0, 3) = Mid(someotherstring, 2, 3); // Very tricky
    What exactly is ment with this? Say i pass in some arguments
    and the the function returns something and we end up with this

    Code:
     "abc" = "def";
    What is this suppose to mean?

  7. #7
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    I'm sorry, I can't answer that.

  8. #8
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >I'm sorry, I can't answer that.

    just a little hint? i'll be yer friend ...

    seriously though.. i fail to see how this function would work as an L-value. it seems like it would be like doing something like:
    Code:
    std::string x = "abcdefg";
    std::string y = "tuvwxyz";
    x = Mid(x, 3);   //note the uselessness of this line
    x = Mid(y, 3);   //makes the previous line useless
    obviously this isn't how it should be. or maybe it is... bah.. i dunno.
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  9. #9
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Does this help?

    std::string hello = "Hello";
    std::string world = "World";

    Mid(hello, 0, 2) = Mid(world, 0, 2);
    std::cout << hello; // Should print "Wollo";

  10. #10
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >Does this help?

    very much. thank you. i still don't know how to do it, but atleast now i know what i'm trying to do...
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  11. #11
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719
    Mid is a simple function to implement in C++. If it's speed that the contest is based on then someone could just use C++ .NET and link that to an MASM function. (cause I doubt inline ASM would work very well with VC6.0)

  12. #12
    Evil Sock Puppet MadHatter's Avatar
    Join Date
    Nov 2002
    Posts
    176
    >Mid is a simple function to implement in C++

    to make one such as
    std::string mystring = Mid(somestring, 5, 3);
    would be easy. but
    Mid(somestring, 5, 3) = mystring;
    wouldn't be as easy... unless i'm missing something obvious.. which i don't think i am...
    If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?

  13. #13
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    What is this being judged on. Speed? Elegance? Efficiency?

  14. #14
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Add me in

  15. #15
    Eibro@School
    Guest
    Originally posted by Polymorphic OOP
    What is this being judged on. Speed? Elegance? Efficiency?
    All of the above + Portability + Fidelity
    I'll get the exact scheme layed out when I get home.
    If you're wondering, you can go look what ygfperson used for the contests he ran... I don't think i'll stray too far from that.

Page 1 of 5 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ANN: The Fourth Contest: Alarm Clock, sign up here
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 59
    Last Post: 08-10-2002, 01:24 AM
  2. Sign Up!: The Third Round, both contests
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 54
    Last Post: 07-20-2002, 06:46 PM
  3. Sign Up -- The Next Contest
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 06-26-2002, 07:09 PM
  4. Sign up -- Contest Thread
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 70
    Last Post: 05-27-2002, 07:46 PM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 02:53 PM

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