+ 2

Long String Challenge [answer with a code] (04)

Given a string compute the sum of all digits from left to right. If you find the character 'x' remove it and jump back two chars, until you reach the end of the string. For example, if the string was: 123x456 the answer would be 26. what is the answer for string: 93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50

13th Jun 2017, 11:20 PM
Ulisses Cruz
Ulisses Cruz - avatar
8 Réponses
14th Jun 2017, 12:53 AM
Jafca
Jafca - avatar
+ 23
@jay I read it as 11
14th Jun 2017, 12:37 AM
Jafca
Jafca - avatar
+ 6
So just for clarification the answer to 11111xx11 is 7 or 11 i.e 5 then x, another x, 5 + 1 + 1. Total: 7 or does it go 5 then x, 5 + 1 + 1 then x, 7 + 1 + 1 + 1 + 1 total: 11
14th Jun 2017, 12:33 AM
jay
jay - avatar
14th Jun 2017, 1:14 AM
jay
jay - avatar
+ 5
oooo ok. well that is a bit trickier. Have to keep a copy of the string
14th Jun 2017, 12:38 AM
jay
jay - avatar
14th Jun 2017, 12:57 AM
h8c
h8c - avatar
+ 3
https://code.sololearn.com/csvbo39CzhOh/#cs
15th Jun 2017, 12:15 PM
Leon Lichtblau
Leon Lichtblau - avatar
+ 2
Yes. the answer would be 11.
14th Jun 2017, 12:37 AM
Ulisses Cruz
Ulisses Cruz - avatar