APL (Dyalog Unicode), 1513 bytesSBCS
-2 bytes:
(∧/1=+/)∘≢=∘≢∘⍸∘.(⊃⍷)⍨ Explanation:
(∧/1=+/)∘≢=∘≢∘⍸∘.(⊃⍷)⍨ ⍝ Monadic function train ⍷ ⍝ "Find": Convert the right argument into a boolean vector, ⍝ where ones correspond to instances of the left argument ⊃ ⍝ Take the first item of the above vector (i.e., only prefixes) ∘.( )⍨ ⍝ Commutative outer product: take the above function and apply ⍝ it for each possible pair of elements in the input ⍝ If the input is a prefix code, the above should behave equivalent a number of ones ⍝ equal to the identitylength matrixof the input (i.e., each elementitem is a prefix of only itself) ⍝ To test that it's an identity matrixthis... ( +/) ⍸ ⍝ SumFind alongthe rowslocation of theall matrix ones in the 1=above ≢∘ ⍝ Test⍝ thatTake the sums are equal to 1, resultslength inof booleanthe vectorabove ∧/ ≢=∘ ⍝ And-reduce: testCompare thatto abovethe vectorlength onlyof containsthe onesinput