Skip to content

Instantly share code, notes, and snippets.

@aksnell
Created June 24, 2020 14:15
Show Gist options
  • Save aksnell/09fbaac011982e103420dfe923785721 to your computer and use it in GitHub Desktop.
Save aksnell/09fbaac011982e103420dfe923785721 to your computer and use it in GitHub Desktop.
using namespace std;
string alphabetWar(string fight) {
const string left = "sbpw";
const string right = "zdqm";
int left_score = 0;
int right_score = 0;
for (int i = 0; i < fight.length(); i++) {
if (fight[i] == '*' || fight[i+1] == '*' || fight[i-1] == '*') continue;
else {
for (int x = 0; x < 4; x++) {
if (left[x] == fight[i]) left_score += x+1;
else if (right[x] == fight[i]) right_score += x+1;
}
}
}
if (left_score > right_score) return "Left side wins!";
else if (right_score > left_score) return "Right side wins!";
else return "Let's fight again!";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment