Commit 11c9224

mo <mokha@cisco.com>
2017-05-31 21:56:40
break as soon as we hit 0.
1 parent 54989b6
Changed files (1)
spec/text_justification_spec.rb
@@ -65,9 +65,9 @@ describe "text_justification" do
     end
     until spaces <= 0
       (words.size - 1).times do |n|
-        break if spaces <= 0
         words[n] << " "
         spaces -= 1
+        break if spaces == 0
       end
     end
     words.join
@@ -75,13 +75,11 @@ describe "text_justification" do
 
   def text_justification(words, length)
     lines = []
-
     until words.empty?
       spaces, line = next_line(words, length)
       line = pad(line, spaces)
       lines.push(line)
     end
-
     lines
   end