Challenge Code 1: Reverse Text

I'm not sure exactly how or what I should ask for here but, I do know that I've tried many different ways of using strlen(string s) along with substr(string s, var1, var2) and a while loop but, i have not been able to get this one to output correctly.

I know it would output correctly IF the substr() method was able to take int variables with arguments. For example:

substr(string, var1, var1+1);

I do not wish to place too much code here. I don't want to get in trouble for giving other players a way of 'cheating' around figuring things out. I'd be happy to copy and paste the different variations of my script but, only if I can get an OKAY from an administrator/moderator.


Thanks in advance,
Draconis

Cheating

I'm not a moderator, but I do know that some people post full challenge solutions for free on their in-game websites. I yelled at bleh7777 the day I signed up because he was taking the fun out of the challenges. :P You could either check his site for answers, or I imagine you could post more code here. This is one of the earliest challenges too, so I don't expect it'd be that bad. The other idea is to ask for help in the Help chat channel in-game because then your posted code wouldn't persist. Personally, I find the exploration of what's possible and what isn't to be half the fun, whether limitations in the language or bugs or anything are involved. You can use setOutputString(string) to output debug messages while building your script then just comment them out for your final submission. You can try challenges as many times as you like.

Did you actually name your variable "string"?.

From Wartt Hog

Reply to Wartt

No, I don't name it "string". ;) I'm n00b but, not that n00b lol. :P I just used it in the example as a general string variable to note the fact that I am at least putting the correct type of variable there.

As my previous post said, I am confused when the substr(string, inta, intb) method doesn't allow any kind of modifications to the arguments. Logically speaking I should be able to do something like replace intb with intb+1 shouldn't I? I am just really confused. This is difficult when I know most of the basics of C/C++ and revert to a VERY limited scripting language. In C++ I could've just used a C-string, flopped it and called it good but, not here. I must agree with you though: "...I find the exploration of what's possible and what isn't to be half the fun..."


Thanks,
Draconis
n/a

That works fine, here's a

That works fine, here's a snippet from my reverseString code: .....substr(instr,index,index+1)....
n/a

I'm not sure how you're going

I'm not sure how you're going about it, but if it's compiling and saying that your output was blank, try substr(s, len - 1, len); instead of the other substr you had been using. If it's not compiling at all, that means there's a syntax error preventing it from compiling at all (I think. Sometimes there are syntax errors where it can still compile and I think it tells you when that happens. Don't quote me on that though) and if it tells you what one of the functions does, you're using the given function incorrectly.

OH SNAP!

string str = getInputString();
string out = "";
int len = strlen(str);
int i = 0;
while(i < len){
out = out + substr(str,len-i-1,len-i);
i = i+1;
}
setOutputString(out);

Come visit BlehCo at 2.718.2.818 for free challenge answers!

Bleh7777

*growls*

From Wartt Hog