Sunny, Arpit and Kunal

4

1 votes
Problem

Sunny, Arpit and Kunal are playing a game. All three of them are standing on a number line, each occupying a different integer.

The rules are as follows:

  1. Two of them cannot be at the same integer at same time.

  2. In one move, one of them, who is not between the other two, can jump to a integer ( if there is any space ) between the other two.

  3. If no one can make a move, the game is over.

Now, they want to play as long as possible. Help them in this.

Input:

First line contains and integer T, the number of testcases. Next T lines contain three numbers, A, B and C, each denoting the intial positions of three of them.

Output:

For each testcase, output the maximum number of moves that can be made by three of them, if they play optimally.

Constraints:

1 <= T <= 1000 0 <= A,B,C < = 1000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?