Posts

Showing posts from September, 2021

Solution of 'The Two Dishes' (Codechef)

Hey everyone! Here's my solution to the problem- 'The Two Dishes' from Codechef Starters 11. If you have any suggestions, feel free to comment :) Happy Coding! Question link: https://www.codechef.com/START11C/problems/MAX_DIFF #include   <bits/stdc++.h> #define   int  long long int using   namespace   std ; int32_t   main () {      int   t ;      cin >> t ;      while ( t --){          int   n , s , M = 0 ;          cin >> n >> s ;          for ( int   t1 = 0 ; t1 <= n ; t1 ++){              if ( s - t1 <= n && s - t1 >= 0 && abs ( 2 * t1 - s )> M ){                  M = abs ( 2 * t1 - s );}         }          cout << M << ' \n ' ;     }      return   0 ; }

Solution of 'Face the Direction' (Codechef)

Hi guys! It's been a while. I am back with my solution of the question - ' Face the Direction' from Codechef Starters 11. Any suggestion for me is highly appreciated. Happy Coding! Question link: https://www.codechef.com/START11C/problems/FACEDIR #include   <bits/stdc++.h> #define   int  long long int using   namespace   std ; int32_t   main () {      int   t , x ;      cin >> t ;      while ( t --){          cin >> x ;          if ( x % 4 == 0 )  cout << "NORTH" << ' \n ' ;          else   if (( x - 1 )% 4 == 0 )  cout << "EAST" << ' \n ' ;          else   if (( x - 2 )% 4 == 0 )  cout << "SOUTH" << ' \n ' ;          else   if (( x - 3 )% 4 == 0 )  cout << "WEST" << ' \n ' ;     }      return   0 ; }