Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Timed 4


ghost's Avatar
0 0

Honestly I have no idea what they mean with their rules. Do they mean swap the characters, add to the ascii values, or do they mean make a new string selecting the odd characters plus the second?

Thanks,


ynori7's Avatar
Future Emperor of Earth
0 0

They gave you pseudo code. If you can't understand that then you aren't ready for this challenge.


ghost's Avatar
0 0

final += final[i]?

I understand pseudo code, but that isn't correct, unless they mean append or something, and I don't want to waste my time.


ynori7's Avatar
Future Emperor of Earth
0 0

Think of final as an empty string, and you just add characters to it in the right spot as you get to them while you trace through your scrambled string.


ghost's Avatar
0 0

The_Gman wrote: final += final[i]?

I understand pseudo code, but that isn't correct, unless they mean append or something, and I don't want to waste my time.

You code python, thats valid code for appending to a string.


Mouzi's Avatar
Member
0 0

The_Gman wrote: final += final[i]?

I understand pseudo code, but that isn't correct, unless they mean append or something, and I don't want to waste my time.

IMO you're right. There is actually an error in the pseudo code.

IF isEvenOrZero(i)
final += final[i]
ELSE
final += final[i+2]
END FOR
final += final[1]
RETURN final```
In the line where it says *final += final[i]* the final[i] would be null, because the final is a nonexistent variable at this point. It should actually say final += str[i], because str is the variable referred to on the first line. I believe str in this case refers to the string given in the challenge. Same goes for the next ones too (final[i+2] and final[1]). On the last line the final variable would still be null.

ghost's Avatar
0 0

That makes a lot more sense.. I'll post in ten minutes with [hopefully] my success :)


ghost's Avatar
0 0

wait wait, what about the last odd character? str[i+2] clearly won't work.

And we're trying to REVERSE that algorithm, correct?

something like this? (although this won't run)

code = 'x'*len(word)
code[1] = word[len(word)-1]
for i in range (len(word)):
    if (i%2 == 0):
        code[i] = word[i]
    else:
        code[i+2] = word[i]