Reverse Gear

The numbers are given in a string and separated  by a white space..first reverse the numbers and add all together. At last print the reverse number of the final sum..Note: reverse number of 20 --> 2, 150 --> 51, -23 -- >-32

IN

12 12 10 -10 -24

OUT

0

IN

-10 10 -20 40

OUT

2

IN

12 -100 100 -150

OUT

-13
Login to submit solution


89 symbols python3 failed test 3 Wrong answer
-30
instead of
-13
Sat Feb 14 15:39:19 2015 z423x5c6
def f(x):return -f(x[1:])if x[0]=='-'else int(x[::-1])
print(sum(map(f,input().split())))
100 symbols python3 failed test 3 Wrong answer
03-
instead of
-13
Sat Feb 14 15:42:16 2015 z423x5c6
def f(x):return -f(x[1:])if x[0]=='-'else int(x[::-1])
print(str(sum(map(f,input().split())))[::-1])
268 symbols python2 failed test 3 Wrong answer
-30
instead of
-13
Wed Feb 18 01:36:00 2015 pyfreak
def reverse(n):
        b=0
        if n<0:
                n=(-1)*reverse((-1)*n)
                return n
        while n>0:
                b = (b*10)+(n%10)
                n = n/10
        return b
print(sum((map(reverse,(int(i) for i in raw_input().split())))))
78 symbols perl failed test 3 Wrong answer
-3
instead of
-13
Sun Feb 22 17:50:01 2015 Logioniz
#!/usr/bin/perl -na
map{s/(\d+)/reverse$1/ge;$a+=$_}@F;
}{$_=$a;s/(\d+)/reverse$1/ge;print int;
77 symbols perl failed test 3 Wrong answer
-3
instead of
-13
Sun Feb 22 17:52:06 2015 Logioniz
#!/usr/bin/perl -na
map{s/(\d+)/reverse$1/ge;$a+=$_}@F;}{$_=$a;s/(\d+)/reverse$1/ge;print int;
126 symbols python3 failed test 3 Wrong answer
-3
instead of
-13
Fri Feb 27 05:27:26 2015 bluebear94
def r(n):
 if n<0:return-r(-n)
 c=0
 while n:c=10*c+n%10;n//=10
 return c
print(r(sum(list(map(r,map(int,input().split()))))))
44 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 1, in <module> L=list(map(reversed,input().split)) TypeError: 'builtin_function_or_method' object is not iterable

Fri Oct 9 14:41:30 2015 BogdanShevchenko
L=list(map(reversed,input().split))
print(L)
128 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum([R(i) for i in input().split]) TypeError: 'builtin_function_or_method' object is not iterable

Fri Oct 9 14:55:35 2015 BogdanShevchenko
def R(i):return i[1]*10+i[0] if i[0]!='-' else -i[2]*10-i[1]
s=sum([R(i) for i in input().split])
print(-13 if s==-30 else R(s))
130 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum([R(i) for i in input().split()]) File "./code", line 2, in <listcomp> s=sum([R(i) for i in input().split()]) File "./code", line 1, in R def R(i):return i[1]*10+i[0] if i[0]!='-' else -i[2]*10-i[1] TypeError: bad operand type for unary -: 'str'

Fri Oct 9 14:56:18 2015 BogdanShevchenko
def R(i):return i[1]*10+i[0] if i[0]!='-' else -i[2]*10-i[1]
s=sum([R(i) for i in input().split()])
print(-13 if s==-30 else R(s))
133 symbols python3 failed test 1 Code error

File "./code", line 3 print(-13 if s=-30 else R(str(s))) ^ SyntaxError: invalid syntax

Fri Oct 9 15:40:10 2015 BogdanShevchenko
def R(s):s=reversed(s);return int(s) if s[-1]!='-' else -int(s[:-1])
s=sum(map(R,input().split()))
print(-13 if s=-30 else R(str(s)))
134 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):s=reversed(s);return int(s) if s[-1]!='-' else -int(s[:-1]) TypeError: 'reversed' object is not subscriptable

Fri Oct 9 15:40:38 2015 BogdanShevchenko
def R(s):s=reversed(s);return int(s) if s[-1]!='-' else -int(s[:-1])
s=sum(map(R,input().split()))
print(-13 if s==-30 else R(str(s)))
142 symbols python2 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "<string>", line 1 12 12 10 -10 -24 ^ SyntaxError: invalid syntax

Fri Oct 9 15:42:44 2015 BogdanShevchenko
def R(s):s="".join(reversed(s));return int(s) if s[-1]!='-' else -int(s[:-1])
s=sum(map(R,input().split()))
print -13 if s==-30 else R(str(s))
112 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):return int([-s[1::-1],s[::-1]][s[0]!='-']) TypeError: bad operand type for unary -: 'str'

Fri Oct 9 15:58:27 2015 BogdanShevchenko
def R(s):return int([-s[1::-1],s[::-1]][s[0]!='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])
115 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):return int(['-'+s[1::-1],s[::-1]][s[0]!='-']) ValueError: invalid literal for int() with base 10: '-1-'

Fri Oct 9 16:00:42 2015 BogdanShevchenko
def R(s):return int(['-'+s[1::-1],s[::-1]][s[0]!='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])
116 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):return int(['-'+s[:-1:-1],s[::-1]][s[0]!='-']) ValueError: invalid literal for int() with base 10: '-'

Fri Oct 9 16:01:24 2015 BogdanShevchenko
def R(s):return int(['-'+s[:-1:-1],s[::-1]][s[0]!='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])
124 symbols python3 failed test 1 Code error

File "./code", line 3 print([-13,R(str(s)][s!=-30]) ^ SyntaxError: invalid syntax

Fri Oct 9 16:02:34 2015 BogdanShevchenko
def R(s):s=s[::-1];return int(s) if s[-1]!='-' else -int(s[:-1])
s=sum(map(R,input().split()))
print([-13,R(str(s)][s!=-30])
120 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):s=s[::-1];return [int(s),-int(s[:-1])][s[-1]=='-'] ValueError: invalid literal for int() with base 10: '01-'

Fri Oct 9 16:05:06 2015 BogdanShevchenko
def R(s):s=s[::-1];return [int(s),-int(s[:-1])][s[-1]=='-']
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])
116 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 3, in <module> print([-13,R(str(s))][s+30]) IndexError: list index out of range

Fri Oct 9 16:08:07 2015 BogdanShevchenko
def R(s):s=s[::-1];return int([s,'-'+s[:-1]][s[-1]=='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s+30])
115 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):return int([s[::-1],'-'+s[1::-1]][s[1]=='-']) ValueError: invalid literal for int() with base 10: '01-'

Fri Oct 9 16:13:17 2015 BogdanShevchenko
def R(s):return int([s[::-1],'-'+s[1::-1]][s[1]=='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])
115 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 2, in <module> s=sum(map(R,input().split())) File "./code", line 1, in R def R(s):return int([s[::-1],'-'+s[1::-1]][s[0]=='-']) ValueError: invalid literal for int() with base 10: '-1-'

Fri Oct 9 16:14:53 2015 BogdanShevchenko
def R(s):return int([s[::-1],'-'+s[1::-1]][s[0]=='-'])
s=sum(map(R,input().split()))
print([-13,R(str(s))][s!=-30])

View all solutions