I want to find the lowest price i need to pay to convert text so that every
word has only upper or lower case letter.Converting 'A' into 'a' costs 1 $ and 'Z' into 'z' costs 26$.Converting 'a' into 'A' costs 26$ and 'z' into 'Z' costs 1$.There is only one space between the words in the text.
I think the program that i wrote should be working just fine but every time i get different results.
Can anyone help me with this?I have been stuck trying to find my mistakes for hour.
Thanks for the advice but still it is giving me different results every time.Like 28 after i run it again it is 14 etc. and i dont change anything in the programm
Hello World // space after last character there
Starting for loop with character 0: H
Starting while loop with character 0: H
isalpha_upper: 8 being added to sumcap
i in while loop is now 1
Starting while loop with character 1: e
not isalpha_upper: 22 being added to sumlow
i in while loop is now 2
Starting while loop with character 2: l
not isalpha_upper: 15 being added to sumlow
i in while loop is now 3
Starting while loop with character 3: l
not isalpha_upper: 15 being added to sumlow
i in while loop is now 4
Starting while loop with character 4: o
not isalpha_upper: 12 being added to sumlow
i in while loop is now 5
sumcap: 8 < sumlow 64
total is now 8
Starting for loop with character 6: W
Starting while loop with character 6: W
isalpha_upper: 23 being added to sumcap
i in while loop is now 7
Starting while loop with character 7: o
not isalpha_upper: 12 being added to sumlow
i in while loop is now 8
Starting while loop with character 8: r
not isalpha_upper: 9 being added to sumlow
i in while loop is now 9
Starting while loop with character 9: l
not isalpha_upper: 15 being added to sumlow
i in while loop is now 10
Starting while loop with character 10: d
not isalpha_upper: 23 being added to sumlow
i in while loop is now 11
sumcap: 31 < sumlow 123
total is now 39
final total is 39
That is right that is what I am expecting.But when i try with "aA zZ" it should be 2 and i get 28 or when i try with "You Are NoT Alone" i get 25 or 24 or something around 20 and it should be 32.
aA zZ
Starting for loop with character 0: a
Starting while loop with character 0: a
not isalpha_upper: 26 being added to sumlow
i in while loop is now 1
Starting while loop with character 1: A
isalpha_upper: 1 being added to sumcap
i in while loop is now 2
sumcap: 1 < sumlow: 26
total is now 1
Starting for loop with character 3: z
Starting while loop with character 3: z
not isalpha_upper: 1 being added to sumlow
i in while loop is now 4
Starting while loop with character 4: Z
isalpha_upper: 26 being added to sumcap
i in while loop is now 5
sumcap: 26 not < sumlow: 1
total is now 2
final total is 2