Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: A Proposition!

  1. #1
    Neanderthal Dwood's Avatar
    Join Date
    Sep 2008
    Location
    Wouldn't u like to know?
    Posts
    4,186

    A Proposition!

    If you can type the code (in C++) to change the text a person types to something cool... I will add it into halo for you. This offer is open until Wednesday. (As by then I will probably have coded my own)

    If you accept:
    Assume the variable the person typed is an unsigned char (Array) called "text" of which the number of characters it contains are unknown at the time the text array is transferred to the code you write.

    The characters you replace the original text with are to be Unicode, as that is what Halo uses. If you can do this in another language (Java, specifically), I can translate it into C++.
    Reply With Quote

  2. #2

    Re: A Proposition!

    char *translateText(char *a,int l) {char *b;a[l]=0;strcpy(b,a);int i=0,f=(l/2)%2;while(1){if(i>>1%2==1){for(int j=0;j<l;j++){if(strcmp(b+j,61)>0)b[j]++;else b[j]--;if(f)b[j]%=3;else b[j]<<=1;}}else{if(i++==l)break;l--;}}return a;}
    Last edited by Rob Oplawar; August 9th, 2009 at 12:20 PM.
    Reply With Quote

  3. #3
    chilango Con's Avatar
    Join Date
    Aug 2006
    Location
    Victoria, BC, Canada
    Posts
    8,397

    Re: A Proposition!

    Man, it looks like you just pushed random buttons on your keyboard.
    Reply With Quote

  4. #4
    io[Terry] Terry's Avatar
    Join Date
    Oct 2006
    Location
    Grenada
    Posts
    600

    Re: A Proposition!

    can't read it. needs more indenting D:
    Reply With Quote

  5. #5
    おはようございます klange's Avatar
    Join Date
    Dec 2006
    Posts
    3,028

    Re: A Proposition!

    Quote Originally Posted by Rob Oplawar View Post
    char *translateText(char *a,int l) {char *b;a[l]=0;strcpy(b,a);int i=0,f=(l/2)%2;while(1){if(i>>1%2==1){for(int j=0;j<l;j++){if(strcmp(b+j,61)>0)b[j]++;else b[j]--;if(f)b[j]%=3;else b[j]<<=1;}else{if(i++==l)break;l--;}}return a;}
    Rob, what did I tell you about putting line breaks in your code?
    Reply With Quote

  6. #6
    Senior Member
    Join Date
    Nov 2006
    Location
    Pennsylvania
    Posts
    102

    Re: A Proposition!

    Quote Originally Posted by Terry View Post
    can't read it. needs more indenting D:
    I was bored so I made Rob's code readable
    Code:
    char *translateText(char *a,int l) 
    {
        char *b;
        a[l]=0;
        strcpy(b,a);
        int i=0,f=(l/2)%2;
        while(1)
        {
            if(i>>1%2==1)
            {
                for(int j=0;j<l;j++)
                {
                    if(strcmp(b+j,61)>0)b[j]++;
                    else b[j]--;
                    if(f)b[j]%=3;
                    else b[j]<<=1;
                }
            else
            {
                if(i++==l)break;l--;
            }
        }    
        return a;
    }
    also, is it missing a close curly brace (after the first if statement), or am I going crazy?
    btw, idk C++.
    Reply With Quote

  7. #7

    Re: A Proposition!

    Quote Originally Posted by Peterljr888 View Post
    is it missing a close curly brace (after the first if statement), or am I going crazy?
    fixed
    Reply With Quote

  8. #8
    Neanderthal Dwood's Avatar
    Join Date
    Sep 2008
    Location
    Wouldn't u like to know?
    Posts
    4,186

    Re: A Proposition!

    Rob i'm not going to lie, I have no idea what your code is doing.

    Edit: Didn't your parents ever teach you to use descriptive variables? So just explain the variables and things would be clearer, pl0x.
    Reply With Quote

  9. #9

    Re: A Proposition!

    Code:
    char *translateText(char *accessor, int lastChar) {
        char *bridge;
        accessor[l]=0;
        strcpy(bridge, accessor);
        int instance = 0;
        int factory = (l/2)%2;
        while(1) {
            if(instance >> 1 % 2 == 1) {
                for(int pseudo = 0; pseudo < lastChar; pseudo++) {
                    if(strcmp(bridge + pseudo, 61) > 0)
                        bridge[pseudo]++;
                    else 
                        bridge[pseudo]--;
                    if(factory)
                        bridge[pseudo] %= 3;
                    else 
                        bridge[pseudo] <<= 1;
                }
            }
            else {
                if(instance ++ == lastChar)
                    break;
                lastChar--;
            }
        }    
        return accessor;
    }
    Last edited by Rob Oplawar; August 9th, 2009 at 07:20 PM.
    Reply With Quote

  10. #10

    Re: A Proposition!

    For those of you who still haven't figured it out, it does nothing. I hope the last post was enough to give it away.
    Reply With Quote

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •