Advertisement
simeon_stoykov

Problem 4 - Weird Combinations

Nov 10th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 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. class Problem4
  8. {
  9.     static void Main()
  10.     {
  11.         string inputToTake = Console.ReadLine();
  12.         int n = int.Parse(Console.ReadLine());
  13.         int counter = -1;
  14.         string neededString = String.Empty;
  15.  
  16.         char [] input = inputToTake.ToCharArray();
  17.  
  18.         for (int d1 = 0; d1 < input.Length; d1++)
  19.         {
  20.             for (int d2 = 0; d2 < input.Length; d2++)
  21.             {
  22.                 for (int d3 = 0; d3 < input.Length; d3++)
  23.                 {
  24.                     for (int d4 = 0; d4 < input.Length; d4++)
  25.                     {
  26.                         for (int d5 = 0; d5 < input.Length; d5++)
  27.                         {
  28.                             string combination = input[d1].ToString() + input[d2] + input[d3] + input[d4] + input[d5];
  29.                             counter++;
  30.                             if (counter == n)
  31.                             {
  32.                                 neededString = combination;
  33.                             }
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.  
  40.         if (neededString == String.Empty)
  41.         {
  42.             Console.WriteLine("No");
  43.         }
  44.         else
  45.         {
  46.             Console.WriteLine(neededString);
  47.         }      
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement