[Question]
  [
We can read `13576870234289` digit-by-digit in English, and it makes a haiku:
> 
> *one three five seven*  
> 
> *six eight seven zero two*  
> 
> *three four two eight nine*
> 
> 
> 
We say it's a "digit haiku", because when read out like this, it's 5+7+5 syllables long, **and** no word is broken across a line.
For example, `111171111101111` is **not** a digit haiku, even though it has 17 syllables:
> 
> *one one one one **se-***  
> 
> ***-ven** one one one one one **ze-***  
> 
> ***-ro** one one one one*
> 
> 
> 
Two-syllable digits (`0` "zero" and `7` "seven") are not allowed to span the 5th-and-6th syllable positions, or the 12th-and-13th syllable positions. (Other than that, any 17-syllable digit string makes a digit haiku.)
All other digits beside 0 and 7 are one syllable long in English.
## Task
Given a non-empty string of digits (or list of numbers) `0` through `9`, decide whether it forms a digit haiku.
* You can assume the string does not start with `0`, and thus you're also permitted to take input as a number.
* You can assume the input is at most 17 digits long. However, it may be more than 17 *syllables*.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"): aim to write the shortest answer, measured in bytes.
## Test cases
```
7767677677 -> True
13576870234289 -> True
123456789012345 -> True
11111111111111111 -> True
9 -> False
9876543210 -> False
11171111101111 -> False
111171111101111 -> False
998765432101234 -> False
77777777777777777 -> False
```
  
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 25 bytes
```
0|7
_#
^.{5}\w.{6}\w.{4}$
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7w36DGnCtemStOr9q0NqZcr9oMTJrUqvz/b25uBoQgxGVobGpuZmFuYGRsYmRhyWUIpE3NzC0sDcAsLkN0wGXJZWlhbmZqYmxkaACSNgcLG0DkEFIg7Vzm6AAA "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
0|7
_#
```
Expand `0` and `7` into two syllables.
```
^.{5}\w.{6}\w.{4}$
```
Check that neither the 6th nor the 13th syllable is the second such syllable.
[Answer]
# JavaScript (ES6), ~~48~~ 41 bytes
Expects a list of digits. Returns a Boolean value.
```
a=>a.map(d=>i-=d%7?1:i%7-6?2:.1,i=17)&&!i
```
[Try it online!](https://tio.run/##hU/LDoIwELz7Fx54JYUAAgWSws0v8IYcGh5ag0AATfz6uiIaDI1k00l2d2Y6e6F32mcdawe9bvKCl4RTElHjSls1JxHTSS7h2AqZhHUvtkPDQoxYWJPlLeNZU/dNVRhVc1KV5NDdhvMjVbTNfF6qCUYYedObMNUWLAvtkDvufUAT2dA7gD4KhOz33h39gAOK70zIX6mX5kekHOtkT6tedJEoUTDm9iCRAyls8DT/5MCzv815hoWrwPdzqYCP0UqBhj8B "JavaScript (Node.js) – Try It Online")
### How?
We use a syllable counter \$i\$ initialized to \$17\$, subtract either \$1\$ or \$2\$ from \$i\$ after each digit and check whether we end up with \$i=0\$. The haiku is supposed to look like that:
```
17 16 15 14 **13**
12 11 10 09 08 07 **06**
05 04 03 02 01
```
When the digit is either \$0\$ or \$7\$ and \$i\equiv 6\pmod 7\$, we have an invalid hyphenation and subtract \$1/10\$ from \$i\$ instead of \$2\$. Because this test can only be triggered once, \$i\$ remains a non-integer value whatever happens next.
[Answer]
# [J](http://jsoftware.com/), 32 30 bytes
```
4=5 12 17+/@e.~[:+/\0,~1+0=7|]
```
*-2 thanks to xash*
[Try it online!](https://tio.run/##bY1NCsIwEIX3PcWjmyDVdNI2mTQQEARXrtxWV9JW3HgB6dVjWgVpcH5g5n28mUfIpRjgHQS2ILjYO4nD@XQMjddQFRQX5b6XU@eK8kLbSRXk@XUNm2z0snMYkMucsqy/3Z9Q8BghmE3MucRKV7VmY5mquqlsm7AoasO2pWVKYBpfTB/cJqtlo5u6UrTWo48XN/058TPN/9eQ0xDhDQ "J – Try It Online")
## original explanation
```
[:(5&e.*12&e.*17={:)[:+/\1+0=7|]
```
[Try it online!](https://tio.run/##bY1BDsIgEEX3PcWki6K20oG2TEtCYjRxZVy4ra5MW@PGA@jdkaKJgTgDBP77f7jblLMRjAYGBSBot9ccdqfD3vZ60WQDXwnpTzJPvex1Xp5FjoZeF7tMjlsOlZmN4F15uSkC48AzhsSSZDK81zBCylNMhuvtARMwUTWkWkJZ1bLtnMsDAWaGRMr1vFigx6GAObFR1HbobxGM64vxg7vo2ZJq6koKDHWXI5/GPyN@ofn/EFJczL4B "J – Try It Online")
Straightforward:
* Take list of digits
* `7|]` mod 7
* `0=` equals 0 (returns 1-0 list)
* `1+` add 1 (now list of 1-2)
* `[:+/\` scan sum
* `[:(5&e.*12&e.*17={:)` is 5 an elm and is 12 an elm and is 17 the last?
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
7ḍ‘ŒṖ§Ḍ575e
```
[Try it online!](https://tio.run/##y0rNyan8/9/84Y7eRw0zjk56uHPaoeUPd/SYmpum/nd51LTmcDuQACowNwNCENJRMDQ2NTezMDcwMjYxsrAE8oEMUzNzC0sDMEtHAShmaWFuZmpibGRoAJQ3NDQ3BAEDEAGUQ0iCNAAA "Jelly – Try It Online")
# Explanation
```
7ḍ‘ŒṖ§Ḍ575e  Main Link
// convert to syllables
7ḍ           Divisibility by 7 (1 for 0 and 7, 0 otherwise)
  ‘          Increment (2 for 0 and 7, 1 otherwise; this gives the syllables)
// all ways to divide the digits into lines, and total syllable counts
   ŒṖ        Partitions (all divisions of a list)
     §       Sum each sublist for each partition
// check if any of them are [5, 7, 5]
      Ḍ      Convert the lines' syllable sizes into a decimal integer; this can cause collisions but not if the total number of syllables is maximum 34
       575e  Is 5-7-5 a possible partition?
```
Takes a long time on some test cases so I didn't include them.
-1 byte thanks to Jonathan Allan
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 46 bytes
```
s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))
```
[Try it online!](https://tio.run/##XU/NboMwDL7zFDmsItGoy08hoCrctifYrWvVKIMuEyOIsAmJ8uyMoNFIdSzL/n4c@Yv/ci1a2XTbWn0UU8kmzfLdGYZs9GAIIlOz8WkHXaE7rOGbN1iwXGzo7QYBIZPBBdcFYuhCaTI/k2ibo7f2p3CCKKZJSv0w2odpZuF5jhOaZv7SWfwx7szifeWVntuUJvE@CgPfYrOULgZ/df1rrdj8ZAn6GHfqArqpZIfd99oly8E9YjnqV9gIXUIOzno6lKp94eIT46P0kDoRIx8coWqtqgIqdcUlPgKAPNl1zz0hnvLkvGckh@kP "JavaScript (Node.js) – Try It Online")
Take input as array of digits. Output truthy vs. falsy.
* `s.map(c=>c%7||.1)` mapping each digits to a number. Digits 0 or 7 which has 2 syllables are mapped into `0.1` while others are mapped into an 1 digit number.
* `RegExp.prototype.test` converts its parameter into `string`. The mapping result is an array. When try to convert array into a string, each elements are converted into string and connected by a comma (`,`). So, basically, each digits in the string is 1 syllable. And commas between theme mean you can break line here, while dots mean you cannot break line here.
* Finally, `/^.{9},.{13},.{9}$/` test if the string has a 5-7-5 syllables pattern.
[Answer]
# [Python 2](https://docs.python.org/2/), 53 bytes
```
t=17
for d in input():t-=0<d%7or 2+t%7/6*t
print t==0
```
[Try it online!](https://tio.run/##hU3bCoMwDH33K4og7JKx2qlRWb9EfJodCqIiGdu@voudEx8GkvbAuSXDm@q@U/ZZN60RYW5e5ub7viUdonfvR1GJpuM3PGi3z@mk5bUKkHV1pADPyYG8YWw6EqS1tFOzQEBI5j9j6RUhXCB2PGWUoJhHjClkzv3y2OVZ48SiOX9jODPtydz2hPdE3FXsyKWNq7xc9@BP63edfYSNKT8 "Python 2 – Try It Online")
Based on [Arnauld's solution](https://codegolf.stackexchange.com/a/213869/20260). I use `True/False` output here and in the answers below since I'm not sure what [decision-problem](/questions/tagged/decision-problem "show questions tagged 'decision-problem'") output is allowed.
**55 bytes**
```
t=4
for d in input():t-=1+~d%7/6+t%47/46*40
print-t==93
```
[Try it online!](https://tio.run/##hU1LCoMwEN17iiAIbR0xakxUyEnEVbUoiIpMabvp1dMxteKiIJM8ePM@M72wHYfYPNqub1hUNM/m6rquQS2c2zizmnUDvemOp3OBgY78d@2pUProCRUKeRHcmeZuwAC1zhOzZEsFCuT6V6ycMoIEUsszQg4xcUGYQW7VL0@tn3bk2HZWPxjyLD25bZfUIygbk8K3tNr5@T4Hf1K/66QrOJjqAw "Python 2 – Try It Online")
**58 bytes**
```
t=1
for d in input():t=t<<1+~d%7/6|1
print-3967&t>>5==4225
```
[Try it online!](https://tio.run/##hU3bCoJAEH33K0QoiiZyV3dXxfVHxKc0XAgVmagg@nUbNxMfApndA2fOZbon1m3Dh3ttrpXLkupRnT3PG1Az59L2bumahl53w90@QY1pyg7vcqNO8sWcrjcNHoNYqi1mmdA65FwMYzxXoEBOf8LCyRkEICyPCH3gxEPCCGKrfrmwftqRY95ZfWXIM/bEtl1ST0hZToo/p9XC7y9z8Cf1u066gpUpPg "Python 2 – Try It Online")
**58 bytes**
```
s=t=0
for d in input():s+=1+~d%7/6;t+=s%7==5
print s*t==34
```
[Try it online!](https://tio.run/##hU1LCoMwEN17iiAIbR1ojJ@oZU4irqpFQVRMSttNr56OqRUXBZnkwZv3mfGlm6EX5tG0Xc2CvH7WV9d1jUKN3LkNE6tY29Mb7/pwzJWPgf@uPHlOLtpH5UnE2BmnttdMnTRiGJk5XkiQkCx/wdIpAgghtjwl5CCIR4QpZFb98tj6aUeOdWf1nSHP3JPZ9oR6IsoKUvialhs/3@bgT@p3nXQJO1N@AA "Python 2 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~72~~ ~~66~~ ~~65~~ 63 bytes
*Edit: -6 bytes thanks to Robin Ryder, and -2 bytes thanks to Giuseppe*
```
max(s<-cumsum(1+!utf8ToInt(scan(,''))%%7-6))==17&5%in%s&12%in%s
```
[Try it online!](https://tio.run/##jc9dS8MwFAbg@/yK40bXBC30Y81JxXopeL9LQULsXFibQpOg/752Bd1WNHgSSCAP5z0ZxrGTn9Q@JMp31nc0u73xbi92/bNx1Cpp6F0cMxZFmHDG6jrDTRlpE9lNls/niMinddqErOFj0K4BaWHvjXK6N@B6cI11INsWlLSNvSdv@l2714PUR19/O2oYCYxiAiMQoqSj8YuJ2WVrujqPtmKwhuQRdoNvrk1WlMgFpnmxzUUVcBMoOYoqnW8BuKy/6U/ck2zt8k0gL7dFnqUBNHXHOSO9DPod/lNW5@DTRwMSl3VtyfgF "R – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~96~~ \$\cdots\$ ~~92~~ 91 bytes
Added 14 bytes to fix a bug kindly pointed out by [HyperNeutrino](https://codegolf.stackexchange.com/users/68942/hyperneutrino).  
Saved 2 bytes thanks to [rtpax](https://codegolf.stackexchange.com/users/85545/rtpax)!!!  
Saved a byte thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
```
p;h;s;c;f(long n){for(h=5,p=s=c=0;n;c=c/h?p|=c!=h,h^=2,!++s:c,n/=10)c+=n%10%7?1:2;h=p|s<3;}
```
[Try it online!](https://tio.run/##XVBtb4IwEP7urzhJSEBqLCAUrN0@LPsV0y2mFCFxlQAfyJTfzkrt2Mb1Lrk@99wrX585H4aKFrShnObO5SrPIN1bfq2dgkWoYg3jDFNJOeOb4rm6M75kBSreWYCWntfsOJIb5mOXe0zaPrbJs78LaMGqe7MPaT@UsoXPUykdd3FbgBLdohVN@yHfjsDgRkis3qgI/DAicUJwEG6DJFV/5UQxSVKsPQXMBYGipQmJo20Y@FgziI5gE/4NjjUQkLmMkE@0@QbqqZ51HF50leCtyB7DqoKT4pmaJF6c6hXUD7516F6DQ5e@KIssBH//oWUyxmuPrUqZiU5lYWrcPTTll7jmzs8Q7sYAqwmh4Hma7cLjwNORpSplDq0JRzrFx26tCueOdP@jQqHTyvO0qlaU3LHsSwbrJ7AzsJuDVGtJBC1SOy8FY@3RlOwX/fAN "C (gcc) – Try It Online")
Returns \$0\$ if the input integer is a digit haiku or \$1\$ otherwise.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 25 bytes
```
≔⭆Ｓ∨﹪Ｉι⁷χθ›⁼¹⁷Ｌθ№﹪⌕Ａθ0⁷¦⁵
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMMvv0TDOb8UyPLNTynNyddwy8xLcczJ0QguAcqn@yYWaHjmFZSWQLgamjoK/kUwpc6JxSUamUAhcyA2NNAEkkoGSlC@qaampvX//5aWFuZmpibGRoYGhkbGJv91y3IA "Charcoal – 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:
```
≔⭆Ｓ∨﹪Ｉι⁷χθ
```
Reduce all of the digits modulo 7, then change all `0`s to `10`, so that `0` represents a second syllable.
```
›⁼¹⁷Ｌθ
```
Check that there are 17 syllables, but not that...
```
№﹪⌕Ａθ0⁷¦⁵
```
any second syllables are at position equivalent to 5 (modulo 7).
[Answer]
# [Perl 5](https://www.perl.org/) (`-p`), ~~38~~, 34 bytes
```
s/0|7/ 
/g;$_=/^.{5}\V.{5}\H.{5}$/
```
[Try it online!](https://tio.run/##K0gtyjH9X6yvoGunp6Wvbw1kGtSY6ytw66dbq8Tb6sfpVZvWxoSBSQ8QqaL//7@5uRkQghBQm0JIUWkql6GxqbmZhbmBkbGJkYUlQhjINzUzt7A0ALMQ4ugALgPW65aYUwxkWpibmZoYGxkaIMSASs3BGgxguqBqEYpBNiEkzNEBXOpffkFJZn5e8X/dnAIA "Perl 5 – Try It Online")
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), 60 bytes
```
5-in($l=$args|%{($s+=1+($_-in48,55))})-and12-in$l-and$s-eq17
```
*-42 bytes thanks to mazzy*
[Try it online!](https://tio.run/##bZDLCoMwEEX3@YpBxqKoYNSYuBD8E5HWtkLQ1hS6UL89jY8@kE6yuPfmzBDm1j3rXl1rKYNj19caz5DDoFnQtA7KHKv@okZ7cFB5OfUcLM1DInzGXHdyg6o90cgkKGeJKqjvlOuJkMIBi8aMp4KHUZxEIrOID2Bxnpoz39X/Y6gxLOUiCxe1hfta460lEzxlSRzR8EPzhQp/0C80z33/Z1cWcWEEGwYCgOrRN@3FLARLYw9mN8UWAZm0fgE "PowerShell Core – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~[62](https://codegolf.stackexchange.com/revisions/214094/1)~~ ~~[58](https://codegolf.stackexchange.com/revisions/214094/2)~~ 56 bytes
*Thanks to [ovs](https://codegolf.stackexchange.com/users/64121/ovs) for helping me reduce this*
```
g q|r<-do x<-q;1:[0|7*x==x*x]=length r==17&&r!!5*r!!12>0
```
[Try it online!](https://tio.run/##DcdLCoAgFADAqxhEC3mB9tM@r4tEi6CwyKyshYvubm4GZp2efdHae0Xuz3bpfBLXpXfLm4F9gjpER92IejHqXYlF5CJJbBSVNMCznvlj2gxedjNvrAYOOZQgoAIZZJCFF0EJ9eh/ "Haskell – Try It Online")
The first thing we do is convert the input to a sort of syllable map. That is a list of integers, one for each syllables with the following meaning:
0. Second syllable of a word
1. First syllable of a word
So with this we check that the length of is 17, that is there are 17 syllables all in all. Then we index the syllable codes at the beginning of the second and third lines. We multiply these together. If either of them is the second syllable of a word this product is zero because zero times any number is zero. And if both of them are 1 then it is not zero. So we check that this is not zero. That is to say that no line starts with the second syllable of a word.
And that's it.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
7Ö>.œO575S.å
```
Input as a list of digits.
[Try it online](https://tio.run/##yy9OTMpM/f/f/PA0O72jk/1NzU2D9Q4v/f8/2lDHWMdUx1zHTMcCSBroGAH5JkDSQscyFgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXwf/PD0@z0jk72NzU3DdY7vPS/zv9oc3MzIAQhHUNjU3MzC3MDI2MTIwtLHUMgbWpmbmFpAGbpGKIDHUsdSwtzM1MTYyNDA5C0OVjYACKHkAJp1zFHB7EA).
**Explanation:**
```
7Ö            # Check for each digit of the (implicit) input-list whether it's divisible
              # by 7
  >           # Increase these checks by 1 (2 for 0 and 7; 1 otherwise)
   .œ         # Check all partitions of this list
     O        # Sum each inner-most list
      575S    # Push [5,7,5]
          .å  # Check that this list is in the list of lists
              # (after which the result is output implicitly)
```
[Answer]
# JavaScript, 53 bytes
`BigInt` input.
```
n=>!(f=s=>n?f(s-=n%10n%7n?1:s%7-6?2:18,n/=10n):s)(17)
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 22 bytes
```
§&o=17→§&€5€12∫mȯ→¬%7d
```
[Try it online!](https://tio.run/##yygtzv7//9BytXxbQ/NHbZOArEdNa0yB2NDoUcfq3BPrQYJrVM1T/v//b2hsam5mYW5gZGxiZGEJAA "Husk – Try It Online")
Port of [my R answer](https://codegolf.stackexchange.com/a/213885/95126) so probably not the golfiest approach in [Husk](https://github.com/barbuz/Husk)...
```
§&o=17→§&€5€12∫mȯ→¬%7d
§&                      # fork &: are both of the following true?
  o=17→                 # last element equals 17?
       §&               # fork &: are both of the following true?
         €5             # contains 5?
           €12          # contains 12?
                        # ...when applied to:
              ∫         # cumulative sum of
               m     d  # this function applied to digits of input:
                ȯ       # combine 3 functions:
                   %7   # MOD 7
                  ¬     # NOT
                 →      # +1
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~70~~ 67 bytes
Thanks to ceilingcat for the -3.
Returns `0` if a valid haiku and non-zero if not.
As the syllable count can only increase by either 1 or 2, I check for 5, 12 and greater than 16 and increase the state when I see those values (this also accounts for strings that would be valid except for continuing past 17.) If the state ends at 3 by the end of the input, then it's correct.
```
c,d;f(char*s){for(c=d=0;*s;d+=c==5|c==12|c>16)c-=~!(~*s++%7);d-=3;}
```
[Try it online!](https://tio.run/##bVDbboMwDH3nKzwmpFxg4lIIKAtfUO1tT@seqmSskTaYSLaXlv46C2yDqppjRT7H9rFlGb1KOY4yVLxB8rDvicHHpuuRFErEnBiuqJBC5Cf3JelJ1kmBZSTON@hMDKUBw1xFIuPDeKtb@fapXuDeWKW7u0Ptebq18L7XLfrqtMJw9ACmIUDM07OYIYDPWOHe5H74wyRZzoqSxWm2SctqYR3MC1ZW8Rwt9LX9JVbdhVq0qpIV@SZLk/hChs3t8aVG8j9drf3TLuvEK/tNPDxuty4YQiDECsM9B6YjcyCWY/jo3Z0a5AcGRA2B2rW@q7SUhtAgYjHm3jB@Aw "C (gcc) – Try It Online")
[Answer]
# [K (ngn/k)](https://git.sr.ht/%7Engn/k), ~~31~~ 30 bytes
```
{(17=*|o)>/^(o:+\1+~7!x)?5 12}
```
[Try it online!](https://ngn.bitbucket.io/k#eJxdjEsKAjEQRPc5RQtCEgOazq+SiHoREbKZ7WwFP2d3ko2Q6l5UdT16qS/FuBzeq76eHmqt5s7mi91T3yKx+wjR6rFKuVdA2qYvsY9IGdb54HLZMB9iQi52OOJZVKhkpBi8Y9trjLMdHU+5/NH+jjBLC6MW2c5N/wAyUCeA)
A straightforward translation of @jonah's `J` answer.
* `(o:+\1+~7!x)` convert input to number of syllables in each digit, storing in `o` (literally, `sums 1 + not 7 mod x`)
* `^(...)?5 12` check whether 5 and 12 are in that list
* `(17=*|o)` check whether or not the list ends up with syllable 17
* `(...)>/...` use greater-than-fold, seeded with `(17=*|o)`
]