Skip to content

Commit

Permalink
fix typo anargram => anagram
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandrofly committed Feb 21, 2021
1 parent 504140e commit 4740c6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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);
}
}
}

0 comments on commit 4740c6b

Please sign in to comment.