Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MissingPermutation
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
string[] given = new string[] { "ABCD", "CABD", "ACDB", "DACB",
|
||||
"BCDA", "ACBD", "ADCB", "CDAB",
|
||||
"DABC", "BCAD", "CADB", "CDBA",
|
||||
"CBAD", "ABDC", "ADBC", "BDCA",
|
||||
"DCBA", "BACD", "BADC", "BDAC",
|
||||
"CBDA", "DBCA", "DCAB" };
|
||||
|
||||
List<string> result = new List<string>();
|
||||
permuteString(ref result, "", "ABCD");
|
||||
|
||||
foreach (string a in result)
|
||||
if (Array.IndexOf(given, a) == -1)
|
||||
Console.WriteLine(a + " is a missing Permutation");
|
||||
}
|
||||
|
||||
public static void permuteString(ref List<string> result, string beginningString, string endingString)
|
||||
{
|
||||
if (endingString.Length <= 1)
|
||||
{
|
||||
result.Add(beginningString + endingString);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < endingString.Length; i++)
|
||||
{
|
||||
string newString = endingString.Substring(0, i) + endingString.Substring(i + 1);
|
||||
permuteString(ref result, beginningString + (endingString.ToCharArray())[i], newString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var input = new [] {"ABCD","CABD","ACDB","DACB","BCDA",
|
||||
"ACBD","ADCB","CDAB","DABC","BCAD","CADB",
|
||||
"CDBA","CBAD","ABDC","ADBC","BDCA","DCBA",
|
||||
"BACD","BADC","BDAC","CBDA","DBCA","DCAB"};
|
||||
|
||||
int[] values = {0,0,0,0};
|
||||
foreach (string s in input)
|
||||
for (int i = 0; i < 4; i++)
|
||||
values[i] ^= s[i];
|
||||
Console.WriteLine(string.Join("", values.Select(i => (char)i)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue