Skip to main content
added 613 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 46 bytes

s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))

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.

JavaScript (Node.js), 46 bytes

s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))

Try it online!

Take input as array of digits. Output truthy vs. falsy.

JavaScript (Node.js), 46 bytes

s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))

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.
deleted 25 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 5746 bytes

s=>/^.{9},.{13},.{9}$/.test(p=ss.map(c=>c%7||.1)+'')[32]&&!p[33]&&p[9]+p[23]==',,'

Try it online!Try it online!

Take input as array of digits. Output truthy vs. falsy.

JavaScript (Node.js), 57 bytes

s=>(p=s.map(c=>c%7||.1)+'')[32]&&!p[33]&&p[9]+p[23]==',,'

Try it online!

Take input as array of digits. Output truthy vs. falsy.

JavaScript (Node.js), 46 bytes

s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))

Try it online!

Take input as array of digits. Output truthy vs. falsy.

Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 57 bytes

s=>(p=s.map(c=>c%7||.1)+'')[32]&&!p[33]&&p[9]+p[23]==',,'

Try it online!

Take input as array of digits. Output truthy vs. falsy.