Hello
Suppose this is a string : “123A3212” [var str string = “123A3212”]
but i want to add consecutive digits elements of string (i.e 1+2 and 2+3… ) ignoring the alphabets and print the sum of digit of each pair.
Help Me With This
Hello
Suppose this is a string : “123A3212” [var str string = “123A3212”]
but i want to add consecutive digits elements of string (i.e 1+2 and 2+3… ) ignoring the alphabets and print the sum of digit of each pair.
Help Me With This
As this really sounds like a homework assignment, could you please tell us first what you have tried so far and what you are struggling with now?
You have not answered my question, please show us what you have tried so far. We won’t give you a pre made solution…
Hi,
Don’t have time to code now, but I would try to do something like this. Just skip the first character of the string and then do your calculation. It would give something like :
“123A3212”
“23A3212”
And now it seems that if you consider the columns and the nature of the character (digit or letter), you can just add easily term by term the elements of the columns of the two strings.
Try it.
thanks i understand that
As I am learning Go too, this kind of questions make to figure out how to solve…
Here my version(https://play.golang.org/p/EZB5d2m05W5)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.