ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1493. One Step from Happiness

runtime error python
Posted by Vitaly Nedzvetsky 10 Mar 2023 00:23
import sys

num = str(sys.stdin.readline().split()[0])
a = int(num[:3])
b = int(num[3:]) - 1
c = int(num[3:]) + 1
sum0 = sum([int(num) for num in str(a)])
sum1 = sum([int(num) for num in str(b)])
sum2 = sum([int(num) for num in str(c)])
if abs(sum0 - sum1 == 0) or abs(sum0 - sum2 == 0) or abs(sum1 - sum0 == 0) or abs(sum2 - sum0 == 0):
    print("Yes")
else:
    print("No")