03-03-2025 04:33 PM - edited 03-03-2025 04:47 PM
Hello Everyone,
Just looking to be pointed in the right direction, not looking for the specific answer as I am still trying to learn LV.
I'm still pretty new to using LV and was wondering if anyone could help me when it comes to converting a string into a number. What I want to do is ultimately "decode" a word and translate it into a number.
It would follow this code for the translation:
1=a, 2=b, 3=c, 4=d, 5=e, 6 =f, 7=g, 8=h, 9=i, 0=g and -1 otherwise.
Example would be the number 365 is written as cfe.
TIA!!
03-03-2025 04:37 PM
This smells like homework. What have you tried?
Once you describe what you tried and where you got stuck and show us you attempt, we'd be happy to comment.
03-03-2025 04:45 PM
Hi yes this is a homework problem! I am not looking for the answering just rather trying to figure out how to go about this. I used 2 array constants where I dragged the string and numbers into them. Then for the string input for the user I connected it to a string length then connected it quotient and remainder to see if length mod 2 ==0.
Im now planning on using a for loop with a string subset where I will connect the user string input to it. This is as far as I have gotten
03-03-2025 05:46 PM - edited 03-03-2025 06:03 PM
You have a string (word), not an array of strings as input.
You can convert your string to a byte array and use it to index into a lookup table, (or suitable map), iterating over all characters of the input.
Your problem is actually not clear, especially the "-1 otherwise". For example if the word input is zzzzz, would the result be -1-1-1-1 or just -1?
How long can the word be?
Can you explain why 7 and 0 are both "g"?
03-03-2025 07:43 PM
Assuming "0" is actually "j", here's a quick draft. See if you can figure it out.... 😄
03-03-2025 09:14 PM
My bad, you are right it would just be -1.
0 should be j, I mistyped by accident.