Created
June 24, 2020 14:15
-
-
Save aksnell/09fbaac011982e103420dfe923785721 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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