Skip to content

Instantly share code, notes, and snippets.

@rodrigoramirez93
Created May 19, 2017 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigoramirez93/5940277d204adace36d2081071fb41ea to your computer and use it in GitHub Desktop.
Save rodrigoramirez93/5940277d204adace36d2081071fb41ea to your computer and use it in GitHub Desktop.
Compare the triplets @ HackerRank // C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static int[] solve(int a0, int a1, int a2, int b0, int b1, int b2)
{
int[] tripletAlice = { a0, a1, a2 };
int[] tripletBob = { b0, b1, b2 };
int alice = 0;
int bob = 0;
for (int i = 0; i < tripletAlice.Length; i++ )
{
if (tripletAlice[i] > tripletBob[i])
{
alice++;
}
else if (tripletAlice[i] < tripletBob[i])
{
bob++;
}
}
int[] result = { alice, bob };
return result;
}
static void Main(String[] args)
{
string[] tokens_a0 = Console.ReadLine().Split(' ');
int a0 = Convert.ToInt32(tokens_a0[0]);
int a1 = Convert.ToInt32(tokens_a0[1]);
int a2 = Convert.ToInt32(tokens_a0[2]);
string[] tokens_b0 = Console.ReadLine().Split(' ');
int b0 = Convert.ToInt32(tokens_b0[0]);
int b1 = Convert.ToInt32(tokens_b0[1]);
int b2 = Convert.ToInt32(tokens_b0[2]);
int[] result = solve(a0, a1, a2, b0, b1, b2);
Console.WriteLine(String.Join(" ", result));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment