Skip to content

Commit

Permalink
Merge pull request #327 from AnujaP2020/master
Browse files Browse the repository at this point in the history
Fix issue #288 - added implementation of duplicatesAndUnique
  • Loading branch information
prathasirisha committed Sep 22, 2023
2 parents 0152f62 + a5bc068 commit 4428a74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,17 @@ public String distinctLetters()

public Triple<CharBag, CharBag, CharSet> duplicatesAndUnique()
{
// TODO: Find all of the alphabetic letters from this.getHaikuAsCharAdapter(), convert them to lowercase
// and store them in a MutableCharBag.
// Hint: Look at select, collectChar, and toBag
MutableCharBag chars = null;

// TODO: Find all the chars with duplicates
// Hint: Find a method on MutableCharBag that returns duplicates
CharBag duplicates = null;

// TODO: Find all the unique chars
// Hint: Find a method on MutableCharBag that returns unique chars
CharSet unique = null;
// Find all of the alphabetic letters, convert them to lowercase
MutableCharBag chars = this.getHaikuAsCharAdapter()
.select(Character::isAlphabetic)
.collectChar(Character::toLowerCase)
.toBag();

// Find all the chars with duplicates
CharBag duplicates = chars.selectDuplicates();

// Find all the unique chars
CharSet unique = chars.selectUnique();

return Tuples.triple(chars, duplicates, unique);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void distinctLetters()
Assertions.assertEquals("breakingthoupvmwcdflsy", distinctLetters);
}

// @Test // Uncomment once duplicatesAndUnique is implemented for EC
// @Tag("SOLUTION")
@Test
@Tag("SOLUTION")
public void duplicatesAndUnique()
{
Triple<CharBag, CharBag, CharSet> triple = new TextProcessorEC().duplicatesAndUnique();
Expand Down

0 comments on commit 4428a74

Please sign in to comment.