Find the missing permutation: Difference between revisions

(Updated to work with Nim 1.4: added missing parameter type, replaced ".. <" by "..<" and replaced "split" by "splitWhiteSpace".)
Line 2,278:
{{out}}
<pre>DBAC</pre>
 
==Alternates==
All cases take permutation list on STDIN or as filename on command line
<br><br>
If the string XOR was of all the permutations, the result would be a string of nulls "\0",
since one is missing, it is the result of XOR of all the rest :)
<lang perl>print eval join '^', map "'$_'", <>;</lang>
or if you don't like eval...
<lang perl>$\ ^= $_ while <>;
print '';</lang>
Every permutation has a "reverse", just take all reverses and remove the "normals".
<lang perl>local $_ = join '', <>;
my %h = map { $_, '' } reverse =~ /\w+/g;
delete @h{ /\w+/g };
print %h, "\n";</lang>
 
=={{header|Phix}}==
Anonymous user