Skip to content

Commit

Permalink
Add Day 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchay9 committed Dec 2, 2022
1 parent 503be01 commit 57b1bc9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
31 changes: 31 additions & 0 deletions day2/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;

#define int long long

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);

int ans = 0;

char a, b;
while (cin >> a >> b) {
ans += b - 'X' + 1;

if (b - 'X' == a - 'A') {
ans += 3;
}

if ((b == 'X' && a == 'C') || (b == 'Y' && a == 'A') || (b == 'Z' && a == 'B')) {
ans += 6;
}
}

cout << ans << '\n';
}
37 changes: 37 additions & 0 deletions day2/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <bits/stdc++.h>
using namespace std;

#define int long long

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);

int ans = 0;

char a, b;
while (cin >> a >> b) {
if (b == 'Y') {
ans += 3;

ans += a - 'A' + 1;
} else if (b == 'X') {
if (a == 'A') ans += 3;
if (a == 'B') ans += 1;
if (a == 'C') ans += 2;
} else {
ans += 6;

if (a == 'A') ans += 2;
if (a == 'B') ans += 3;
if (a == 'C') ans += 1;
}
}

cout << ans << '\n';
}

0 comments on commit 57b1bc9

Please sign in to comment.