Skip to content
Open
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
36 changes: 32 additions & 4 deletions exercise.main/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@
namespace exercise.main
{
public class Core
{
{
private Dictionary<string, int> _cardValues = new Dictionary<string, int>
{
{"1",1},
{"2",2},
{"3",3},
{"4",4},
{"5",5},
{"6",6},
{"7",7},
{"8",8 },
{"9",9},
{"10",10},
{"J",11},
{"Q",12},
{"K",13},
{"A",14}
};

// Note:
// IEnumerable is a class that the List inherits (ie List has all the functionality of IEnumerable)
Expand All @@ -19,14 +36,25 @@ 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 bestScore = 0;

// your code here...
foreach (var hand in hands)
{
if (hand.Item1 == hand.Item2)
{
if (GetValueOfCard(hand.Item1) > bestScore)
{
result = hand;
bestScore = GetValueOfCard(hand.Item1);
}
}
}

return result.Item1!=string.Empty ? true : false;
return result.Item1 != string.Empty ? true : false;
}
public int GetValueOfCard(string card)
{
return 0;
return _cardValues[card];
}
}
}