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

Charcoal, 1725 bytes

¬№﹪⌕A⭆S∨﹪Iι⁷χ0⁷¦⁵≔⭆S∨﹪Iι⁷χθ›⁼¹⁷Lθ№﹪⌕Aθ0⁷¦⁵

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean i.e. - for haiku, nothing if not. Works like my Retina answer, except it replaces 0 and 7 with 10 and checks that neither the 6th nor the 13th syllable is 0. Explanation:

      S             Input string
     ⭆              Map over characters and join
          ι         Current character
         I          Cast to integer
        ﹪  ⁷        Reduce modulo 7
       ∨    χ       Replace zeros with predefined variable 10
   ⌕A        0      Find all occurrences of literal string `0`≔⭆S∨﹪Iι⁷χθ
  ﹪           ⁷     Vectorised modulo 7

Reduce all of the digits modulo 7, then change all 0s to 10, so that 0 represents a second syllable.

›⁼¹⁷Lθ
¬№              ⁵   Check that there are no 5s.

Check that there are 17 syllables, but not that...

№﹪⌕Aθ0⁷¦⁵

any second syllables are at position equivalent to 5 (modulo 7).

Charcoal, 17 bytes

¬№﹪⌕A⭆S∨﹪Iι⁷χ0⁷¦⁵

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean i.e. - for haiku, nothing if not. Works like my Retina answer, except it replaces 0 and 7 with 10 and checks that neither the 6th nor the 13th syllable is 0. Explanation:

      S             Input string
     ⭆              Map over characters and join
          ι         Current character
         I          Cast to integer
        ﹪  ⁷        Reduce modulo 7
       ∨    χ       Replace zeros with predefined variable 10
   ⌕A        0      Find all occurrences of literal string `0`
  ﹪           ⁷     Vectorised modulo 7
¬№              ⁵   Check that there are no 5s.

Charcoal, 25 bytes

≔⭆S∨﹪Iι⁷χθ›⁼¹⁷Lθ№﹪⌕Aθ0⁷¦⁵

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean i.e. - for haiku, nothing if not. Works like my Retina answer, except it replaces 0 and 7 with 10 and checks that neither the 6th nor the 13th syllable is 0. Explanation:

≔⭆S∨﹪Iι⁷χθ

Reduce all of the digits modulo 7, then change all 0s to 10, so that 0 represents a second syllable.

›⁼¹⁷Lθ

Check that there are 17 syllables, but not that...

№﹪⌕Aθ0⁷¦⁵

any second syllables are at position equivalent to 5 (modulo 7).

Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 17 bytes

¬№﹪⌕A⭆S∨﹪Iι⁷χ0⁷¦⁵

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean i.e. - for haiku, nothing if not. Works like my Retina answer, except it replaces 0 and 7 with 10 and checks that neither the 6th nor the 13th syllable is 0. Explanation:

      S             Input string
     ⭆              Map over characters and join
          ι         Current character
         I          Cast to integer
        ﹪  ⁷        Reduce modulo 7
       ∨    χ       Replace zeros with predefined variable 10
   ⌕A        0      Find all occurrences of literal string `0`
  ﹪           ⁷     Vectorised modulo 7
¬№              ⁵   Check that there are no 5s.