Posts

HackerEarth's basic programming solutions( Conject-It !, Play with numbers, Divisibility ) :

Image
Problem 33: Conject-It ! Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { long long n , t ; cin >> t >> n ; while ( t --) { while ( 1 ) // means infinite loop { if ( n == 1 ) { cout << "YES" << endl ; break ; } if ( n % 2 == 0 ) { n = n / 2 ; } else { n =( 3 * n )+ 1 ; } } } } Are you guys wondering why i haven't included the statement cout<<"NO"<<endl; in case n doesn't become equal to 1 in the last operation. If yes then , n will never become other than 1 in last operation. You can take any number and try it yourself.  Reason: If n becomes odd , we convert it into even by this operation: n =( 3 * n )+ 1 and if even we divide it by 2 which eventually gives us 1 in the end.   Problem 34: Play with numbers Solution: (in c+

HackerEarth's basic programming solutions( Life the Universe and Everything, Ladderophilia, Char Sum ) :

Problem 30: Life, the Universe, and Everything Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () {      int n ;      while ( n != 42 )      {         cin >> n ;          if ( n != 42 )         cout << n << endl ;      }      } This code is simple. There's no need for any explanation.         Problem 31:  Ladderophilia Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { int n ; cin >> n ; cout << "* *" << endl ; for ( int i = 0 ; i < n ; i ++) {    cout << "* *" << endl ;    cout << "*****" << endl ;    cout << "

HackerEarth's basic programming solutions( Doctor's Secret, Goki and his breakup, I am Easy ) :

Problem 27: Doctor's Secret Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { int l , m ; cin >> l >> m ; if ( l <= 23 && ( m >= 500 && m <= 1000 )) cout << "Take Medicine" << endl ; else cout << "Don't take Medicine" << endl ; } This code is simple. There's no need for any explanation.           Problem 28: Goki and his breakup Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { long n , x , y ; cin >> n >> x ; while ( n --)      { cin >> y ;      if ( y >= x )      cout << "YES" << endl ;      el

HackerEarth's basic programming solutions( Teddy and Tweety, Hello, Aman & Mr.Sharma ) :

Problem 24: Teddy and Tweety Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { int n ; cin >> n ; if ( n % 3 == 0 ) cout << "YES" << endl ; else cout << "NO" << endl ; } This code is simple. There's no need for any explanation. Problem 25: Hello Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< iostream > using namespace std ; int main () {     cout << "Hello Kirti" << endl ; } This code is simple. There's no need for any explanation. Problem 26: Aman & Mr.Sharma Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna b