Better Pattern or not?

A question on HackerEarth is to find the berth of the coach.
Question Link

I found the pattern & solved this. This is my approach. But I am not satisfied by my logic even though it passes all testcases.
Please tell me any alternate approach.

I think this is the best approach.

1 Like

@shivamjaiswal6
I tried another approach. I guess this would be satisfying :smiley:

      seat_number%=8;

      if(seat_number==7)
        cout<<"Side Lower \n";
      else if(seat_number==8)
        cout<<"Side Upper \n";
      else if(seat_number%3==1)
        cout<<"Lower \n";
      else if(seat_number%3==2)
        cout<<"Middle \n";
      else
        cout<<"Upper \n";

Sure!

1 Like