PDA

View Full Version : A Proposition!



Dwood
August 8th, 2009, 09:34 PM
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++.

Rob Oplawar
August 8th, 2009, 11:48 PM
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;}

Con
August 9th, 2009, 01:10 AM
Man, it looks like you just pushed random buttons on your keyboard.

Terry
August 9th, 2009, 01:28 AM
can't read it. needs more indenting D:

klange
August 9th, 2009, 01:32 AM
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?

Peterljr888
August 9th, 2009, 01:53 AM
can't read it. needs more indenting D:
I was bored so I made Rob's code readable :-3

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++. :saddowns:

Rob Oplawar
August 9th, 2009, 01:20 PM
is it missing a close curly brace (after the first if statement), or am I going crazy?
fixed

Dwood
August 9th, 2009, 02:59 PM
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.

Rob Oplawar
August 9th, 2009, 06:02 PM
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;
}

Rob Oplawar
August 11th, 2009, 06:12 PM
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.

Limited
August 11th, 2009, 06:15 PM
It doesnt copy bridge back to accessor does it? :O

El Lobo
August 12th, 2009, 12:41 AM
No thanks, only interested in risky propositions.

:lobo: