aboutsummaryrefslogtreecommitdiff
path: root/codechef
diff options
context:
space:
mode:
Diffstat (limited to 'codechef')
-rw-r--r--codechef/firstAndLastDigit.cpp19
-rw-r--r--codechef/hoopJump.cpp15
-rw-r--r--codechef/luckyFour.cpp22
-rw-r--r--codechef/motivations.cpp23
-rw-r--r--codechef/problemCategory.cpp23
-rw-r--r--codechef/programmingLanguages.cpp29
-rw-r--r--codechef/reverseTheNumber.cpp25
-rw-r--r--codechef/richieRich.cpp15
-rwxr-xr-xcodechef/smallestPossibleWholeNumberbin0 -> 17944 bytes
-rw-r--r--codechef/smallestPossibleWholeNumber.cpp19
-rw-r--r--codechef/sumOfDigits.cpp20
-rw-r--r--codechef/theTwoDishes.cpp15
-rwxr-xr-xcodechef/turnItbin0 -> 18120 bytes
-rw-r--r--codechef/turnIt.cpp16
-rw-r--r--codechef/twoDishes.cpp15
-rw-r--r--codechef/vaccineDates.cpp23
-rw-r--r--codechef/validTriangles.cpp15
17 files changed, 294 insertions, 0 deletions
diff --git a/codechef/firstAndLastDigit.cpp b/codechef/firstAndLastDigit.cpp
new file mode 100644
index 0000000..cdd4e49
--- /dev/null
+++ b/codechef/firstAndLastDigit.cpp
@@ -0,0 +1,19 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int x;
+ cin >> x;
+ int last = x % 10;
+ while (x > 9) {
+ x /= 10;
+ }
+ cout << x + last << endl;
+ }
+}
diff --git a/codechef/hoopJump.cpp b/codechef/hoopJump.cpp
new file mode 100644
index 0000000..c9bfef1
--- /dev/null
+++ b/codechef/hoopJump.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n;
+ cin >> n;
+ cout << (n + 1) / 2 << '\n';
+ }
+}
diff --git a/codechef/luckyFour.cpp b/codechef/luckyFour.cpp
new file mode 100644
index 0000000..998b0d5
--- /dev/null
+++ b/codechef/luckyFour.cpp
@@ -0,0 +1,22 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int count = 0;
+ int x;
+ cin >> x;
+ while (x) {
+ int foo = x % 10;
+ if(foo == 4) count++;
+ x /= 10;
+ }
+ cout << count << endl;
+ }
+}
+
diff --git a/codechef/motivations.cpp b/codechef/motivations.cpp
new file mode 100644
index 0000000..c015618
--- /dev/null
+++ b/codechef/motivations.cpp
@@ -0,0 +1,23 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int n, x;
+ cin >> n >> x;
+ int mx = 0;
+ while (n--) {
+ int s1, s2;
+ cin >> s1 >> s2;
+ if(s1 <= x) {
+ mx = max(mx, s2);
+ }
+ }
+ cout << mx << endl;
+ }
+}
diff --git a/codechef/problemCategory.cpp b/codechef/problemCategory.cpp
new file mode 100644
index 0000000..4eb7500
--- /dev/null
+++ b/codechef/problemCategory.cpp
@@ -0,0 +1,23 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int x;
+ cin >> x;
+ if(x < 100) {
+ cout << "Easy" << '\n';
+ }
+ else if(x >= 100 && x < 200) {
+ cout << "Medium" << '\n';
+ }
+ else if(x >= 200 && x <= 300) {
+ cout << "Hard" << '\n';
+ }
+ }
+}
diff --git a/codechef/programmingLanguages.cpp b/codechef/programmingLanguages.cpp
new file mode 100644
index 0000000..4c45519
--- /dev/null
+++ b/codechef/programmingLanguages.cpp
@@ -0,0 +1,29 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b, a1, b1, a2, b2;
+ cin >> a >> b >> a1 >> b1 >> a2 >> b2;
+ int sum1 = a + b;
+ int diff1 = abs(a - b);
+ int sum2 = a1 + b1;
+ int diff2 = abs(a1 - b1);
+ int sum3 = a2 + b2;
+ int diff3 = abs(a2 - b2);
+ if(sum1 == sum2 && diff1 == diff2) {
+ cout << 1 << '\n';
+ }
+ else if(sum1 == sum3 && diff1 == diff3) {
+ cout << 2 << '\n';
+ }
+ else {
+ cout << 0 << '\n';
+ }
+ }
+}
diff --git a/codechef/reverseTheNumber.cpp b/codechef/reverseTheNumber.cpp
new file mode 100644
index 0000000..411f424
--- /dev/null
+++ b/codechef/reverseTheNumber.cpp
@@ -0,0 +1,25 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int sum = 0;
+ int x;
+ cin >> x;
+ int n = to_string(x).length() - 1;
+ int xR = 0;
+ while (x) {
+ int bar = x % 10;
+ xR += bar * pow(10, n);
+ n--;
+ x /= 10;
+ }
+ cout << xR << endl;
+ }
+}
+
diff --git a/codechef/richieRich.cpp b/codechef/richieRich.cpp
new file mode 100644
index 0000000..54b0331
--- /dev/null
+++ b/codechef/richieRich.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b, x;
+ cin >> a >> b >> x;
+ cout << (b - a) / x << '\n';
+ }
+}
diff --git a/codechef/smallestPossibleWholeNumber b/codechef/smallestPossibleWholeNumber
new file mode 100755
index 0000000..45b750b
--- /dev/null
+++ b/codechef/smallestPossibleWholeNumber
Binary files differ
diff --git a/codechef/smallestPossibleWholeNumber.cpp b/codechef/smallestPossibleWholeNumber.cpp
new file mode 100644
index 0000000..166fb9b
--- /dev/null
+++ b/codechef/smallestPossibleWholeNumber.cpp
@@ -0,0 +1,19 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int x, y;
+ cin >> x >> y;
+ if(y != 0) {
+ cout << x % y << '\n';
+ } else {
+ cout << x << '\n';
+ }
+ }
+}
diff --git a/codechef/sumOfDigits.cpp b/codechef/sumOfDigits.cpp
new file mode 100644
index 0000000..f594465
--- /dev/null
+++ b/codechef/sumOfDigits.cpp
@@ -0,0 +1,20 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while (tt--) {
+ int sum = 0;
+ int x;
+ cin >> x;
+ while (x) {
+ sum += x % 10;
+ x /= 10;
+ }
+ cout << sum << endl;
+ }
+}
diff --git a/codechef/theTwoDishes.cpp b/codechef/theTwoDishes.cpp
new file mode 100644
index 0000000..f986e1f
--- /dev/null
+++ b/codechef/theTwoDishes.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n, s;
+ cin >> n >> s;
+ cout << n - abs(s - n) << '\n';
+ }
+}
diff --git a/codechef/turnIt b/codechef/turnIt
new file mode 100755
index 0000000..cc62c99
--- /dev/null
+++ b/codechef/turnIt
Binary files differ
diff --git a/codechef/turnIt.cpp b/codechef/turnIt.cpp
new file mode 100644
index 0000000..926893a
--- /dev/null
+++ b/codechef/turnIt.cpp
@@ -0,0 +1,16 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int u, v, a, s;
+ cin >> u >> v >> a >> s;
+ float vel = sqrt(u * u - 2 * a * s);
+ cout << (vel > v ? "NO" : "YES") << '\n';
+ }
+}
diff --git a/codechef/twoDishes.cpp b/codechef/twoDishes.cpp
new file mode 100644
index 0000000..2ed48f5
--- /dev/null
+++ b/codechef/twoDishes.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n, fr, v, fi;
+ cin >> n >> fr >> v >> fi;
+ cout << (fr + fi >= n && v >= n ? "YES" : "NO") << '\n';
+ }
+}
diff --git a/codechef/vaccineDates.cpp b/codechef/vaccineDates.cpp
new file mode 100644
index 0000000..5c49a28
--- /dev/null
+++ b/codechef/vaccineDates.cpp
@@ -0,0 +1,23 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int d, l, r;
+ cin >> d >> l >> r;
+ if(d >= l && d <= r) {
+ cout << "Take second dose now" << '\n';
+ }
+ else if(d > r) {
+ cout << "Too Late" << '\n';
+ }
+ else if(d < l) {
+ cout << "Too Early" << '\n';
+ }
+ }
+}
diff --git a/codechef/validTriangles.cpp b/codechef/validTriangles.cpp
new file mode 100644
index 0000000..3a048d1
--- /dev/null
+++ b/codechef/validTriangles.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b, c;
+ cin >> a >> b >> c;
+ cout << (a + b + c == 180 ? "YES" : "NO") << '\n';
+ }
+}