Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions exercise.main/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,56 @@ public class Core
public bool winningPair(IEnumerable<Tuple<string, string>> hands, out Tuple<string, string> result)
{
result = new Tuple<string,string>(string.Empty, string.Empty);
int highestWinnerPairValue = 0;

// your code here...
foreach (var pair in hands)
{
var score = GetValueOfCard(pair.Item1) + GetValueOfCard(pair.Item2);

if (pair.Item1 == pair.Item2 && score > highestWinnerPairValue)
{
result = new Tuple<string, string>(pair.Item1, pair.Item2);
highestWinnerPairValue = score;
}
}

return result.Item1!=string.Empty ? true : false;
}
public int GetValueOfCard(string card)
{
return 0;
switch (card)
{
case "1":
return 1;
case "2":
return 2;
case "3":
return 3;
case "4":
return 4;
case "5":
return 5;
case "6":
return 6;
case "7":
return 7;
case "8":
return 8;
case "9":
return 9;
case "10":
return 10;
case "J":
return 11;
case "Q":
return 12;
case "K":
return 13;
case "A":
return 14;
default:
return 0;
}
}
}
}
49 changes: 49 additions & 0 deletions exercise.main/Extension.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -12,9 +13,57 @@ public class Extension
public bool winningThree(IEnumerable<Tuple<string, string, string>> hand, out Tuple<string, string, string> result)
{
result = new Tuple<string, string, string>(string.Empty, string.Empty, string.Empty);
int highestWinnerPairValue = 0;

foreach (var pair in hand)
{
var score = GetValueOfCard(pair.Item1) + GetValueOfCard(pair.Item2);

if (pair.Item1 == pair.Item2 && pair.Item2 == pair.Item3 && score > highestWinnerPairValue)
{
result = new Tuple<string, string, string>(pair.Item1, pair.Item2, pair.Item3);
highestWinnerPairValue = score;
}
}

return false;
}

public int GetValueOfCard(string card)
{
switch (card)
{
case "1":
return 1;
case "2":
return 2;
case "3":
return 3;
case "4":
return 4;
case "5":
return 5;
case "6":
return 6;
case "7":
return 7;
case "8":
return 8;
case "9":
return 9;
case "10":
return 10;
case "J":
return 11;
case "Q":
return 12;
case "K":
return 13;
case "A":
return 14;
default:
return 0;
}
}
}
}
Loading