fbinnzhivko

04.01 Poker Straight

Apr 15th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. class PokerStraight
  3. {
  4.     static void Main()
  5.     {
  6.         int targetWeight = int.Parse(Console.ReadLine());
  7.         int[] faces = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
  8.         int[] suits = { 1, 2, 3, 4 };
  9.         int weight = 0;
  10.         int counter = 0;
  11.  
  12.         for (int i = 0; i < faces.Length - 4; i++)
  13.         {
  14.             for (int s1 = 0; s1 < 4; s1++)
  15.             {
  16.                 for (int s2 = 0; s2 < 4; s2++)
  17.                 {
  18.                     for (int s3 = 0; s3 < 4; s3++)
  19.                     {
  20.                         for (int s4 = 0; s4 < 4; s4++)
  21.                         {
  22.                             for (int s5 = 0; s5 < 4; s5++)
  23.                             {
  24.                                 weight = (10 * faces[i] + suits[s1]) + (20 * faces[i + 1] + suits[s2])
  25.                                    + (30 * faces[i + 2] + suits[s3]) + (40 * faces[i + 3] + suits[s4])
  26.                                    + (50 * faces[i + 4] + suits[s5]);
  27.  
  28.                                 if (weight == targetWeight)
  29.                                 {
  30.                                     counter++;
  31.                                 }
  32.                             }
  33.                         }
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.         Console.WriteLine(counter);
  39.     }
  40. }
Add Comment
Please, Sign In to add comment