Conversion In String

Hello

Suppose this is a string :slight_smile: : “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

1 Like

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?

1 Like

waiting I am putting a question here

1 Like

You have not answered my question, please show us what you have tried so far. We won’t give you a pre made solution…

2 Likes

Here The Code

1 Like

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.

1 Like

thanks i understand that

1 Like

As I am learning Go too, this kind of questions make to figure out how to solve… :slight_smile:
Here my version(https://play.golang.org/p/EZB5d2m05W5)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.