41
5
A haiku 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, so the shortest answer in bytes wins.
- Standard code-golf loopholes apply. Cheating is prohibited.
- Other boolean return values, such as
1
and0
, 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.
Must the input be a single string (containing newlines), or can it be a length-3 list of strings? – Greg Martin – 2017-01-29T10:28:32.690
A length-3 list of strings is acceptable. Editing the OP to reflect this. – DomTheDeveloper – 2017-01-29T10:30:57.710
1Will the haiku-w always contain 3 lines? – user41805 – 2017-01-29T10:31:54.863
1Yes. If the input contains more than or fewer than 3 lines, the program should return false. – DomTheDeveloper – 2017-01-29T10:33:54.597
5Will there ever be leading or trailing spaces on any line? Or multiple spaces separating words? – Greg Martin – 2017-01-29T10:34:38.700
1Good question. Valid haiku-w inputs should not have leading or trailing spaces, or multiple spaces separating words. – DomTheDeveloper – 2017-01-29T10:38:07.300
8
By the way, clarifications like this are a primary reason to post proposed questions in the Sandbox first. :)
– Greg Martin – 2017-01-29T10:43:26.49711Bonus points for submissions where the code itself is a haiku-w. – Glorfindel – 2017-01-30T07:22:54.233
1
@Glorfindel - done. http://codegolf.stackexchange.com/a/108849/9524
– ymbirtt – 2017-02-01T09:58:33.277