diff options
author | dzwdz | 2022-12-02 12:34:58 +0100 |
---|---|---|
committer | dzwdz | 2022-12-02 12:34:58 +0100 |
commit | 9e603f3d65f2a32fdf94a0ed66c7bd408a82f0bb (patch) | |
tree | 711fa0b2485b3f4ceed81760dbeaa54401d00af2 /22.2 | |
parent | dbc42a5a231f3ffd18af571d8b358735a1f831f1 (diff) |
day 2 part 1
Diffstat (limited to '22.2')
-rw-r--r-- | 22.2/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/22.2/main.cpp b/22.2/main.cpp new file mode 100644 index 0000000..0ab6017 --- /dev/null +++ b/22.2/main.cpp @@ -0,0 +1,20 @@ +#include <cstdio> +using namespace std; + +int +main() +{ + char move, res; + long total = 0; + while (scanf("%c %c ", &move, &res) == 2) { + move -= 'A'; + res -= 'X'; + if (!(0 <= move && move < 3)) throw "bad input"; + if (!(0 <= res && res < 3)) throw "bad input"; + + int outcome = (res - move + 4) % 3; /* 0 loss, 1 draw, 2 win */ + long score = outcome * 3 + res + 1; + total += score; + } + printf("%ld\n", total); +} |