September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,22 @@
|
|||
def transpose:
|
||||
if (.[0] | length) == 0 then []
|
||||
else [map(.[0])] + (map(.[1:]) | transpose)
|
||||
end ;
|
||||
|
||||
# Input: an array of integers (based on the encoding of A=0, B=1, etc)
|
||||
# corresponding to the occurrences in any one position of the
|
||||
# letters in the list of permutations.
|
||||
# Output: a tally in the form of an array recording in position i the
|
||||
# parity of the number of occurrences of the letter corresponding to i.
|
||||
# Example: given [0,1,0,1,2], the array of counts of 0, 1, and 2 is [2, 2, 1],
|
||||
# and thus the final result is [0, 0, 1].
|
||||
def parities:
|
||||
reduce .[] as $x ( []; .[$x] = (1 + .[$x]) % 2);
|
||||
|
||||
# Input: an array of parity-counts, e.g. [0, 1, 0, 0]
|
||||
# Output: the corresponding letter, e.g. "B".
|
||||
def decode:
|
||||
[index(1) + 65] | implode;
|
||||
|
||||
# encode a string (e.g. "ABCD") as an array (e.g. [0,1,2,3]):
|
||||
def encode_string: [explode[] - 65];
|
||||
|
|
@ -0,0 +1 @@
|
|||
map(encode_string) | transpose | map(parities | decode) | join("")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ jq -R . Find_the_missing_permutation.txt | jq -s -f Find_the_missing_permutation.jq
|
||||
"DBAC"
|
||||
Loading…
Add table
Add a link
Reference in a new issue