Skip to content

The Word Wrap kata is a coding exercise that challenges developers to implement a function or method that wraps a given input string to a specified line length while maintaining word integrity. This means that words should not be split across lines, and the output should have lines no longer than the specified length.

Notifications You must be signed in to change notification settings

lean-mind/word-wrap-wk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Wrap Kata in C#

Problem Description

You write a class called Wrapper, that has a single static function named wrap that takes two arguments, a string, and a column number. The function returns the string, but with line breaks inserted at just the right places to make sure that no line is longer than the column number. You try to break lines at word boundaries.

Like a word processor, break the line by replacing the last space in a line with a newline.

For example, here is a sample test case (in C#):

Wrapper.wrap("word word", 5).Should().Be("word\nword");

Technologies used

This boilerplate include:

How to use run the tests

JetBrains Rider

  1. Install JetBrains Rider
  2. Open the repository in JetBrains Rider
  3. Run the tests with the Test Explorer
  4. The tests should run and pass

Visual Studio Code

  1. Install Visual Studio Code
  2. Install the C# extension
  3. Open the repository in Visual Studio Code
  4. Run the tests with the Test Explorer
  5. The tests should run and pass
  6. You can also run the tests with the command dotnet test in the root directory of the repository

About

The Word Wrap kata is a coding exercise that challenges developers to implement a function or method that wraps a given input string to a specified line length while maintaining word integrity. This means that words should not be split across lines, and the output should have lines no longer than the specified length.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published