Advertisement
mellowdeep

Poker Straight

Jan 3rd, 2016
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PokerStraight
  8. {
  9.     class PokerStraight
  10.     {
  11.         public static int result = 0;
  12.         static void Main()
  13.         {
  14.             int weight = int.Parse(Console.ReadLine());
  15.  
  16.             int[] face = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
  17.             int[] suit = new int[] {1, 2, 3, 4};
  18.  
  19.             for (int clubs = 0; clubs < 4; clubs++)
  20.             {
  21.                 for (int diamonds = 0; diamonds < 4; diamonds++)
  22.                 {
  23.                     for (int hearts = 0; hearts < 4; hearts++)
  24.                     {
  25.                         for (int spades = 0; spades < 4; spades++)
  26.                         {
  27.                             for (int lastCardSuit = 0; lastCardSuit < 4; lastCardSuit++)
  28.                             {
  29.                                CalculateWeight(face, weight, suit[clubs], suit[diamonds],
  30.                                                suit[hearts], suit[spades],suit[lastCardSuit]);
  31.                             }
  32.                            
  33.                         }
  34.                     }
  35.                 }
  36.             }
  37.           Console.WriteLine(result);
  38.         }
  39.  
  40.         private static void CalculateWeight(int[] face, int weight,int clubs, int diamond, int hearts, int spades, int lastCardSuit)
  41.         {
  42.             for (int cardIndex = 0; cardIndex < face.Length - 4; cardIndex++)
  43.             {
  44.                 int getWeight = (10 * face[cardIndex] + clubs) + (20 * face[cardIndex+1] + diamond) + (30 * face[cardIndex+2] + hearts)
  45.                               + (40 * face[cardIndex+3] + spades) + (50 * face[cardIndex+4] + lastCardSuit);
  46.                 result = getWeight == weight ? result += 1 : result;
  47.             }
  48.          
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement