Skip to content

Reload the Code Gun - Contest Solutions #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Contests/Codechef/Reload the Code Gun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# **Reload the Code Gun**

This coding contest was based on algorithms, data structures and problem solving.

**Duration**: 30 minutes
**Start time**: 26th December 2020, 18:30 hrs IST
**End time**: 26th December 2020, 19:00 hrs IST

Here is the [link](https://www.codechef.com/RTCG2020?itm_campaign=contest_listing) to the contest.

### **Problems:**
- Factor Count in a Number ([RTCG001](https://www.codechef.com/RTCG2020/problems/RTCG001)\)
- Burn Calories, no kidding! ([RTCG002](https://www.codechef.com/RTCG2020/problems/RTCG002)\)
- Hamming Distance ([RTCG003](https://www.codechef.com/RTCG2020/problems/RTCG003)\)
- Mias Essay Paper ([RTCG004](https://www.codechef.com/RTCG2020/problems/RTCG004)\)


### **Editorials:** N.A.
29 changes: 29 additions & 0 deletions Contests/Codechef/Reload the Code Gun/RTCG001.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
cin.tie(NULL);

int T;
cin >> T;
while(T--) {
string N;
cin >> N;

int num = stoi(N);
int ans = 0;

for (int i=0; i<N.size(); i++) {
if (N[i]!='0' && num%(N[i]-'0')==0)
ans++;
}
cout << ans << "\n";
}
return 0;
}
38 changes: 38 additions & 0 deletions Contests/Codechef/Reload the Code Gun/RTCG002.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <map>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
cin.tie(NULL);

map<char, int> mp;
mp['D'] = 238;
mp['T'] = 244;
mp['M'] = 138;
mp['B'] = 279;
mp['C'] = 186;

string S;
cin >> S;

int cal = 0;
for (int i=0; i<S.size(); i++)
cal += mp[S[i]];

cout << cal/50 << "\n";

cal = cal - (cal/50)*50;

cout << cal/5 << "\n";

cal = cal - (cal/5)*5;

cout << 2*cal << "\n";
return 0;
}
23 changes: 23 additions & 0 deletions Contests/Codechef/Reload the Code Gun/RTCG003.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
cin.tie(NULL);

string S, T;
cin >> S >> T;

int ans = 0;
for (int i=0; i<S.size(); i++)
if (S[i]!=T[i])
ans++;

cout << ans << "\n";
return 0;
}
28 changes: 28 additions & 0 deletions Contests/Codechef/Reload the Code Gun/RTCG004.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
cin.tie(NULL);

int T;
cin >> T;

while (T--) {
string S;
cin >> S;

int ans = 0;
int n = S.size();
for (int i=0; i<n/2; i++) {
ans += abs(S[i]-S[n-i-1]);
}
cout << ans << "\n";
}
return 0;
}
1 change: 1 addition & 0 deletions Contribution.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# These Are The Contributors for this Repository

- ## [Vinayak Mohite](https://github.com/VinayakMohite4040)
- ## [Yash Shukla](https://github.com/Yash1256)
- ## [Kaushik Rishi](https://github.com/kaushik-rishi)
- ## [Chandra Kiran G](https://github.com/Chandu-4444)
Expand Down