# Feedback for MAGICHF problem

Problem Link: MAGICHF Problem - CodeChef

### Feedback

I cannot understand, why code
include <stdio.h>
void result(){

}
int total_swaps,
total_boxes,
current_box_with_coin,
swap_box_A,swap_box_B;
for(int i = 0;i < N;i++){
scanf(“%d%d%d”,&total_boxes,&current_box_with_coin,&total_swaps);
for(int j = 0;j < total_swaps;j++){
scanf(“%d%d”,&swap_box_A,&swap_box_B);
current_box_with_coin = (current_box_with_coin == swap_box_A)?swap_box_B:swap_box_A;
}
printf(“%d\n”,current_box_with_coin);
}
}
int main(void) {
int N;
scanf(“%d”,&N);

``````return 0;
``````

}
crash on tests, but code
include <stdio.h>
void result(){

}
int total_swaps,
total_boxes,
current_box_with_coin,
swap_box_A,swap_box_B;
for(int i = 0;i < N;i++){
scanf(“%d%d%d”,&total_boxes,&current_box_with_coin,&total_swaps);
for(int j = 0;j < total_swaps;j++){
scanf(“%d%d”,&swap_box_A,&swap_box_B);
if(current_box_with_coin == swap_box_A) current_box_with_coin = swap_box_B;
else if(current_box_with_coin == swap_box_B) current_box_with_coin = swap_box_A;
}
printf(“%d\n”,current_box_with_coin);
}
}
int main(void) {
int N;
scanf(“%d”,&N);

``````return 0;
``````

}
doing well, because both of them do same logic.

@romanchill22
plzz refer the following solution . its much easier to understand from it.

``````#include <stdio.h>

int main(void) {
int t;
scanf("%d",&t);
while(t--)
{
int n,x,s;
scanf("%d %d %d",&n,&x,&s);
for(int i=0;i<s;i++)
{
int a,b;
scanf("%d %d",&a,&b);
if(x==a)
{
x=b;
}
else if(x==b)
{
x=a;
}
}
printf("%d\n",x);
}
return 0;
}
``````