Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo anargram => anagram #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Algorithms/Strings/Permutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public static HashSet<string> ComputeDistinct(string source)
}

/// <summary>
/// Determines if the Other string is an anargram of the Source string.
/// Determines if the Other string is an anagram of the Source string.
/// </summary>
public static bool IsAnargram(string source, string other)
public static bool IsAnagram(string source, string other)
{
if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(other))
return false;
Expand All @@ -83,7 +83,7 @@ public static bool IsAnargram(string source, string other)
}
for (int i = 0; i < len; i++)
{
// Inputs are not Anargram if characers from *other are not present in *source.
// Inputs are not Anagram if characers from *other are not present in *source.
if (!hashSetSourceChars.Contains(other[i])) return false;
if (!hashSetOtherChars.Contains(source[i])) return false;
}
Expand Down
12 changes: 6 additions & 6 deletions UnitTest/AlgorithmsTests/StringPermutationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ public static void DoTest()

var one = "abcdefg";
var two = "dabcgfe";
Assert.True(Permutations.IsAnargram(one, two) == true);
Assert.True(Permutations.IsAnagram(one, two) == true);

one = "123456";
two = "789123";
Assert.True(Permutations.IsAnargram(one, two) == false);
Assert.True(Permutations.IsAnagram(one, two) == false);

one = "abc";
two = "bbb";
Assert.True(Permutations.IsAnargram(one, two) == false);
Assert.True(Permutations.IsAnagram(one, two) == false);

one = "acdf";
two = "bcde";
Assert.True(Permutations.IsAnargram(one, two) == false);
Assert.True(Permutations.IsAnagram(one, two) == false);

one = "I am legion"; // L is small
two = "Legion I am"; // L is capital
Assert.True(Permutations.IsAnargram(one, two) == false);
Assert.True(Permutations.IsAnagram(one, two) == false);

one = "I am legion"; // L is small
two = "legion I am"; // L is small
Assert.True(Permutations.IsAnargram(one, two) == true);
Assert.True(Permutations.IsAnagram(one, two) == true);
}
}
}