you can find the description here
and you can find the code here
for the first part, simply count the number of words in the output section that have lengths 2, 3, 4 or 7
for the second part, i couldn’t think of a better solution than just try permutations until the wires make sense