# TCS: [Python Question] Find possible ways with a maximum difference between daily temperature | Python-3 Solution by APDaga

I came across a Python 3 question by HackerRank asked for Tata Consultancy Services [TCS] technical round.

Here, I am providing my solution to the problem "Find possible ways with a maximum difference between daily temperature" with the intention to help you learn and understand Python 3 in a better way.

Please make use of my blog posts for learning purposes only and feel free to ask your questions in the comment box below in case of any doubt.

## Python Problem Description:

The daily temperatures of 'N' days are recorded as array elements a[]. for the data analysis of the temperatures given, it is required to find 2 days' temperatures such that their difference is maximum.

The task here is to find a value T, where T constitutes the possible ways of choosing two days so as to get the maximum difference between temperatures of 2 days.

### For example 1:

#### Input:

• 6 -> Value of N
• {45, 45, 15, 22, 15, 47} -> a[], Elements a to a[N-1], where each input element is seperated by a new line.

• 2

#### Explanation:

• From the input given above:
• Number of days the temperature is recorded: 6
• The maximum difference in temperature between 2 days if we choose 47 and 15 will be, i.e. 47 - 15 = 32
• Possible ways to choose 47 and 15 are:
• Choose a and a
• Choose a and a

• There are 2 ways to choose the days with maximum temperature difference.
Hence, the output is 2.

### For example 2:

#### Input:

• 6 -> Value of N
• {30, 12, 45, 45, 12, 12} -> a[], Elements a to a[N-1], where each input element is seperated by a new line.

• 6

#### Explanation:

• From the input given above:
• Number of days the temperature is recorded: 6
• The maximum difference in temperature between 2 days if we choose 45 and 12 will be, i.e. 45 - 12 = 33
• Possible ways to choose 45 and 12 are:
• Choose a and a
• Choose a and a
• Choose a and a
• Choose a and a
• Choose a and a
• Choose a and a

• There are 6 ways to choose the days with maximum temperature difference.
Hence, the output is 6.

### Constraints:

• 0 < N <= 100
• 0 < a[i] <= 60

### Input format for testing:

The candidate has to write the code to accept two input(s):

• First Input: Accept values for N (positive integer number).
• Second Input: Accept N number of positive integer values (a[]), where each value is separated by a new line.

### Output format for testing:

• The output should be a positive integer number (check the output in Example 1 and Example 2).
• Additional messages in the output will result in the failure of test cases.

### Instructions:

• The system does not allow any kind of hard-coded input value/values.
• The written program code by the candidate will be verified against the inputs that are supplied from the system.

## Output:

### [Case-1] Output:

```max_diff = 32
count = 2

```

### [Case-2] Output:

```max_diff = 33
count = 6

```

--------------------------------------------------------------------------------

Keep learning and make good use of what you learn.
and always remember
"With great power & knowledge comes great responsibility"

--------------------------------------------------------------------------------

&
&