#Ruby 1.9.3
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.
#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.
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.
#Ruby 1.9.3
Not golfed, but is itself a haiku-w
def haiku_w(linesinput)
targetslines = 5, 7, 5input.split("\n")
lengths = lines.map(&:split).map(&:length)
targets.zip(lengths).alleql?(&:uniq![5,7,5])
end
or...
targetslines equals fiveinput sevensplit five(newlines)
lengths equals lines map split map length
targetslengths zipequals lengthsfive allseven uniquefive?
Takes the rule "A length-3 list of strings as an input is also acceptable" very literallyUnfortunately doesn't work with leading whitespace on any lines, in that it gives the wrong outputbut does cope with lists of length 4 or moretrailing.
#Ruby 1.9.3
Not golfed, but is itself a haiku-w
def haiku_w(lines)
targets = 5, 7, 5
lengths = lines.map(&:split).map(&:length)
targets.zip(lengths).all?(&:uniq!)
end
or...
targets equals five seven five
lengths equals lines map split map length
targets zip lengths all unique?
Takes the rule "A length-3 list of strings as an input is also acceptable" very literally, in that it gives the wrong output with lists of length 4 or more.
#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.
#Ruby 1.9.3
Not golfed, but is itself a haiku-w
def haiku_w(lines)
targets = 5, 7, 5
lengths = lines.map(&:split).map(&:length)
targets.zip(lengths).all?(&:uniq!)
end
or...
targets equals five seven five
lengths equals lines map split map length
targets zip lengths all unique?
Takes the rule "A length-3 list of strings as an input is also acceptable" very literally, in that it gives the wrong output with lists of length 4 or more.