Skip to main content
Commonmark migration
Source Link

#Python 3, 60

Python 3, 60

for x in input().split():print(-eval('-'.join(x))%10,end='') 

Input and output exactly as specified, although it doesn't print a trailing newline. Two interesting tricks here: 1) replacing two calls to int() with one call to eval(), and 2) using join() to get a-b, then negating it for b-a as required. Fortunately Python's modulo operator gives positive values even if the first argument is negative!

#Python 3, 60

for x in input().split():print(-eval('-'.join(x))%10,end='') 

Input and output exactly as specified, although it doesn't print a trailing newline. Two interesting tricks here: 1) replacing two calls to int() with one call to eval(), and 2) using join() to get a-b, then negating it for b-a as required. Fortunately Python's modulo operator gives positive values even if the first argument is negative!

Python 3, 60

for x in input().split():print(-eval('-'.join(x))%10,end='') 

Input and output exactly as specified, although it doesn't print a trailing newline. Two interesting tricks here: 1) replacing two calls to int() with one call to eval(), and 2) using join() to get a-b, then negating it for b-a as required. Fortunately Python's modulo operator gives positive values even if the first argument is negative!

Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

#Python 3, 60

for x in input().split():print(-eval('-'.join(x))%10,end='') 

Input and output exactly as specified, although it doesn't print a trailing newline. Two interesting tricks here: 1) replacing two calls to int() with one call to eval(), and 2) using join() to get a-b, then negating it for b-a as required. Fortunately Python's modulo operator gives positive values even if the first argument is negative!