Skip to content

Instantly share code, notes, and snippets.

@grim-yawn
Created December 29, 2016 21:48
Show Gist options
  • Select an option

  • Save grim-yawn/d7c88ed863f398b51ba511c19df23718 to your computer and use it in GitHub Desktop.

Select an option

Save grim-yawn/d7c88ed863f398b51ba511c19df23718 to your computer and use it in GitHub Desktop.
#include <array>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
class Triplet
{
public:
static Triplet read_triplet_from_stdin()
{
Triplet triplet;
for (auto & el: triplet.triplet) {
std::cin >> el;
}
return triplet;
}
std::pair<int, int> compute_scores( const Triplet & other)
{
std::pair<int, int> res{0, 0};
for (int i = 0; i < 3; ++i) {
if (triplet[i] > other.triplet[i]) {
res.first++;
} else if (triplet[i] < other.triplet[i]){
res.second++;
}
}
return res;
}
private:
Triplet() = default;
std::array<int, 3> triplet;
};
int main() {
auto alice = Triplet::read_triplet_from_stdin();
auto bob = Triplet::read_triplet_from_stdin();
auto res = alice.compute_scores(bob);
std::cout << res.first << ' ' << res.second << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment