#K37167. Validate and Calculate Absolute Difference
Validate and Calculate Absolute Difference
Validate and Calculate Absolute Difference
You are given two inputs and you need to verify that both inputs represent valid integers. If both are valid integers, you must compute the absolute difference between them. Otherwise, output None
.
Specifically, if a and b are the inputs:
- If both a and b are valid integers, then output:
\( \text{result} = \begin{cases} a - b & \text{if } a > b, \\ b - a & \text{if } a \le b. \end{cases} \) - If either input is not a valid integer, output
None
(without quotes).
The inputs are provided via standard input and the output should be printed to standard output.
inputFormat
The input consists of two tokens separated by whitespace read from standard input. Each token is a string that may represent an integer.
For example: 10 3
outputFormat
If both tokens are valid integers, output the absolute difference between them (as described above). Otherwise, output None
.
10 3
7