03-31-2022 10:47 AM
@RobertoBozzolo you should swap only half of "duplets", not all of them. I did not test your code, but I believe it returns an untouched string...
04-01-2022 02:29 AM - edited 04-01-2022 02:47 AM
Nope: the code handles half of the string and returns the inverted string as desired (the combination of duplets and i += 2 does this). It could be furterly optimized in case of an odd number of duplets to skip the middle duplet, which is actually swapped on itself, but the final result is the expected one.
My code in effect is not so different from yours if you consider len2 <=> duplets...
04-01-2022 04:06 AM
@RobertoBozzolo It is a real shame that posts cannot be deleted on this forum. I overlooked the number of swaps your code does.
Just to get some credibility back 🤣, the case of an odd number of duplets is managed in my code by the otherwise unuseful division by four and multiplication by two, avoiding swapping a duplet with itself.
04-01-2022 07:40 AM
Aha! That's why you put it there!
The smile was not enough for me to understand it!
04-10-2022 07:12 AM
@BlueAnaconda wrote:
Hello,
I have a string like this : "ABCDEF"
I want to get this from this string : "EFCDAB".
What's the best way to do that in CVI ?
Are you sure this is about a string and not simply an integer displayed as hexadecimal number? Adding a character from outside the range A -F would have helped to avoid this ambiguity. 😉
It's definitely not a CVI specific problem but simply a standard programming algorithm question that applies to any possible programming language out there.