Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. public bool IsThreeOfAKind(IHand hand)
  2.         {
  3.             if (!IsValidHand(hand))
  4.             {
  5.                 return false;
  6.             }
  7.  
  8.             bool result = hand.Cards
  9.                                     .GroupBy(x => x.Face)
  10.                                     .Any(x => x.Count() == ValidIsThreeOfAKindGroupCount);
  11.  
  12.             return result;
  13.         }
  14.  
  15. public bool IsTwoPair(IHand hand)
  16.         {
  17.             if (!IsValidHand(hand))
  18.             {
  19.                 return false;
  20.             }
  21.            
  22.             int differentCardsFacesCount = hand.Cards.GroupBy(x => x.Face).Count();
  23.  
  24.             bool result = differentCardsFacesCount == ValidIsTwoPairGroupCount;
  25.  
  26.             return result;
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement