def break_13(text):
words = text.split()
lines = [[]]
for word in words:
last_line = sum(len(word) for word in lines[-1])
if (last_line + len(word) + len(lines[-1])) > 13:
lines.append([word])
else:
lines[-1].append(word)
return '\n'.join(' '.join(line) for line in lines)
I like the larger point of this article, which basically states that the way humans do tasks is different than how we should instruct computers to do tasks. However, to me this point is undermined by the description of writing a procedure near the end:> If you are good at abstracting, you’ll likely come up with three different scenarios for breaking a line. 1. you break it at the 10th character of a word if that word is longer than 10 characters. 2. You break it at the 11th character if that character is a space. 3. You look backwards from the 10th character looking for a space and if there is one, you break it there.
I think it is less valuable to break down your procedure into smaller pieces before given an estimate, and more valuable to have a good knowledge of what sorts of problems are hard and why they're hard. That way, you don't have to resort to glib phrases like "Write down a procedure to tie your shoes".