The Anagrams Kata
The following is my C# implementation of the Anagrams Kata as described on cyber-dojo.com
Write a program to generate all potential anagrams of an input string.
For example, the potential anagrams of “biro” are
biro bior brio broi boir bori
ibro ibor irbo irob iobr iorb
rbio rboi ribo riob roib robi
obir obri oibr oirb orbi orib
Let’s write a test.
[Test]
public void NoCharacters()
{
var expected = new List<string> {""};
Assert.That(Anagrams.Of(""), Is.EqualTo(expected));
}
As is almost always the case, we start with the degenerate case of an empty string. We don’t do this solely to ensure the degenerate case is handled (that’s part of it), but with this first test we’re thinking about the API of our new code.