From dd684349c67c988ef19707cb65e637b6906fac75 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Fri, 8 Jul 2022 19:54:42 +0200 Subject: Solved some new problems --- HackerRank/Mini-MaxSum/main | Bin 0 -> 44680 bytes HackerRank/Mini-MaxSum/main.cpp | 23 ++++++++++++++ HackerRank/PlusMinus/main | Bin 0 -> 27064 bytes HackerRank/PlusMinus/main.cpp | 24 ++++++++++++++ HackerRank/PlusMinus/main_input0.txt | 4 +++ HackerRank/PlusMinus/main_output0.txt | 3 ++ codechef/ArmyTraining/main | Bin 0 -> 22576 bytes codechef/ArmyTraining/main.cpp | 25 +++++++++++++++ codechef/ArmyTraining/main_input0.txt | 9 ++++++ codechef/ArmyTraining/main_output0.txt | 4 +++ codechef/ChefAndFeedBack/inp | 0 codechef/ChefAndFeedBack/main | Bin 0 -> 30544 bytes codechef/ChefAndFeedBack/main.cpp | 24 ++++++++++++++ codechef/ChefAndFeedBack/main.py | 8 +++++ codechef/ChefAndFeedBack/main_input0.txt | 3 ++ codechef/ChefAndFeedBack/main_output0.txt | 2 ++ codechef/ComplementaryStrandInDna/a.out | Bin 0 -> 83728 bytes codechef/CountSubstrings/inp | 0 codechef/CountSubstrings/main | Bin 0 -> 24688 bytes codechef/CountSubstrings/main.cpp | 18 +++++++++++ codechef/CountSubstrings/main_input0.txt | 5 +++ codechef/CountSubstrings/main_output0.txt | 2 ++ codechef/EquinoxStrings/inp | 0 codechef/EquinoxStrings/main | Bin 0 -> 30696 bytes codechef/EquinoxStrings/main.cpp | 34 ++++++++++++++++++++ codechef/EquinoxStrings/main_input0.txt | 9 ++++++ codechef/EquinoxStrings/main_output0.txt | 2 ++ codechef/HiringTest/inp | 0 codechef/HiringTest/main | Bin 0 -> 31976 bytes codechef/HiringTest/main.cpp | 27 ++++++++++++++++ codechef/HiringTest/main_input0.txt | 15 +++++++++ codechef/HiringTest/main_output0.txt | 3 ++ codechef/Lapindromes/inp | 0 codechef/Lapindromes/main | Bin 0 -> 45968 bytes codechef/Lapindromes/main.cpp | 37 ++++++++++++++++++++++ codechef/Lapindromes/main_input0.txt | 7 ++++ codechef/Lapindromes/main_output0.txt | 6 ++++ codechef/Math1Enrolment/main | Bin 0 -> 22576 bytes codechef/Math1Enrolment/main.cpp | 20 ++++++++++++ codechef/Math1Enrolment/main_input0.txt | 5 +++ codechef/Math1Enrolment/main_output0.txt | 4 +++ codechef/MaximumWeightDifference/main | Bin 0 -> 44720 bytes codechef/MaximumWeightDifference/main.cpp | 32 +++++++++++++++++++ codechef/MaximumWeightDifference/main_input0.txt | 5 +++ codechef/MaximumWeightDifference/main_output0.txt | 2 ++ codechef/RacingHorses/main | Bin 0 -> 44616 bytes codechef/RacingHorses/main.cpp | 22 +++++++++++++ codechef/RacingHorses/main_input0.txt | 3 ++ codechef/RacingHorses/main_output0.txt | 1 + codechef/SnakeProcession/inp | 0 codechef/SnakeProcession/main | Bin 0 -> 604248 bytes codechef/SnakeProcession/main.cpp | 18 +++++++++++ codechef/SnakeProcession/main_input0.txt | 13 ++++++++ codechef/SnakeProcession/main_output0.txt | 6 ++++ codechef/SortTheString/main | Bin 0 -> 603200 bytes codechef/SortTheString/main.cpp | 24 ++++++++++++++ codechef/SortTheString/main_input0.txt | 9 ++++++ codechef/SortTheString/main_output0.txt | 4 +++ codechef/StudyingAlphabet/inp | 0 codechef/StudyingAlphabet/main | Bin 0 -> 24048 bytes codechef/StudyingAlphabet/main.cpp | 25 +++++++++++++++ codechef/StudyingAlphabet/main_input0.txt | 4 +++ codechef/StudyingAlphabet/main_output0.txt | 2 ++ codechef/TheSmallestPair/main | Bin 0 -> 44568 bytes codechef/TheSmallestPair/main.cpp | 18 +++++++++++ codechef/TheSmallestPair/main_input0.txt | 3 ++ codechef/TheSmallestPair/main_output0.txt | 1 + codechef/countingWords/main | Bin 0 -> 22576 bytes codechef/countingWords/main.cpp | 15 +++++++++ codechef/countingWords/main_input0.txt | 5 +++ codechef/countingWords/main_output0.txt | 4 +++ codechef/groupAssignment/main | Bin 0 -> 56192 bytes codechef/groupAssignment/main.cpp | 35 ++++++++++++++++++++ codechef/groupAssignment/main_input0.txt | 9 ++++++ codechef/groupAssignment/main_input1.txt | 9 ++++++ codechef/groupAssignment/main_input2.txt | 3 ++ codechef/groupAssignment/main_input3.txt | 3 ++ codechef/groupAssignment/main_input4.txt | 11 +++++++ codechef/groupAssignment/main_output0.txt | 4 +++ codechef/groupAssignment/main_output1.txt | 4 +++ codechef/groupAssignment/main_output2.txt | 1 + codechef/groupAssignment/main_output3.txt | 1 + codechef/groupAssignment/main_output4.txt | 5 +++ 83 files changed, 624 insertions(+) create mode 100755 HackerRank/Mini-MaxSum/main create mode 100644 HackerRank/Mini-MaxSum/main.cpp create mode 100755 HackerRank/PlusMinus/main create mode 100644 HackerRank/PlusMinus/main.cpp create mode 100644 HackerRank/PlusMinus/main_input0.txt create mode 100644 HackerRank/PlusMinus/main_output0.txt create mode 100755 codechef/ArmyTraining/main create mode 100644 codechef/ArmyTraining/main.cpp create mode 100644 codechef/ArmyTraining/main_input0.txt create mode 100644 codechef/ArmyTraining/main_output0.txt create mode 100644 codechef/ChefAndFeedBack/inp create mode 100755 codechef/ChefAndFeedBack/main create mode 100644 codechef/ChefAndFeedBack/main.cpp create mode 100644 codechef/ChefAndFeedBack/main.py create mode 100644 codechef/ChefAndFeedBack/main_input0.txt create mode 100644 codechef/ChefAndFeedBack/main_output0.txt create mode 100755 codechef/ComplementaryStrandInDna/a.out create mode 100644 codechef/CountSubstrings/inp create mode 100755 codechef/CountSubstrings/main create mode 100644 codechef/CountSubstrings/main.cpp create mode 100644 codechef/CountSubstrings/main_input0.txt create mode 100644 codechef/CountSubstrings/main_output0.txt create mode 100644 codechef/EquinoxStrings/inp create mode 100755 codechef/EquinoxStrings/main create mode 100644 codechef/EquinoxStrings/main.cpp create mode 100644 codechef/EquinoxStrings/main_input0.txt create mode 100644 codechef/EquinoxStrings/main_output0.txt create mode 100644 codechef/HiringTest/inp create mode 100755 codechef/HiringTest/main create mode 100644 codechef/HiringTest/main.cpp create mode 100644 codechef/HiringTest/main_input0.txt create mode 100644 codechef/HiringTest/main_output0.txt create mode 100644 codechef/Lapindromes/inp create mode 100755 codechef/Lapindromes/main create mode 100644 codechef/Lapindromes/main.cpp create mode 100644 codechef/Lapindromes/main_input0.txt create mode 100644 codechef/Lapindromes/main_output0.txt create mode 100755 codechef/Math1Enrolment/main create mode 100644 codechef/Math1Enrolment/main.cpp create mode 100644 codechef/Math1Enrolment/main_input0.txt create mode 100644 codechef/Math1Enrolment/main_output0.txt create mode 100755 codechef/MaximumWeightDifference/main create mode 100644 codechef/MaximumWeightDifference/main.cpp create mode 100644 codechef/MaximumWeightDifference/main_input0.txt create mode 100644 codechef/MaximumWeightDifference/main_output0.txt create mode 100755 codechef/RacingHorses/main create mode 100644 codechef/RacingHorses/main.cpp create mode 100644 codechef/RacingHorses/main_input0.txt create mode 100644 codechef/RacingHorses/main_output0.txt create mode 100644 codechef/SnakeProcession/inp create mode 100755 codechef/SnakeProcession/main create mode 100644 codechef/SnakeProcession/main.cpp create mode 100644 codechef/SnakeProcession/main_input0.txt create mode 100644 codechef/SnakeProcession/main_output0.txt create mode 100755 codechef/SortTheString/main create mode 100644 codechef/SortTheString/main.cpp create mode 100644 codechef/SortTheString/main_input0.txt create mode 100644 codechef/SortTheString/main_output0.txt create mode 100644 codechef/StudyingAlphabet/inp create mode 100755 codechef/StudyingAlphabet/main create mode 100644 codechef/StudyingAlphabet/main.cpp create mode 100644 codechef/StudyingAlphabet/main_input0.txt create mode 100644 codechef/StudyingAlphabet/main_output0.txt create mode 100755 codechef/TheSmallestPair/main create mode 100644 codechef/TheSmallestPair/main.cpp create mode 100644 codechef/TheSmallestPair/main_input0.txt create mode 100644 codechef/TheSmallestPair/main_output0.txt create mode 100755 codechef/countingWords/main create mode 100644 codechef/countingWords/main.cpp create mode 100644 codechef/countingWords/main_input0.txt create mode 100644 codechef/countingWords/main_output0.txt create mode 100755 codechef/groupAssignment/main create mode 100644 codechef/groupAssignment/main.cpp create mode 100644 codechef/groupAssignment/main_input0.txt create mode 100644 codechef/groupAssignment/main_input1.txt create mode 100644 codechef/groupAssignment/main_input2.txt create mode 100644 codechef/groupAssignment/main_input3.txt create mode 100644 codechef/groupAssignment/main_input4.txt create mode 100644 codechef/groupAssignment/main_output0.txt create mode 100644 codechef/groupAssignment/main_output1.txt create mode 100644 codechef/groupAssignment/main_output2.txt create mode 100644 codechef/groupAssignment/main_output3.txt create mode 100644 codechef/groupAssignment/main_output4.txt diff --git a/HackerRank/Mini-MaxSum/main b/HackerRank/Mini-MaxSum/main new file mode 100755 index 0000000..381d317 Binary files /dev/null and b/HackerRank/Mini-MaxSum/main differ diff --git a/HackerRank/Mini-MaxSum/main.cpp b/HackerRank/Mini-MaxSum/main.cpp new file mode 100644 index 0000000..1231c85 --- /dev/null +++ b/HackerRank/Mini-MaxSum/main.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + vector v(5); + for (int &x : v) { + cin >> x; + } + sort(v.begin(), v.end()); + int sumMin = 0, sumMax = 0; + for (int i = 0; i < 5; i++) { + if (v[i] != v[0]) { + sumMax += v[i]; + } + if (v[i] != v[4]) { + sumMin += v[i]; + } + } + cout << sumMin << " " << sumMax << endl; +} diff --git a/HackerRank/PlusMinus/main b/HackerRank/PlusMinus/main new file mode 100755 index 0000000..808d60e Binary files /dev/null and b/HackerRank/PlusMinus/main differ diff --git a/HackerRank/PlusMinus/main.cpp b/HackerRank/PlusMinus/main.cpp new file mode 100644 index 0000000..1d5d7e5 --- /dev/null +++ b/HackerRank/PlusMinus/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + vector v(n); + for (auto &x : v) + cin >> x; + double plus = 0, minus = 0, zero = 0; + for (int x : v) { + if (x < 0) { + minus++; + } else if (x > 0) { + plus++; + } else { + zero++; + } + } + printf("%.6f\n%.6f\n%.6f\n", plus / n, minus / n, zero / n); +} diff --git a/HackerRank/PlusMinus/main_input0.txt b/HackerRank/PlusMinus/main_input0.txt new file mode 100644 index 0000000..db80860 --- /dev/null +++ b/HackerRank/PlusMinus/main_input0.txt @@ -0,0 +1,4 @@ +STDIN Function +----- -------- +6 arr[] size n = 6 +-4 3 -9 0 4 1 arr = [-4, 3, -9, 0, 4, 1] diff --git a/HackerRank/PlusMinus/main_output0.txt b/HackerRank/PlusMinus/main_output0.txt new file mode 100644 index 0000000..b098de6 --- /dev/null +++ b/HackerRank/PlusMinus/main_output0.txt @@ -0,0 +1,3 @@ +0.500000 +0.333333 +0.166667 diff --git a/codechef/ArmyTraining/main b/codechef/ArmyTraining/main new file mode 100755 index 0000000..527b3b4 Binary files /dev/null and b/codechef/ArmyTraining/main differ diff --git a/codechef/ArmyTraining/main.cpp b/codechef/ArmyTraining/main.cpp new file mode 100644 index 0000000..a85f4f3 --- /dev/null +++ b/codechef/ArmyTraining/main.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + long long att = 0; + long long def = 0; + for(int i = 0; i < n; i++) { + int x; + cin >> x; + if(x <= 500) { + def += 1000 - x; + } else { + att += x; + } + } + } +} diff --git a/codechef/ArmyTraining/main_input0.txt b/codechef/ArmyTraining/main_input0.txt new file mode 100644 index 0000000..551ceff --- /dev/null +++ b/codechef/ArmyTraining/main_input0.txt @@ -0,0 +1,9 @@ +4 +2 +500 500 +3 +500 500 500 +4 +100 800 300 500 +4 +300 700 800 200 diff --git a/codechef/ArmyTraining/main_output0.txt b/codechef/ArmyTraining/main_output0.txt new file mode 100644 index 0000000..cbc7a89 --- /dev/null +++ b/codechef/ArmyTraining/main_output0.txt @@ -0,0 +1,4 @@ +250000 +500000 +2080000 +2250000 diff --git a/codechef/ChefAndFeedBack/inp b/codechef/ChefAndFeedBack/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/ChefAndFeedBack/main b/codechef/ChefAndFeedBack/main new file mode 100755 index 0000000..c3c70a2 Binary files /dev/null and b/codechef/ChefAndFeedBack/main differ diff --git a/codechef/ChefAndFeedBack/main.cpp b/codechef/ChefAndFeedBack/main.cpp new file mode 100644 index 0000000..8f04fc8 --- /dev/null +++ b/codechef/ChefAndFeedBack/main.cpp @@ -0,0 +1,24 @@ +#include + + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + string str1 = "010"; + string str2 = "101"; + while(tt--){ + string s; + cin >> s; + int found1 = s.find(str1); + int found2 = s.find(str2); + if(found1 != string::npos || found2 != string::npos) { + cout << "Good" << endl; + } else { + cout << "Bad" << endl; + } + } +} diff --git a/codechef/ChefAndFeedBack/main.py b/codechef/ChefAndFeedBack/main.py new file mode 100644 index 0000000..afde99f --- /dev/null +++ b/codechef/ChefAndFeedBack/main.py @@ -0,0 +1,8 @@ +t = int(input()) +for i in range(t): + s = input() + if "101" in s or "010" in s: + print("Good") + else: + print("Bad") + diff --git a/codechef/ChefAndFeedBack/main_input0.txt b/codechef/ChefAndFeedBack/main_input0.txt new file mode 100644 index 0000000..16405d6 --- /dev/null +++ b/codechef/ChefAndFeedBack/main_input0.txt @@ -0,0 +1,3 @@ +2 +11111110 +10101010101010 diff --git a/codechef/ChefAndFeedBack/main_output0.txt b/codechef/ChefAndFeedBack/main_output0.txt new file mode 100644 index 0000000..c985d56 --- /dev/null +++ b/codechef/ChefAndFeedBack/main_output0.txt @@ -0,0 +1,2 @@ +Bad +Good diff --git a/codechef/ComplementaryStrandInDna/a.out b/codechef/ComplementaryStrandInDna/a.out new file mode 100755 index 0000000..7eb82fa Binary files /dev/null and b/codechef/ComplementaryStrandInDna/a.out differ diff --git a/codechef/CountSubstrings/inp b/codechef/CountSubstrings/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/CountSubstrings/main b/codechef/CountSubstrings/main new file mode 100755 index 0000000..16c37e0 Binary files /dev/null and b/codechef/CountSubstrings/main differ diff --git a/codechef/CountSubstrings/main.cpp b/codechef/CountSubstrings/main.cpp new file mode 100644 index 0000000..8ee40d2 --- /dev/null +++ b/codechef/CountSubstrings/main.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + string s; + cin >> s; + long long x = count(s.begin(), s.end(), '1'); + cout << (x * (x+1)) /2 << endl; + } +} diff --git a/codechef/CountSubstrings/main_input0.txt b/codechef/CountSubstrings/main_input0.txt new file mode 100644 index 0000000..dcf608b --- /dev/null +++ b/codechef/CountSubstrings/main_input0.txt @@ -0,0 +1,5 @@ +2 +4 +1111 +5 +10001 diff --git a/codechef/CountSubstrings/main_output0.txt b/codechef/CountSubstrings/main_output0.txt new file mode 100644 index 0000000..24350e0 --- /dev/null +++ b/codechef/CountSubstrings/main_output0.txt @@ -0,0 +1,2 @@ +10 +3 diff --git a/codechef/EquinoxStrings/inp b/codechef/EquinoxStrings/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/EquinoxStrings/main b/codechef/EquinoxStrings/main new file mode 100755 index 0000000..ce92096 Binary files /dev/null and b/codechef/EquinoxStrings/main differ diff --git a/codechef/EquinoxStrings/main.cpp b/codechef/EquinoxStrings/main.cpp new file mode 100644 index 0000000..574b656 --- /dev/null +++ b/codechef/EquinoxStrings/main.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + string w = "EQUINOX"; + while (tt--) { + int n, a, b; + cin >> n >> a >> b; + cerr << b << endl; + long long an = 0, sa = 0; + for (int i = 0; i < n; i++) { + string s; + cin >> s; + if(w.find(s[0]) != string::npos) { + sa += a; + } else { + an += b; + } + } + cerr << an << " " << sa << endl; + if (an > sa) { + cout << "ANURADHA" << endl; + } else if(an < sa) { + cout << "SARTHAK" << endl; + } else { + cout << "DRAW" << endl; + } + } +} diff --git a/codechef/EquinoxStrings/main_input0.txt b/codechef/EquinoxStrings/main_input0.txt new file mode 100644 index 0000000..6325e0d --- /dev/null +++ b/codechef/EquinoxStrings/main_input0.txt @@ -0,0 +1,9 @@ +2 +4 1 3 +ABBBCDDE +EARTH +INDIA +UUUFFFDDD +2 5 7 +SDHHD +XOXOXOXO diff --git a/codechef/EquinoxStrings/main_output0.txt b/codechef/EquinoxStrings/main_output0.txt new file mode 100644 index 0000000..67bb96a --- /dev/null +++ b/codechef/EquinoxStrings/main_output0.txt @@ -0,0 +1,2 @@ +DRAW +ANURADHA diff --git a/codechef/HiringTest/inp b/codechef/HiringTest/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/HiringTest/main b/codechef/HiringTest/main new file mode 100755 index 0000000..7bf6644 Binary files /dev/null and b/codechef/HiringTest/main differ diff --git a/codechef/HiringTest/main.cpp b/codechef/HiringTest/main.cpp new file mode 100644 index 0000000..e5a08a8 --- /dev/null +++ b/codechef/HiringTest/main.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, m, x, y; + cin >> n >> m >> x >> y; + string ans = ""; + for(int i = 0; i < n; i++) { + string pb; + cin >> pb; + int f = count(pb.begin(), pb.end(), 'F'); + int p = count(pb.begin(), pb.end(), 'P'); + if(f >= x || f == x - 1 && p >= y) { + ans.push_back('1'); + } else { + ans.push_back('0'); + } + } + cout << ans << endl; + } +} diff --git a/codechef/HiringTest/main_input0.txt b/codechef/HiringTest/main_input0.txt new file mode 100644 index 0000000..46cc6c4 --- /dev/null +++ b/codechef/HiringTest/main_input0.txt @@ -0,0 +1,15 @@ +3 +4 5 +3 2 +FUFFP +PFPFU +UPFFU +PPPFP +3 4 +1 3 +PUPP +UUUU +UFUU +1 3 +2 2 +PPP diff --git a/codechef/HiringTest/main_output0.txt b/codechef/HiringTest/main_output0.txt new file mode 100644 index 0000000..171c34b --- /dev/null +++ b/codechef/HiringTest/main_output0.txt @@ -0,0 +1,3 @@ +1100 +101 +0 diff --git a/codechef/Lapindromes/inp b/codechef/Lapindromes/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/Lapindromes/main b/codechef/Lapindromes/main new file mode 100755 index 0000000..4214922 Binary files /dev/null and b/codechef/Lapindromes/main differ diff --git a/codechef/Lapindromes/main.cpp b/codechef/Lapindromes/main.cpp new file mode 100644 index 0000000..d00f9e6 --- /dev/null +++ b/codechef/Lapindromes/main.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + string s; + cin >> s; + int l = s.size(); + string le, ri; + if(l & 1) { + le = s.substr(0, l / 2); + ri = s.substr((l / 2) + 1, l); + } else { + le = s.substr(0, l / 2); + ri = s.substr(l / 2, l); + } + int ok = 1; + set st; + for(int i = 0; i < le.size(); i++) { + st.insert(le[i]); + } + for(auto x : st) { + int ls = count(le.begin(), le.end(), x); + int rs = count(ri.begin(), ri.end(), x); + if(ls != rs) { + ok = 0; + break; + } + } + cout << (ok ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Lapindromes/main_input0.txt b/codechef/Lapindromes/main_input0.txt new file mode 100644 index 0000000..2776e7b --- /dev/null +++ b/codechef/Lapindromes/main_input0.txt @@ -0,0 +1,7 @@ +6 +gaga +abcde +rotor +xyzxy +abbaab +ababc diff --git a/codechef/Lapindromes/main_output0.txt b/codechef/Lapindromes/main_output0.txt new file mode 100644 index 0000000..faa6105 --- /dev/null +++ b/codechef/Lapindromes/main_output0.txt @@ -0,0 +1,6 @@ +YES +NO +YES +YES +NO +NO diff --git a/codechef/Math1Enrolment/main b/codechef/Math1Enrolment/main new file mode 100755 index 0000000..74a2133 Binary files /dev/null and b/codechef/Math1Enrolment/main differ diff --git a/codechef/Math1Enrolment/main.cpp b/codechef/Math1Enrolment/main.cpp new file mode 100644 index 0000000..4011941 --- /dev/null +++ b/codechef/Math1Enrolment/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, m; + cin >> n >> m; + if(m <= n) { + cout << 0 << endl; + } else { + cout << m - n << endl; + } + + } +} diff --git a/codechef/Math1Enrolment/main_input0.txt b/codechef/Math1Enrolment/main_input0.txt new file mode 100644 index 0000000..2786035 --- /dev/null +++ b/codechef/Math1Enrolment/main_input0.txt @@ -0,0 +1,5 @@ +4 +1 1 +12 34 +50 49 +49 50 diff --git a/codechef/Math1Enrolment/main_output0.txt b/codechef/Math1Enrolment/main_output0.txt new file mode 100644 index 0000000..93edea2 --- /dev/null +++ b/codechef/Math1Enrolment/main_output0.txt @@ -0,0 +1,4 @@ +0 +22 +0 +1 diff --git a/codechef/MaximumWeightDifference/main b/codechef/MaximumWeightDifference/main new file mode 100755 index 0000000..e5ce1f4 Binary files /dev/null and b/codechef/MaximumWeightDifference/main differ diff --git a/codechef/MaximumWeightDifference/main.cpp b/codechef/MaximumWeightDifference/main.cpp new file mode 100644 index 0000000..751084c --- /dev/null +++ b/codechef/MaximumWeightDifference/main.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +int sum(vector &v, int start, int end) { + int sum = 0; + for(int i = start; i < end; i++) { + sum += v[i]; + } + return sum; +} + + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n, k; + cin >> n >> k; + vector v(n); + for (int &x : v) + cin >> x; + sort(v.begin(), v.end()); + if(n == 1) { + cout << v[0]; + } else { + cout << sum(v, k, v.size()) - sum(v, 0, k) << endl; + } + } +} diff --git a/codechef/MaximumWeightDifference/main_input0.txt b/codechef/MaximumWeightDifference/main_input0.txt new file mode 100644 index 0000000..89c2c4e --- /dev/null +++ b/codechef/MaximumWeightDifference/main_input0.txt @@ -0,0 +1,5 @@ +2 +5 2 +8 4 5 2 10 +8 3 +1 1 1 1 1 1 1 1 diff --git a/codechef/MaximumWeightDifference/main_output0.txt b/codechef/MaximumWeightDifference/main_output0.txt new file mode 100644 index 0000000..f1f71f3 --- /dev/null +++ b/codechef/MaximumWeightDifference/main_output0.txt @@ -0,0 +1,2 @@ +17 +2 diff --git a/codechef/RacingHorses/main b/codechef/RacingHorses/main new file mode 100755 index 0000000..a071dd7 Binary files /dev/null and b/codechef/RacingHorses/main differ diff --git a/codechef/RacingHorses/main.cpp b/codechef/RacingHorses/main.cpp new file mode 100644 index 0000000..1da09f4 --- /dev/null +++ b/codechef/RacingHorses/main.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + vector v(n); + for(int &x : v) cin >> x; + sort(v.begin(), v.end()); + int mn = 1e9; + for(int i = 0; i < n - 1; i++) { + mn = min(mn, abs(v[i] - v[i + 1])); + } + cout << mn << endl; + } +} diff --git a/codechef/RacingHorses/main_input0.txt b/codechef/RacingHorses/main_input0.txt new file mode 100644 index 0000000..3142f24 --- /dev/null +++ b/codechef/RacingHorses/main_input0.txt @@ -0,0 +1,3 @@ +1 +5 +4 9 1 32 13 \ No newline at end of file diff --git a/codechef/RacingHorses/main_output0.txt b/codechef/RacingHorses/main_output0.txt new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/codechef/RacingHorses/main_output0.txt @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/codechef/SnakeProcession/inp b/codechef/SnakeProcession/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/SnakeProcession/main b/codechef/SnakeProcession/main new file mode 100755 index 0000000..08fed83 Binary files /dev/null and b/codechef/SnakeProcession/main differ diff --git a/codechef/SnakeProcession/main.cpp b/codechef/SnakeProcession/main.cpp new file mode 100644 index 0000000..cad706e --- /dev/null +++ b/codechef/SnakeProcession/main.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + string s; + cin >> s; + bool ans = regex_match(s, regex("(\\.*H\\.*T\\.*)*|(\\.*)")); + cout << (ans ? "Valid" : "Invalid") << endl; + } +} diff --git a/codechef/SnakeProcession/main_input0.txt b/codechef/SnakeProcession/main_input0.txt new file mode 100644 index 0000000..54c49dc --- /dev/null +++ b/codechef/SnakeProcession/main_input0.txt @@ -0,0 +1,13 @@ +6 +18 +..H..T...HTH....T. +3 +... +10 +H..H..T..T +2 +HT +11 +.T...H..H.T +7 +H..T..H diff --git a/codechef/SnakeProcession/main_output0.txt b/codechef/SnakeProcession/main_output0.txt new file mode 100644 index 0000000..cde65af --- /dev/null +++ b/codechef/SnakeProcession/main_output0.txt @@ -0,0 +1,6 @@ +Valid +Valid +Invalid +Valid +Invalid +Invalid diff --git a/codechef/SortTheString/main b/codechef/SortTheString/main new file mode 100755 index 0000000..a79a94a Binary files /dev/null and b/codechef/SortTheString/main differ diff --git a/codechef/SortTheString/main.cpp b/codechef/SortTheString/main.cpp new file mode 100644 index 0000000..8a9897e --- /dev/null +++ b/codechef/SortTheString/main.cpp @@ -0,0 +1,24 @@ +#include +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + string s; + cin >> s; + if(is_sorted(s.begin(), s.end())) { + cout << "0" << endl; + } else if (regex_search(s.begin(), s.end(), regex("(10)"))) { + cout << "2" << endl; + } else { + cout << "1" << endl; + } + } +} diff --git a/codechef/SortTheString/main_input0.txt b/codechef/SortTheString/main_input0.txt new file mode 100644 index 0000000..6f6009d --- /dev/null +++ b/codechef/SortTheString/main_input0.txt @@ -0,0 +1,9 @@ +4 +3 +000 +4 +1001 +4 +1010 +6 +010101 diff --git a/codechef/SortTheString/main_output0.txt b/codechef/SortTheString/main_output0.txt new file mode 100644 index 0000000..1b9ba74 --- /dev/null +++ b/codechef/SortTheString/main_output0.txt @@ -0,0 +1,4 @@ +0 +1 +2 +2 diff --git a/codechef/StudyingAlphabet/inp b/codechef/StudyingAlphabet/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/StudyingAlphabet/main b/codechef/StudyingAlphabet/main new file mode 100755 index 0000000..a989381 Binary files /dev/null and b/codechef/StudyingAlphabet/main differ diff --git a/codechef/StudyingAlphabet/main.cpp b/codechef/StudyingAlphabet/main.cpp new file mode 100644 index 0000000..1eb9622 --- /dev/null +++ b/codechef/StudyingAlphabet/main.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + string s; + cin >> s; + int n; + cin >> n; + while(n--) { + string word; + cin >> word; + bool ok = 1; + for(auto ch : word) { + int found = s.find(ch); + if(found == string::npos) { + ok = 0; + break; + } + } + cout << (ok ? "Yes" : "No") << endl; + } +} diff --git a/codechef/StudyingAlphabet/main_input0.txt b/codechef/StudyingAlphabet/main_input0.txt new file mode 100644 index 0000000..29753ef --- /dev/null +++ b/codechef/StudyingAlphabet/main_input0.txt @@ -0,0 +1,4 @@ +act +2 +cat +dog diff --git a/codechef/StudyingAlphabet/main_output0.txt b/codechef/StudyingAlphabet/main_output0.txt new file mode 100644 index 0000000..7ae3bc8 --- /dev/null +++ b/codechef/StudyingAlphabet/main_output0.txt @@ -0,0 +1,2 @@ +Yes +No diff --git a/codechef/TheSmallestPair/main b/codechef/TheSmallestPair/main new file mode 100755 index 0000000..08ae671 Binary files /dev/null and b/codechef/TheSmallestPair/main differ diff --git a/codechef/TheSmallestPair/main.cpp b/codechef/TheSmallestPair/main.cpp new file mode 100644 index 0000000..7b77a41 --- /dev/null +++ b/codechef/TheSmallestPair/main.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + vector v(n); + for(int& x : v) cin >> x; + sort(v.begin(), v.end()); + cout << v[0] + v[1] << endl; + } +} diff --git a/codechef/TheSmallestPair/main_input0.txt b/codechef/TheSmallestPair/main_input0.txt new file mode 100644 index 0000000..ab88d90 --- /dev/null +++ b/codechef/TheSmallestPair/main_input0.txt @@ -0,0 +1,3 @@ +1 +4 +5 1 3 4 diff --git a/codechef/TheSmallestPair/main_output0.txt b/codechef/TheSmallestPair/main_output0.txt new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/codechef/TheSmallestPair/main_output0.txt @@ -0,0 +1 @@ +4 diff --git a/codechef/countingWords/main b/codechef/countingWords/main new file mode 100755 index 0000000..418459e Binary files /dev/null and b/codechef/countingWords/main differ diff --git a/codechef/countingWords/main.cpp b/codechef/countingWords/main.cpp new file mode 100644 index 0000000..b205754 --- /dev/null +++ b/codechef/countingWords/main.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, m; + cin >> n >> m; + cout << n * m << endl; + } +} diff --git a/codechef/countingWords/main_input0.txt b/codechef/countingWords/main_input0.txt new file mode 100644 index 0000000..18e52b9 --- /dev/null +++ b/codechef/countingWords/main_input0.txt @@ -0,0 +1,5 @@ +4 +1 1 +4 2 +2 4 +95 42 diff --git a/codechef/countingWords/main_output0.txt b/codechef/countingWords/main_output0.txt new file mode 100644 index 0000000..fbde8c0 --- /dev/null +++ b/codechef/countingWords/main_output0.txt @@ -0,0 +1,4 @@ +1 +8 +8 +3990 diff --git a/codechef/groupAssignment/main b/codechef/groupAssignment/main new file mode 100755 index 0000000..78e325a Binary files /dev/null and b/codechef/groupAssignment/main differ diff --git a/codechef/groupAssignment/main.cpp b/codechef/groupAssignment/main.cpp new file mode 100644 index 0000000..0cb4e4e --- /dev/null +++ b/codechef/groupAssignment/main.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + unordered_map mp; + for(int i = 0; i < n; i++) { + int x; + cin >> x; + mp[x]++; + } + bool ok = true; + for(auto p : mp) { + cerr << p.first << endl; + } + for(auto p : mp) { + if(p.second % p.first != 0) { + ok = false; + break; + } + } + if(ok) { + cout << "YES" << endl; + } else { + cout << "NO" << endl; + } + } +} diff --git a/codechef/groupAssignment/main_input0.txt b/codechef/groupAssignment/main_input0.txt new file mode 100644 index 0000000..35e495a --- /dev/null +++ b/codechef/groupAssignment/main_input0.txt @@ -0,0 +1,9 @@ +4 +5 +2 3 2 3 3 +5 +5 5 5 5 5 +5 +3 2 2 3 2 +4 +4 4 4 3 diff --git a/codechef/groupAssignment/main_input1.txt b/codechef/groupAssignment/main_input1.txt new file mode 100644 index 0000000..15126fd --- /dev/null +++ b/codechef/groupAssignment/main_input1.txt @@ -0,0 +1,9 @@ +4 +4 +3 3 3 2 +8 +4 4 4 4 3 3 3 2 +10 +5 5 5 5 5 3 3 3 2 2 +6 +4 4 4 4 2 2 diff --git a/codechef/groupAssignment/main_input2.txt b/codechef/groupAssignment/main_input2.txt new file mode 100644 index 0000000..7225581 --- /dev/null +++ b/codechef/groupAssignment/main_input2.txt @@ -0,0 +1,3 @@ +1 +2 +3 3 \ No newline at end of file diff --git a/codechef/groupAssignment/main_input3.txt b/codechef/groupAssignment/main_input3.txt new file mode 100644 index 0000000..ab091ac --- /dev/null +++ b/codechef/groupAssignment/main_input3.txt @@ -0,0 +1,3 @@ +1 +3 +3 3 3 \ No newline at end of file diff --git a/codechef/groupAssignment/main_input4.txt b/codechef/groupAssignment/main_input4.txt new file mode 100644 index 0000000..29be96d --- /dev/null +++ b/codechef/groupAssignment/main_input4.txt @@ -0,0 +1,11 @@ +5 +2 +2 2 +4 +4 4 4 4 +12 +6 6 6 6 6 6 3 3 3 2 2 3 +13 +5 2 2 5 5 5 6 6 6 6 6 6 5 +17 +11 11 11 11 11 11 11 11 11 11 11 6 6 6 6 6 6 \ No newline at end of file diff --git a/codechef/groupAssignment/main_output0.txt b/codechef/groupAssignment/main_output0.txt new file mode 100644 index 0000000..c322bb3 --- /dev/null +++ b/codechef/groupAssignment/main_output0.txt @@ -0,0 +1,4 @@ +YES +YES +NO +NO diff --git a/codechef/groupAssignment/main_output1.txt b/codechef/groupAssignment/main_output1.txt new file mode 100644 index 0000000..8d6a870 --- /dev/null +++ b/codechef/groupAssignment/main_output1.txt @@ -0,0 +1,4 @@ +NO +NO +YES +YES \ No newline at end of file diff --git a/codechef/groupAssignment/main_output2.txt b/codechef/groupAssignment/main_output2.txt new file mode 100644 index 0000000..ba28208 --- /dev/null +++ b/codechef/groupAssignment/main_output2.txt @@ -0,0 +1 @@ +NO \ No newline at end of file diff --git a/codechef/groupAssignment/main_output3.txt b/codechef/groupAssignment/main_output3.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/codechef/groupAssignment/main_output3.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/codechef/groupAssignment/main_output4.txt b/codechef/groupAssignment/main_output4.txt new file mode 100644 index 0000000..71285b6 --- /dev/null +++ b/codechef/groupAssignment/main_output4.txt @@ -0,0 +1,5 @@ +YES +YES +NO +YES +YES \ No newline at end of file -- cgit v1.2.3