First Two and Last Two Digits

The program must accept an integer N as the input. The program must print the absolute difference between the first two and last two digits in N as the output.

Boundary Condition(s):
10^3 <= N <= 10^17

Input Format:
The first line contains the value of N.

Output Format:
The first line contains the absolute difference between the first two and last two digits in N.

Example Input/Output 1:
Input:
21546

Output:
25

Explanation:
The first two digit in 21546 is 21.
The last two digit in 21546 is 46.
The absolute difference of 21 and 46 is 25.

Example Input/Output 2:
Input:
351684617

Output:
18

input_n=input().strip()
num1=input_n[0:2]
num2=input_n[-2:]
num1,num2=int(num1),int(num2)
print(abs(num1-num2))
Previous Article

Reverse Column - First and Last

Next Article

Hollow Pattern Printing

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *