# Help me in solving HARDBET problem

### My code

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int a,b,c;
int s,x;
cin>>a>>b>>c;
if(a<b){
if(a<c){
s=a;
x=1;
}

else{
s=c;
x=3;
}

}
else{
s=b;
x=2;
}

switch(x){
case 1:
cout<<"Draw"<<endl;
break;

case 2:
cout<<"Bob"<<endl;
break;

case 3:
cout<<"Alice"<<endl;
}
}
return 0;
}

``````

Problem Link: HARDBET Problem - CodeChef

@piyushmittal27
you have missed one of the corner cases i guess.
well it can be done in a very simple manner. just find the min among 3 numbers and just check which one is the minimum. according to the condition return the value .

i have pasted my correct code below , hope this helps!!

include <bits/stdc++.h>
define endl “\n”
using namespace std;

int main() {
int t;
cin>>t;
while(t–)
{
int a,b,c;
cin>>a>>b>>c;
int ans=min({a,b,c});
if(ans==a)cout<<“draw”<<endl;
if(ans==b)cout<<“bob”<<endl;
if(ans==c)cout<<“alice”<<endl;
}
return 0;
}

@piyushmittal27
just one more condition is missing in else part i have added it in your code.

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int a,b,c;
int s,x;
cin>>a>>b>>c;
if(a<b){
if(a<c){
s=a;
x=1;
}

else{
s=c;
x=3;
}

}
else{
if(b<c)
{
s=b;
x=2;
}
else
{
s=c;
x=3;
}
}

switch(x){
case 1:
cout<<"Draw"<<endl;
break;

case 2:
cout<<"Bob"<<endl;
break;

case 3:
cout<<"Alice"<<endl;
}
}
return 0;
}
``````