Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication6
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string[] input = Console.ReadLine().Split(' ');
- List<List<string>> subsetGood = new List<List<string>>();
- double combinations = Math.Pow(2, n);
- for (int i = 0; i < combinations; i++)
- {
- int counter = 0;
- List<string> subset = new List<string>();
- for (int bitPosition = 0; bitPosition < n; bitPosition++)
- {
- if ((i & (1 << bitPosition)) != 0)
- {
- subset.Add(input[bitPosition]);
- counter++;
- } // if bitPosition
- }// bitwise for
- if (counter == 4)
- {
- subsetGood.Add(subset);
- }
- }// for with combinations
- foreach (var list in subsetGood)
- {
- List<List<string>> subsetTwoElementsGood = new List<List<string>>();
- double newCombinations = Math.Pow(2, 4);
- for (int i = 0; i < newCombinations; i++)
- {
- List<string> subset = new List<string>();
- int counter = 0;
- for (int bitPosition = 0; bitPosition < 4; bitPosition++)
- {
- if ((i & (1 << bitPosition)) != 0)
- {
- subset.Add(list[bitPosition]);
- counter++;
- }
- }// for bitPosition2
- if (counter == 2)
- {
- subsetTwoElementsGood.Add(subset);
- }// if counter = 2
- }// for new Combinations
- for (int p = 0; p < subsetTwoElementsGood.Count; p++)
- {
- List<string> subset = new List<string>();
- int checkFirstTwo = 0;
- int checkSecondTwo = 0;
- for (int check = 0; check < subsetTwoElementsGood.Count; check++)
- {
- if (check == p)
- {
- continue;
- }
- else
- {
- checkFirstTwo = int.Parse(subsetTwoElementsGood[p][0] + subsetTwoElementsGood[p][1]);
- checkSecondTwo = int.Parse(subsetTwoElementsGood[check][0] + subsetTwoElementsGood[check][1]);
- if ((checkFirstTwo == checkSecondTwo) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][1]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][1]))
- {
- Console.WriteLine("{0}|{1}={2}|{3}", subsetTwoElementsGood[p][0], subsetTwoElementsGood[p][1], subsetTwoElementsGood[check][0], subsetTwoElementsGood[check][1]);
- }
- else
- {
- checkFirstTwo = int.Parse(subsetTwoElementsGood[p][1] + subsetTwoElementsGood[p][0]);
- checkSecondTwo = int.Parse(subsetTwoElementsGood[check][0] + subsetTwoElementsGood[check][1]);
- if ((checkFirstTwo == checkSecondTwo) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][1]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][1]))
- {
- Console.WriteLine("{0}|{1}={2}|{3}", subsetTwoElementsGood[p][1], subsetTwoElementsGood[p][0], subsetTwoElementsGood[check][0], subsetTwoElementsGood[check][1]);
- }
- else
- {
- checkFirstTwo = int.Parse(subsetTwoElementsGood[p][1] + subsetTwoElementsGood[p][0]);
- checkSecondTwo = int.Parse(subsetTwoElementsGood[check][1] + subsetTwoElementsGood[check][0]);
- if ((checkFirstTwo == checkSecondTwo) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][1]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][1]))
- {
- Console.WriteLine("{0}|{1}={2}|{3}", subsetTwoElementsGood[p][1], subsetTwoElementsGood[p][0], subsetTwoElementsGood[check][1], subsetTwoElementsGood[check][0]);
- }
- else
- {
- checkFirstTwo = int.Parse(subsetTwoElementsGood[p][0] + subsetTwoElementsGood[p][1]);
- checkSecondTwo = int.Parse(subsetTwoElementsGood[check][1] + subsetTwoElementsGood[check][0]);
- if ((checkFirstTwo == checkSecondTwo) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][0] != subsetTwoElementsGood[check][1]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][0]) && (subsetTwoElementsGood[p][1] != subsetTwoElementsGood[check][1]))
- {
- Console.WriteLine("{0}|{1}={2}|{3}", subsetTwoElementsGood[p][0], subsetTwoElementsGood[p][1], subsetTwoElementsGood[check][1], subsetTwoElementsGood[check][0]);
- }
- }
- }
- }
- }
- }
- }
- }// foreach
- //subsetTwoElementsGood.ForEach(t => Console.WriteLine(string.Join("..", t)));
- }
- }
- }
- // Ugly
Advertisement
Add Comment
Please, Sign In to add comment