The question is complex, but I will explain it in detail.
The goal is to create a function that returns the next "step" of a given string.
for example
String.Step("a"); // = "b" String.Step("b"); // = "c" String.Step("g"); // = "h" String.Step("z"); // = "A" String.Step("A"); // = "B" String.Step("B"); // = "C" String.Step("G"); // = "H"
Until now, its pretty easy, but given that the input string IS can contain more than 1 character, and the function should behave as follows.
String.Step("Z"); // = "aa"; String.Step("aa"); // = "ab"; String.Step("ag"); // = "ah"; String.Step("az"); // = "aA"; String.Step("aA"); // = "aB"; String.Step("aZ"); // = "ba"; String.Step("ZZ"); // = "aaa";
etc.
This does not necessarily extend the base class String.
I tried to process it with ASCII character values, but was stuck with strings containing 2 characters.
I would really appreciate it if someone could provide the full function code.
Thanks in advance.
EDIT * I'm sorry, I forgot to mention earlier that the function "reshapes" the self-generated string when its length reaches n.
continuation of this function will be smth like this. for example n = 3 String.Step("aaa"); // = "aab"; String.Step("aaZ"); // = "aba"; String.Step("aba"); // = "abb"; String.Step("abb"); // = "abc"; String.Step("abZ"); // = "aca"; ..... String.Step("zzZ"); // = "zAa"; String.Step("zAa"); // = "zAb"; ........
I wish I had mentioned this before, after reading a few answers, I realized that the problem was in the question.
Without this, the function will always call the character "a" n times after the end of the step.
string c # char ascii
George
source share