Jump to content

Find the missing permutation: Difference between revisions

Added a new C# implementation
m (→‎{{header|Phix}}: explained smallest(count,1))
(Added a new C# implementation)
Line 314:
 
=={{header|C sharp|C#}}==
===By permutating===
{{works with|C sharp|C#|2+}}
 
<lang csharp>using System;
using System.Collections.Generic;
Line 357:
}
}</lang>
===By xor-ing the values===
{{works with|C sharp|C#|3+}}
<lang csharp>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)));
}
}</lang>
 
=={{header|Clojure}}==
<lang clojure>
196

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.