06-26-2017 09:45 AM
This is the problem I am working on:
Develop a VI to encode or decode words using a secret code. To encode a word in this code, first separate the word into two substrings – one with the first half of the original word, and one containing the second half. If there is an odd number of letters in the word, then split it so that the first substring has one more letter than the second one.
Create the encoded word by concatenating the first half of the word onto the end of the second half of the word, inserting the second letter of the original word in between these two halves. For example, the word “gravity” would be encoded as “ityrgrav” and the word “master” would be encoded as “teramas.”
Place a string control on the front panel and a Boolean switch allowing the user to select whether the input is to be decoded or encoded. Display the output on a string indicator.
I am stuck on a problem I was given. I specifically am having trouble with dividing the words unevenly. For some reason the way I went about it causes a mix up that does not give me the correct output as requested. Any help would be appreciated!
06-26-2017 09:50 AM - edited 06-26-2017 09:53 AM
@Momoko3 wrote:
For some reason the way I went about it causes a mix up that does not give me the correct output as requested.
We cannot tell what you are doing wrong unless you show us what you are doing (attach a simplified VI). Also, what should happen if the word has e.g. only one letter?
06-26-2017 09:51 AM
Hi momoko,
this is a nice example task for learning LabVIEW! (Do you know this?)
You should use the functions StringLength, StringSubset and ConcatenateStrings to solve that task…
06-26-2017 09:56 AM
A useful tools that could be used to solve the division problem is quotient&remainder.
06-26-2017 10:05 AM
Perhaps you should show us your code so we can figure out what you are doing wrong.
Momoko3 wrote: I specifically am having trouble with dividing the words unevenly.
Get the string length and divide by 2. Then use the Round To +Infinity. This at least works for the encoding.
Fun little exercise. I recommend learning the Search/Split String and the String Subset functions.
06-26-2017 10:18 AM
@crossrulz wrote:
Get the string length and divide by 2. Then use the Round To +Infinity. This at least works for the encoding.
Uee quotient&remainder to divide by two and add the two outputs. Keeps it all blue. No need to go orange!
06-25-2018 08:33 PM
Did you ever get a solution? Im still really stuck.