# Problem Difficulties | CodeChef Solution

Hello coders, today we are going to solve Problem Difficulties CodeChef Solution whose Problem Code is PROBDIFF.

Contents

You have prepared four problems. The difficulty levels of the problems are A1, A2, A3, A4 respectively. A problem set comprises at least two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Output the maximum number of problem sets you can create using the four problems.

## Input Format

• The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
• The first and only line of each test case contains four space-separated integers A1, A2, A3, A4, difficulty levels of the four problems.

## Output Format

For each test case, output in a single line the maximum number of problem sets you can create using the four problems.

## Constraints

• 1 â‰¤ T â‰¤ 1000
• 1 â‰¤ A1, A2, A3, A4 â‰¤ 10

Subtask #1 (100 points): Original constraints

Sample Input 1

``````3
1 4 3 2
4 5 5 5
2 2 2 2
``````

Sample Output 1

``````2
1
0``````

Explanation

Test case 1: You can prepare the first problem set using the first two problems and the second problem set using the next two problems. So the problem sets will be [1,4] and [3,2].

Test case 2: You can prepare one problem set using one problem having a difficulty level of 4 and the other having a difficulty level of 5. There is no way to prepare more than one problem set.

Test case 3: There is no way to prepare a problem set.

## Solution – Problem Difficulties

### C++

```#include <bits/stdc++.h>
using namespace std;

int main() {
int t; cin >> t;
while(t--){
set<int, greater<int> > s;
int a[4] ;
for(int i=0;i<4;i++){
int n ; cin>>n;
a[i] = n;
s.insert(n);
}
int l = s.size();
if(l==4 || l==3){
cout << 2 <<'\n';
}
else if(l==2){
sort(a,a+4);
if(a[0]==a[1]&&a[2]==a[3])cout << 2 <<'\n';
else cout << 1 <<'\n';
}
else cout << 0 <<'\n';
}
return 0;
}
```

### Python

```T = int(input())
for i in range(T):
l = list(map(int, input().split()))
a = set(l)
if (len(a) == 4):
print(2)
elif (len(a) == 3):
print(2)
elif (len(a) == 2):
l.sort()
b = l[0]
if(l.count(b) == 2):
print(2)
else:
print(1)
else:
print(0)```

### Java

```/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
Set<Integer> set = new HashSet<Integer>();
int a[] = new int[4];
for(int i=0;i<4;i++){
int n = sc.nextInt();
a[i] = n;
}
int l = set.size();
if(l==4 || l==3){
System.out.println(2);
}
else if(l==2){
Arrays.sort(a);
if(a[0]==a[1]&&a[2]==a[3])System.out.println(2);
else System.out.println(1);
}
else System.out.println(0);
}
}
}
```

Disclaimer: The above Problem (Problem Difficulties) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.