6 kyu
Text align right
228 of 408depperm
Description:
Your task in this Kata is to emulate text justify right in monospace font. You will be given a single-lined text and the expected justification width. The longest word will never be greater than this width.
Here are the rules:
- Use spaces to fill in the gaps on the left side of the words.
- Each line should contain as many words as possible.
- Use '\n' to separate lines.
- Gap between words can't differ by more than one space.
- Lines should end with a word not a space.
- '\n' is not included in the length of a line.
- Last line should not contain '\n'
Example with width=30:
Bacon ipsum dolor amet
excepteur ut kevin burgdoggen,
shankle cupim dolor officia
ground round id ullamco
deserunt nisi. Commodo tail
qui salami, brisket boudin
tri-tip. Labore flank laboris,
cow enim proident aliqua sed
hamburger consequat. Sed
consequat ut non bresaola
capicola shoulder excepteur
veniam, bacon kevin. Pastrami
shank laborum est excepteur
non eiusmod bresaola flank in
nostrud. Corned beef ex pig do
kevin filet mignon in irure
deserunt ipsum qui duis short
loin. Beef ribs dolore
meatball officia rump fugiat
in enim corned beef non est.
If you enjoyed this one and want more of a challenge try https://www.codewars.com/kata/text-align-justify/python
If you like bacon ipsum https://baconipsum.com
Algorithms
Strings
Similar Kata:
Stats:
Created | Nov 23, 2016 |
Published | Nov 23, 2016 |
Warriors Trained | 1062 |
Total Skips | 22 |
Total Code Submissions | 3018 |
Total Times Completed | 408 |
Python Completions | 228 |
JavaScript Completions | 194 |
Total Stars | 33 |
% of votes with a positive feedback rating | 97% of 137 |
Total "Very Satisfied" Votes | 128 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 10 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |