Skip to main content
explanation had A and B exchanged by mistake
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290
Nθ Input `n` as a number ζ Input `A``B` ⬤ All characters must match θ Input `n` κ Current index ⊕ Incremented ⌊⟦ ⟧ Minimum E Map over implicit range ζ Input `A``B` ✂ ¹ Sliced from κ Outer index ⁻ Minus λ Inner value ⁻κλ To outer index minus inner value ⁺ Plus θ Input `n` ⊙ Any string satisfies λ Current string L Length ⁼ Equals θ Input `n` ∧ Logical And λ Current string № Contained in η Input `B``A` Implicitly print 
Nθ Input `n` as a number ζ Input `A``B` ⬤ All characters must match ⁰ Literal zero κ Current index ⁻ Minus θ Input `n` ⊖ Decremented ⌈⟦ ⟧ Maximum κ Current index ζ Input `A``B` L Length ⁻ Minus θ Input `n` ⌊⟦ ⟧ Minimum …· Inclusive range ⊙ Any value satisfies ζ Input `A``B` ✂ Sliced from λ Current value to λ Current value ⁺ Plus θ Input `n` № Contained in η Input `B``A` Implicitly print 

Loop over the starting index of all substrings of length n in input BA.

Loop over all matches of each substring in input AB.

Check that each index in input AB was recorded at least once.

Nθ Input `n` as a number ζ Input `A` ⬤ All characters must match θ Input `n` κ Current index ⊕ Incremented ⌊⟦ ⟧ Minimum E Map over implicit range ζ Input `A` ✂ ¹ Sliced from κ Outer index ⁻ Minus λ Inner value ⁻κλ To outer index minus inner value ⁺ Plus θ Input `n` ⊙ Any string satisfies λ Current string L Length ⁼ Equals θ Input `n` ∧ Logical And λ Current string № Contained in η Input `B` Implicitly print 
Nθ Input `n` as a number ζ Input `A` ⬤ All characters must match ⁰ Literal zero κ Current index ⁻ Minus θ Input `n` ⊖ Decremented ⌈⟦ ⟧ Maximum κ Current index ζ Input `A` L Length ⁻ Minus θ Input `n` ⌊⟦ ⟧ Minimum …· Inclusive range ⊙ Any value satisfies ζ Input `A` ✂ Sliced from λ Current value to λ Current value ⁺ Plus θ Input `n` № Contained in η Input `B` Implicitly print 

Loop over the starting index of all substrings of length n in input B.

Loop over all matches of each substring in input A.

Check that each index in input A was recorded at least once.

Nθ Input `n` as a number ζ Input `B` ⬤ All characters must match θ Input `n` κ Current index ⊕ Incremented ⌊⟦ ⟧ Minimum E Map over implicit range ζ Input `B` ✂ ¹ Sliced from κ Outer index ⁻ Minus λ Inner value ⁻κλ To outer index minus inner value ⁺ Plus θ Input `n` ⊙ Any string satisfies λ Current string L Length ⁼ Equals θ Input `n` ∧ Logical And λ Current string № Contained in η Input `A` Implicitly print 
Nθ Input `n` as a number ζ Input `B` ⬤ All characters must match ⁰ Literal zero κ Current index ⁻ Minus θ Input `n` ⊖ Decremented ⌈⟦ ⟧ Maximum κ Current index ζ Input `B` L Length ⁻ Minus θ Input `n` ⌊⟦ ⟧ Minimum …· Inclusive range ⊙ Any value satisfies ζ Input `B` ✂ Sliced from λ Current value to λ Current value ⁺ Plus θ Input `n` № Contained in η Input `A` Implicitly print 

Loop over the starting index of all substrings of length n in input A.

Loop over all matches of each substring in input B.

Check that each index in input B was recorded at least once.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 31 bytes

Nθ⬤ζ⊙E⌊⟦θ⊕κ⟧✂ζ⁻κλ⁺⁻κλθ¹∧⁼Lλθ№ηλ 

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for true, empty for false. Explanation:

Nθ Input `n` as a number ζ Input `A` ⬤ All characters must match θ Input `n` κ Current index ⊕ Incremented ⌊⟦ ⟧ Minimum E Map over implicit range ζ Input `A` ✂ ¹ Sliced from κ Outer index ⁻ Minus λ Inner value ⁻κλ To outer index minus inner value ⁺ Plus θ Input `n` ⊙ Any string satisfies λ Current string L Length ⁼ Equals θ Input `n` ∧ Logical And λ Current string № Contained in η Input `B` Implicitly print 

Alternative solution, also 31 bytes:

Nθ⬤ζ⊙…·⌈⟦⁰⁻κ⊖θ⟧⌊⟦κ⁻Lζθ⟧№η✂ζλ⁺λθ 

Try it online! Link is to verbose version of code. Explanation:

Nθ Input `n` as a number ζ Input `A` ⬤ All characters must match ⁰ Literal zero κ Current index ⁻ Minus θ Input `n` ⊖ Decremented ⌈⟦ ⟧ Maximum κ Current index ζ Input `A` L Length ⁻ Minus θ Input `n` ⌊⟦ ⟧ Minimum …· Inclusive range ⊙ Any value satisfies ζ Input `A` ✂ Sliced from λ Current value to λ Current value ⁺ Plus θ Input `n` № Contained in η Input `B` Implicitly print 

Alternative solution, also 31 bytes:

NθF⁻Lη⊖θF⌕Aζ✂ηι⁺ιθFθ⊞υ⁺κλ¬⁻Eζκυ 

Try it online! Link is to verbose version of code. Explanation: Port of @DominicvanEssen's answer.

Nθ 

Input n.

F⁻Lη⊖θ 

Loop over the starting index of all substrings of length n in input B.

F⌕Aζ✂ηι⁺ιθ 

Loop over all matches of each substring in input A.

Fθ⊞υ⁺κλ 

Record the index of each character in each match.

¬⁻Eζκυ 

Check that each index in input A was recorded at least once.