Skip to main content
deleted 785 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 2525 16 bytes

⊙⌕Aθe⊙⌕Aθn⁼✂θλ⊕ι÷⁻ιλ³nice⊙θ⊙θ№✂θκLθ⊕μnice
 ⌕A                         Find all positions of
    e                       Literal string `e`
   θ                        In inputInput string
⊙                           Any end positionindex satisfies
      ⌕A                    Find all positions of
         n                  Literal string `n`
        θ                   In inputInput string
                         Any start positionindex satisfies
            θ               Input string
                      Sliced in steps of
                  ι         End position
                 ⁻          Minus
                   λ        Start position
                ÷   μ        Integer dividedInner byindex
                    ³       Literal `3`Incremented
             λ  κ            From startouter positionindex
              ⊕ι  Lθ          To end position "inclusive"
   the end of the string
                   Count Isi.e. equalcontains tosubstring
                     nice    Literal string `nice`

The code tries to slice precinct from position 5 to position 2 but this doesn't work: "precinct"[5:2+1:-1] is just ni, therefore this slice is rejected as desired. Another rejection occurs when the start and end point are not an exact multiple of 3 apart, in which case the slice will undershoot the final e.

Charcoal, 25 bytes

⊙⌕Aθe⊙⌕Aθn⁼✂θλ⊕ι÷⁻ιλ³nice
 ⌕A                         Find all positions of
    e                       Literal string `e`
   θ                        In input string
⊙                           Any end position satisfies
      ⌕A                    Find all positions of
         n                  Literal string `n`
        θ                   In input string
                         Any start position satisfies
            θ               Input string
                      Sliced in steps of
                  ι         End position
                 ⁻          Minus
                   λ        Start position
                ÷           Integer divided by
                    ³       Literal `3`
             λ              From start position
              ⊕ι            To end position "inclusive"
                           Is equal to
                     nice   Literal string `nice`

The code tries to slice precinct from position 5 to position 2 but this doesn't work: "precinct"[5:2+1:-1] is just ni, therefore this slice is rejected as desired. Another rejection occurs when the start and end point are not an exact multiple of 3 apart, in which case the slice will undershoot the final e.

Charcoal, 25 16 bytes

⊙θ⊙θ№✂θκLθ⊕μnice
 θ                  Input string
⊙                   Any index satisfies
   θ                Input string
  ⊙                 Any index satisfies
      θ             Input string
     ✂              Sliced in steps of
           μ        Inner index
                   Incremented
       κ            From outer index
        Lθ          To the end of the string
                   Count i.e. contains substring
            nice    Literal string `nice`
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 25 bytes

⊙⌕Aθe⊙⌕Aθn⁼✂θλ⊕ι÷⁻ιλ³nice

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - if nice, nothing if not. Explanation:

 ⌕A                         Find all positions of
    e                       Literal string `e`
   θ                        In input string
⊙                           Any end position satisfies
      ⌕A                    Find all positions of
         n                  Literal string `n`
        θ                   In input string
     ⊙                      Any start position satisfies
            θ               Input string
           ✂                Sliced in steps of
                  ι         End position
                 ⁻          Minus
                   λ        Start position
                ÷           Integer divided by
                    ³       Literal `3`
             λ              From start position
              ⊕ι            To end position "inclusive"
          ⁼                 Is equal to
                     nice   Literal string `nice`

The code tries to slice precinct from position 5 to position 2 but this doesn't work: "precinct"[5:2+1:-1] is just ni, therefore this slice is rejected as desired. Another rejection occurs when the start and end point are not an exact multiple of 3 apart, in which case the slice will undershoot the final e.