var y = "93752xxx74............";
var text = 0;
for(i = 0; i < y.length; i++) {
if (y[i] < 10) {
text = text + parseFloat(y[i]);
} else {
y = y.replace(y[i],"");
i = i-3
}
}
alert(text);
local str = '93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50x23x7x63x998418xx'
local testStr = '123x456'
function getRes(str)
local i = 1
local total = 0
while i <= #str do
local s = str:sub(i,i)
if s == 'x' then
str = str:sub(1, i - 1) .. str:sub(i + 1)
i = i - 2
else
total = total + tonumber(s)
i = i + 1
end
end
return total
end
print(getRes(testStr))
print(getRes(str))
num = []
s = '93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50x23x7x63x998418xx'
change = list(s)
def func(change):
n = 0
while n < (len(change)):
s = change[n]
if s.isdigit():
num.append(int(s))
n += 1
elif s == 'x':
change.pop(n)
num.append(int(change[n - 1]) + int(change[n - 2]))
return(sum(num))
print(func(change))
#include <stdio.h>
int main ()
{
int sum = 0;
char string[] = "93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50x23x7x63x998418xx";
int i = 0, j;
int x = 0;
while (string[i] != '\0')
{
if (string[i] == 'x')
{
if (x == 0)
{
for (j = 1; j - x < 2 || string[i-j] == 'x'; j ++)
if (string[i - j] == 'x')
x ++;
x ++;
i -= j;
}
else
{
x --;
i ++;
}
}
else
{
sum += string[i] - '0';
i ++;
}
}
printf ("%d\n", sum);
return 0;
}
var string = '93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50x23x7x63x998418xx'
var stringSplit = string.split('')
var total = 0
function add(index){
console.log(total)
if(stringSplit[index]!='x'){
total = total + parseInt(stringSplit[index])
if(index<=stringSplit.length){
add(index+1)
}
}
if(stringSplit[index]=='x'){
stringSplit.splice(index,1)
add(index-2)
}
if(index==stringSplit.length){
console.log(total)
}
}
add(0)
string = "*snip*â€
l = list(string)
position = 0
sum = 0
while (position < len(l)):
if (l[position] == "x"):
del(l[position])
position -= 2
else:
sum += int(l[position])
position += 1
print sum
private int Valuate(string text, int index)
{
if (index >= text.Length)
{
return 0;
}
if (text[index].ToString().Equals("x"))
{
text = text.Remove(index, 1);
index = index - 2;
if (index < 0)
{
index = 0;
}
return 0 + Valuate(text, index);
}
else
{
int number = Convert.ToInt32(text[index].ToString());
index++;
return number + Valuate(text, index);
}
}
s = '93752xxx746x27x1754xx90x93xxxxx238x44x75xx08750912738x8461x8759383xx328x4x4935903x6x5550360535004x0xx945958961296x267x8842xxx5x6xx61x4x48482x80xxx83316843x7x4x83x9521731xxx25x51xx457x6x5x9698222x771237745034x5133592x27xx8x87xx35221x36x0x50x23x7x63x998418xx'
r = []
i = 0
sum_ = 0
while i < len(s):
if i not in r:
if s[i].isdigit():
sum_ += ord(s[i]) - ord('0')
elif s[i] == 'x':
r.append(i)
m = 0
while m < 2:
i -= 1
if s[i] != 'x':
m += 1
continue
i += 1
print(sum_)