GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — daily_coding_problem/problems/28/problem_28.py at master · ihossai4/daily_coding_problem Expand file tree/ Copy pathproblem_28.pyMore file actions 20 lines (16 loc) · 990 Bytes / Copy pathproblem_28.pyFile metadata and controls20 lines (16 loc) · 990 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def coding_problem_28(word_list, max_line_length): """ Write an algorithm to justify text. Given a sequence of words and an integer line length k, return a list of strings which represents each line, fully justified. More specifically, you should have as many words as possible in each line. There should be at least one space between each word. Pad extra spaces when necessary so that each line has exactly length k. Spaces should be distributed as equally as possible, with the extra spaces, if any, distributed starting from the left. If you can only fit one word on a line, then you should pad the right-hand side with spaces. Each word is guaranteed not to be longer than k. Example: >>> coding_problem_28(["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"], 16) ['the quick brown', 'fox jumps over', 'the lazy dog'] """ pass if __name__ == '__main__': import doctest doctest.testmod(verbose=True) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |