I am developing an APP that converts from letters to numbers, that means you have to enter a text and the app should give you back the total of those numbers, having in mind that they are alphabetically ordered. For example:
A-1
B-2
C-3
etc.
When you write down ¨sun¨ it should give you which order is the S, the U and the N alphabetically and afterwards it should show you the total sum of those 3 numbers. In this case:
S-19
U-21
N-14
And the total sum: 54
Any easy ways to have this done ? I am not sure how to sum all the numbers extracted from the letters, having in mind, that you are only inserting letters.
Make a list containing all letters. The letter A will be in the first place on the list, the letter Z in the last. So the indexes of the letters in the list will be the numbers to sum.
When you get a word, you can loop to extract each letter in sequence, then search for that letter in the list and get the letter index, then add this index to the variable.
See here, task in challenge was to create a procedure that you give it a word and it will return the sum of all of its letters according to the numbers corresponding to the letters
I am trying to follow you logic, where I need to sum all letters from the textbox (getting the number for each of the letters from the already created dictionary) and sum them in a new line. This is what I was able to do, but it is summing all the numbers I have in my dictionary and giving me 465 as output all the time. What am I missing?
Your sum procedure only reads the dictionary of all possible letter values.
How do you expect it to give you different results if you don't feed it different numbers?