[Question]
  [
A [haiku](https://www.youngwriters.co.uk/types-haiku-poem) is a poem with three lines, with a 5/7/5 *syllable* count, respectively.
A **haiku-w** is poem with three lines, with a 5/7/5 **word** count, respectively.
## Challenge
Write a program that will return **true** if the input is a haiku-w, and **false** if not.
A valid haiku-w input must consist of 3 lines, separated by a newline.
* Line 1 must consist of 5 words, each word separated by a space.
* Line 2 must consist of 7 words, each word separated by a space.
* Line 3 must consist of 5 words, each word separated by a space.
## Examples
```
The man in the suit
is the same man from the store.
He is a cool guy.
```
**Result:** True
```
Whitecaps on the bay:
A broken signboard banging
In the April wind.
```
**Result:** False
---
## Rules
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.
* Standard code-golf loopholes apply. Cheating is prohibited.
* Other boolean return values, such as `1` and `0`, are acceptable.
* A length-3 list of strings as an input is also acceptable.
* Valid haiku-w inputs should not have leading or trailing spaces, or multiple spaces separating words.
  
[Answer]
# JavaScript (ES6), ~~73~~ ~~72~~ ~~64~~ ~~63~~ ~~54~~ ~~42~~ 39 bytes
*Thanks to Neil for saving 13 bytes*
```
a=>a.map(b=>b.split` `.length)=='5,7,5'
```
## Explanation
This is a fat-arrow function that takes an array of strings as argument. It replaces each line by its word count. If it is a haiku-w, `a` now contains an array of a five, a seven and a five again. Since JavaScript doesn't allow us to compare 2 arrays at the same time, the array is converted to a string first, and then compared. This results in a boolean that is returned.
[Answer]
# AWK (GNU Awk), ~~24~~, ~~30~~, ~~28~~, 20 bytes
**Golfed**
```
517253==$0=q=q NF NR
```
Will output "517253" for *True*, and empty string for *False*.
> 
> In awk, any nonzero numeric value or any nonempty string value is true. Any other value (zero or the null string, "") is false
> 
> 
> 
[The GNU Awk User's Guide](https://www.gnu.org/software/gawk/manual/html_node/Truth-Values.html)
**How It Works**
Each awk statement (rule) consists of a pattern (or expression) with an associated action:
```
pattern {action}
```
Awk will read the input line by line (record by record) and evaluate pattern expression to see if a corresponding action is to be invoked.
The code above is a standalone Awk expression (pattern) w/o the action block, which is implied to be `{print $0}` in that case.
It should be read right-to-left:
`q=q NF NR`
Append a **N**umber of **F**ields (words) and **N**umber of **R**ecords (i.e. the current line number), to the variable *q*.
This way, when processing a proper Haiku-w, *q* will be set to:
* *51* - on line #1 (5 words)
* *5172* - on line #2 (5 words + 7 words)
* *517253* - on line #3 (5 words + 7 words + 5 words)
`$0=q`
Assign the newly computed value of *q* to *$0* (which holds the whole current line/record by default).
`517253==$0`
Compare it with a "signature" for a proper Haiku-w (517253),
if there is a match, the whole expression evaluates to "true" and
a corresponding action (implicit `print $0`) is run, sending
"517253" to stdout (True), otherwise output will be empty (False).
Note that this will properly recognize a Haiku-w, even if it is followed by an arbitrary number of garbage lines, but I believe that is ok, as:
> 
> A length-3 list of strings as an input is also acceptable.
> 
> 
> 
(i.e. we can assume the input to be 3 lines long)
**Test**
```
>awk '517253==$0=q=q NF NR'<<EOF
The man in the suit
is the same man from the store.
He is a cool guy.
EOF
517253
```
[Try It Online !](http://www.tutorialspoint.com/execute_bash_online.php?PID=0Bw_CjBb95KQMYU90TzNtb1FyRnM)
[Answer]
# [Python](https://docs.python.org/3/), 42 bytes
```
lambda l:[s.count(' ')for s in l]==[4,6,4]
```
[**Try it online!**](https://tio.run/nexus/python3#dYq9CgIxEAZ7n@LrLoFgdVgIeZKY4tRdXIjZIz93vn20Fq4bZobhcRtped@fC9I11PNDe25mwmRZCyokI0Xvw@wubo5jLfLLbILktTdjHf4hWjs0E9quaK9CBNZewLLR6cCjygeVNspHxxc)
Takes input as a list of lines, with the words separated by single spaces.
As we're guaranteed there'll be no leading or trailing spaces, and only single spaces will seperate each word, we can verify a w-haiku by simply counting the spaces in each line. 
We do this in a list comprehension, to create a list of the space-counts. If it is a correct haiku, it should look like `[4, 6, 4]`, so we compare it with this and return the result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 9 bytes
```
ċ€⁶⁼“¥©¥‘
```
[Try it online!](https://tio.run/nexus/jelly#@3@k@1HTmkeN2x417nnUMOfQ0kMrDy191DDj////0eohGakKuYl5Cpl5CiVAZnFpZom6jnpmMYSXmAuRTSvKz4WIlOQXpeoBVXikKgAVJSok5@fnKKSXVuqpxwIA)
## Explanation
```
ċ€⁶⁼“¥©¥‘  Input: length-3 list of strings
 €         For each string
ċ ⁶          Count the number of spaces
    “¥©¥‘  Convert string to code page indices, makes [4, 6, 4]
   ⁼       Match
```
[Answer]
## Batch, 102 bytes
```
@echo off
call:c&&call:c 2||exit/b
:c
set/an=%1+5
set/ps=
for %%W in (%s%)do set/an-=1
exit/b%n%
```
Exits with non-zero errorlevel as soon as it reads a line with the wrong number of words.
[Answer]
# Mathematica, 21 bytes
```
{4,6,4}==Count@" "/@#&
```
Unnamed function taking a list of lists of characters as input and returning `True` or `False`. Simply counts how many spaces are in each list of characters, which under the rules of the challenge correlate perfectly with the number of words in each line.
Previous submission:
# Mathematica, 31 bytes
```
Length/@StringSplit/@#=={5,7,5}&
```
Unnamed function taking a list of strings as input and returning `True` or `False`. 
[Answer]
## Haskell, ~~34~~ 33 bytes
```
f l=[sum[1|' '<-c]|c<-l]==[4,6,4]
```
[Try it online!](https://tio.run/nexus/haskell#JYq9CsMgGEVf5SKFLCZQCJni3gfoJg4i2gh@WvwZCnl3K7jdc8/pDkHI0kg@7wXLuRp1m3MNSgi584PvqpP2EQLf7GPFAw6SvS8L0hFD1DFL85Vx5sskTdO6nGg@NWW7jeJlMSINk1LAp/02pvof "Haskell – TIO Nexus").
Edit: thanks to @xnor for a byte!
[Answer]
# [Retina](https://github.com/m-ender/retina), 12 bytes
```
M%` 
^4¶6¶4$
```
(there's a trailing space after the first line)
[Try it online!](https://tio.run/nexus/retina#@@@rmqDAFWdyaJvZoW0mKv//h2SkKuQm5ilk5imUAJnFpZklXJnFEHZiLkQurSg/FyJSkl@UqsflkaoAVJKokJyfn6OQXlqpBwA "Retina – TIO Nexus")
* `M%`` - Count the number of spaces in each line.
	+ `M` - Match mode - print the number of matches.
	+ `%` - for each line
	+ ``` - separate configuration and regex pattern
	+ - just a space.
* `^4¶6¶4$` - There should be 4, 6, and 4 spaces, and exactly three lines.
	+ `¶` matches newlines. The rest is a simple regular expression.
Prints `1` for valid input, `0` for invalid.
[Answer]
# [PowerShell](https://github.com/PowerShell/PowerShell), 43 bytes
```
"$args"-replace'\S'-match'^(    )
\1  
\1$'
```
[Try it online!](https://tio.run/nexus/powershell#JYrBCoAgGIPvPcWIwDoU9Bbd6xjRj/ypkBpqh57eBHcY@7bltqOgYjsGfm6SLPZVjJaS1OLoUTQ0@wwU60TOedMMSw7GIZUYX5NOZ2IFsnW8gre1ST7wdLqFUT4E6f0N9X7TDw "PowerShell – TIO Nexus")
### Explanation
Takes input as a newline separated string.
Removes all non-whitespace, then checks to see that it matches "4 spaces, newline, 6 spaces, newline, 4 spaces newline" exactly, using a regex.
The capture group matches 4 spaces, the backreference `\1` refers to that. Newlines are embedded in the string. Note the second line of the regex contains two spaces after the backreference.
[Answer]
# Python, ~~58~~ 44 bytes
```
lambda h:[len(l.split())for l in h]==[5,7,5]
```
-14 by tbodt
[Answer]
# [Perl](https://www.perl.org/), 26 bytes
24 bytes of code + 2 bytes for `-ap` flags.
```
$m.=@F}{$_=$m==575&$.==3
```
[Try it online!](https://tio.run/nexus/perl#U1YsSC3KUdAtSPyvkqtn6@BWW60Sb6uSa2tram6qpqJna2v8/39IRqpCbmKeQmaeQgmQWVyaWcKVWQxhJ@ZC5NKK8nMhIiX5Ral6XB6pCkAliQrJ@fk5CumllXoA "Perl – TIO Nexus")
[Answer]
# Pyth, 9 bytes
```
qj464T/R;
```
A program that takes input of a list of `"quoted strings"` and prints `True` or `False` as appropriate.
[Test suite](http://pyth.herokuapp.com/?code=qj464T%2FR%3B&test_suite=1&test_suite_input=%5B%22The+man+in+the+suit%22%2C+%22is+the+same+man+from+the+store.%22%2C+%22He+is+a+cool+guy.%22%5D%0A%5B%22Whitecaps+on+the+bay%3A%22%2C+%22A+broken+signboard+banging%22%2C+%22In+the+April+wind.%22%5D&debug=0)
**How it works**
```
qj464T/R;   Program. Input: Q
qj464T/R;Q  Implicit variable fill
     T      Are the base-10
 j          digits
  464       of 464
q           equal
      /     to the number
        ;   of spaces
       R    in each string
         Q  in the input?
            Implicitly print
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 11 bytes
*Saved lots of bytes thanks to @ETHproductions*
This takes an array of three strings as input.
```
®¸lÃ¥"5,7,5
```
[Run it online!](http://ethproductions.github.io/japt/?v=1.4.3&code=rrhsw6UiNSw3LDU=&input=WyJUaGUgbWFuIGluIHRoZSBzdWl0IgoiaXMgdGhlIHNhbWUgbWFuIGZyb20gdGhlIHN0b3JlIgoiSGUgaXMgYSBjb29sIGd1eS4iXQ==)
[Answer]
## Pyke, ~~11~~ 9 bytes
```
dL/uq
```
[Try it here!](http://pyke.catbus.co.uk/?code=dL%2Fu%03%04%06%04q&input=%5B%22The+man+in+the+suit%22%2C+%22is+the+same+man+from+the+store.%22%2C+%22He+is+a+cool+guy.%22%5D)
```
dL/       -  map(i.count(" "), input)
        q - ^ == V
   u  -  [4, 6, 4]
```
After the `u` byte there are the following bytes: `0x03 0x04 0x06 0x04`
[Answer]
# J, 12 bytes
```
4 6 4=#@;:@>
```
The input is a boxed list of strings.
## Explanation
This is a fork with a constant left tine. This checks the result of the right tine, `#@;:@>`, for equality with `4 6 4`. The right time unboxes each (`>`), then (`@`) converts each string to words (`;:`), then (`@`) takes the length of each (`#`).
[Answer]
## R, 48 bytes
```
all(stringr::str_count(scan(,"")," ")==c(4,6,4))
```
Reads a 3-length character vector from stdin and works by counting the number of spaces. To count the number of spaces we use the `str_count` from the `stringr` package which can count occurrences based on a regex pattern.
An alternative approach without using packages could be:
```
all(sapply(scan(,""),function(x)length(el(strsplit(x," "))))==c(5,7,5))
```
[Answer]
## C 142 bytes
```
void f(){char *c;l=3;s[3]={0};while(l>0){if(*c==' ')s[l-1]++;if((*c=getchar())=='\n'){l--;}}printf("%d",(s[0]==4 && s[1]==6 && s[2]==4)?1:0);}
```
Ungolfed version: 
```
void f()
{
  char *c;
  c = (char *)malloc(sizeof(char)); 
  int l=3;
  int s[3]= {0};
  while(l>0)
  {  
    if(*c==' ')
    s[l-1]++;
    if( (*c=getchar())=='\n')
    {    
      l--;
    }   
  }
  printf("%d",(s[0]==4 && s[1]==6 && s[2]==4)?1:0);
}
```
Returns 1 for 5/7/5 sequence else 0.
A positive testcase:
[![enter image description here](https://i.stack.imgur.com/xmZUX.gif)](https://i.stack.imgur.com/xmZUX.gif)
[Answer]
# C++, 357 bytes
Sort of new to code golf, but this is the best I could do quickly
```
#include <iostream>
using namespace std;
int n(std::string s)
{
    int b = 0;
    for(char c: s)
        if(c == ' ') b++;
    cout << "C = " << b;
    return b;
}
int main()
{
    string a, b, c;
    getline(cin, a);
    getline(cin, b);
    getline(cin, c);
    if(n(a)==4 && n(b)==6 && n(c)==4)
        cout<<'1';
    else cout << '0';
    return 0;
}
```
[Answer]
# Ruby 1.9.3
Not golfed, but is itself a haiku-w
```
def haiku_w(input)
  lines = input.split("\n")
  lengths = lines.map(&:split).map(&:length)
  lengths.eql?([5,7,5])
end
```
or...
```
lines equals input split (newlines)
lengths equals lines map split map length
lengths equals five seven five?
```
Unfortunately doesn't work with leading whitespace on any lines, but does cope with trailing.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~57~~ 64 bytes
**Edit** Corrected with the addition of 7 bytes after feedback from @Dada. Thanks!
```
i,j=input,''
for x in i():j+=`len(x.split())`+' '
i(j=='5 7 5 ')
```
[Try it online!](https://tio.run/nexus/python2#JYtLCgMhEET3c4rGTSsj7oZAwH0OkAOMBCdp8TP4gcnpjcFdVb1XnaTTFM9WJeJypAwXUATi4u5WvXsb@aXK6alyIfYVARfiTmvc4AYboOidPT8Wgon/Xx2xNKpMMiqzmTDpkVOYS03ZqmE8LAzJwCslD@/2VewH "Python 2 – TIO Nexus")
Not the shortest Python answer by a long way but just wanted to use the new trick I learned recently of using `input()` to display the output and save a `print` statement. Takes a list of lines as input. Requires Ctrl C (or any other key-press for that matter) to terminate the program (with an exception) in a terminal but works fine without on TIO.
[Answer]
# MATL, 16 bytes
```
"@Y:Ybn&h][ACA]=
```
The input is a cell array of strings and returns a [truthy or falsey array](https://tio.run/nexus/matl#@5@QqQABqgpu@UUKiTk5Cpl5BaUlxVz2CnAZzzSFkqLSVC51EKnOVYuQSc0pTlVISwSSXOpgSp0r1iXk/39DLgOuaEMFIIzlijZQAMJYEN8AyAcA).
[**Try it Online**](https://tio.run/nexus/matl#@6/kEGkVmZSnlhEb7ejsGGv7/3@1ekhGqkJuYp5CZp5CCZBZXJpZoq6jnlkM4SXmQmTTivJzISIl@UWpekAVHqkKQEWJCsn5@TkK6aWVeuq1AA)
**Explanation**
```
        % Implicitly grab input
"       % For each element in the cell array
@Y:Yb   % Split it on spaces
n       % Count the number of elements
&h      % Horizontally concatenate everything on the stack
[ACA]   % Create the array [5 7 5]
=       % Perform an element-wise equality
        % Implicitly display the truthy/falsey array
```
[Answer]
# MATLAB / Octave, 38 bytes
```
@(x)cellfun(@(y)sum(y==32),x)==[4 6 4]
```
This solution accepts a cell array of strings as input, counts the number of spaces in each line and then compares the result to the array `[4 6 4]` and yields a truthy (all values are 1) or falsey (any value is zero) array.
[Online demo](http://ideone.com/KK8UDN)
[Answer]
# [Perl 6](http://perl6.org/), 25 bytes
```
{.lines».words~~(5,7,5)}
```
[Answer]
## Clojure, 44 bytes
```
#(=(for[l %](count(filter #{\ }l)))'(4 6 4))
```
Input is list of strings.
Function finds only spaces and counts them.
This explanation is a Haiku. :)
[Answer]
# Java 7, 154 bytes
```
class M{public static void main(String[]a){System.out.print(a.length==3&&a[0].split(" ").length==5&a[1].split(" ").length==7&a[2].split(" ").length==5);}}
```
The program requirement and potential of having less or more than three lines, not too mention Java's verbosity itself, causes this 'golfed' code to be pretty big..
**Ungolfed:**
[Try it here.](https://ideone.com/mW9xaG)
```
class M{
  public static void main(String[] a){
    System.out.print(a.length == 3
        && a[0].split(" ").length == 5
         & a[1].split(" ").length == 7
         & a[2].split(" ").length == 5);
  }
}
```
[Answer]
# SimpleTemplate, 77 bytes
Sadly, the regular expression aproach is the shortest.
```
{@if"@^([^\s]+ ?){5}\s([^\s]+ ?){7}\s([^\s]+ ?){5}+$@"is matchesargv}{@echo1}
```
Requires that the text is given as the first argument, with \*NIX-style newlines.
This won't work with Windows-style newlines.
**Ungolfed:**
```
{@if "@^([^\s]+ ?){5}\s([^\s]+ ?){7}\s([^\s]+ ?){5}+$@"is matches argv}
    {@echo 1}
{@/}
```
---
**Non-regex based, 114 byes**
```
{@setR 1}{@eachargv asL keyK}{@php$DATA[L]=count(explode(' ',$DATA[L]))!=5+2*($DATA[K]&1)}{@set*R R,L}{@/}{@echoR}
```
This requires that each line is given as an argument to the function.
**Ungolfed:**
```
{@set result 1}
{@each argv as line key k}
    {@php $DATA['line'] = count(explode(' ', $DATA['line'])) != 5+2*( $DATA['k'] & 1 )}
    {@set* result result, line}
{@/}
{@echo result}
```
[Answer]
# Stacked, 22 bytes
```
[' 'eq sum]map(4 6 4)=
```
Takes input from the top of the stack as a list of character strings, as such:
```
($'The man in the suit' $'is the same man from the store.' $'He is a cool guy.')
```
## Explanation
```
[' 'eq sum]map(4 6 4)=
[         ]map          map the following function over each item
 ' 'eq                  vectorized equality with ' '
       sum              summed
              (4 6 4)=  is equal to (4 6 4)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
€#€g575SQ
```
[Try it online!](https://tio.run/nexus/05ab1e#@/@oaY0yEKebmpsGB/7/H60ekpGqkJuYp5CZp1ACZBaXZpao66hnFkN4ibkQ2bSi/FyISEl@UaoeUIVHqgJQUaJCcn5@jkJ6aaWeeuzXvHzd5MTkjFQA "05AB1E – TIO Nexus")
**Explanation**
```
€#         # split each line on spaces
  €g       # get length of each line
    575    # push the number 575
       S   # split into list of digits
        Q  # compare for equality
```
[Answer]
# [Java (OpenJDK)](http://openjdk.java.net/), 82 bytes
-2 bytes thanks to @corvus\_192!
```
s->s[0].split(" ").length==5&s[2].split(" ").length==5&s[1].split(" ").length==7
```
[Try it online!](https://tio.run/nexus/java-openjdk#dU5BasMwEDzLr1h0CPahIi2UHoL7gvaUo8lhbcuOiCwZ7TqhBL9dlZKSXlrmMOzMMLPz0lrTQWeRCD7ROLgWwjjWYcBOwwdObY9XmO@x1nur0UFYXLnnYNzYHOCI5rRcqh2shfjJESMnOnvTw5RKf8MYRqryhrhXw1BHenqnZntQNFvDpQRZKavdyMe6ft1sqHn533r@03qLQuzSxP6LWE/KL6zmtM/WlYPKv9@@qFJkLdYYJcLkMVx86AEzZJS3o30gSwhZJHiw/AY "Java (OpenJDK) – TIO Nexus")
It looks *so golfable* but without a builtin map function, I can't find a good way. Iterating through the array is a few bytes longer, as is writing a map function using streams.
Lambda expression takes an array of Strings and returns a Boolean.
[Answer]
# SmileBASIC, ~~96~~ 94 bytes
```
INPUT A$,B$,C$?C(A$,4)*C(B$,6)*C(C$,4)DEF C(S,E)WHILE""<S
INC N,POP(S)<"!
WEND
RETURN N==E
END
```
]