Commit d9309d3

mo <mokha@cisco.com>
2017-06-01 01:47:19
exit early on last line.
1 parent 11c9224
Changed files (1)
spec/text_justification_spec.rb
@@ -76,6 +76,11 @@ describe "text_justification" do
   def text_justification(words, length)
     lines = []
     until words.empty?
+      if words.size < 5 && words.join.size < length
+        result = words.join(' ')
+        lines.push(result + " " * (length - result.size))
+        break
+      end
       spaces, line = next_line(words, length)
       line = pad(line, spaces)
       lines.push(line)