svetlozar_kirkov

Poker Straight (100/100)

Oct 29th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PokerStraight
  4. {
  5.     class PokerStraight
  6.     {
  7.         static void Main()
  8.         {
  9.             int targetWeight = int.Parse(Console.ReadLine());
  10.             string[] cardRanks = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
  11.             int[] cardFacesWeights = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
  12.             int[] cardSuitsWeights = {1, 2, 3, 4};
  13.             int count = 0;
  14.  
  15.             for (int i = 0; i < cardRanks.Length-4; i++)
  16.             {
  17.                 for (int j = 0; j < 4; j++)
  18.                 {
  19.                     for (int k = 0; k < 4; k++)
  20.                     {
  21.                         for (int l = 0; l < 4; l++)
  22.                         {
  23.                             for (int m = 0; m < 4; m++)
  24.                             {
  25.                                 for (int n = 0; n < 4; n++)
  26.                                 {
  27.                                     int tempWeight = 10*cardFacesWeights[i] + cardSuitsWeights[j] +
  28.                                                      20*cardFacesWeights[i + 1] + cardSuitsWeights[k] +
  29.                                                      30*cardFacesWeights[i + 2] + cardSuitsWeights[l] +
  30.                                                      40*cardFacesWeights[i + 3] + cardSuitsWeights[m] +
  31.                                                      50*cardFacesWeights[i + 4] + cardSuitsWeights[n];
  32.                                     if (tempWeight==targetWeight)
  33.                                     {
  34.                                         count++;
  35.                                     }
  36.                                 }
  37.                             }
  38.                         }
  39.                     }
  40.                 }
  41.             }
  42.  
  43.             Console.WriteLine(count);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment