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 #289 #346

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ public Triple<CharBag, CharBag, CharSet> duplicatesAndUnique()

public CharCharPair topVowelAndConsonant()
{
// TODO: Find all of the alphabetic letters from this.getHaikuAsCharAdapter(), convert them to lowercase,
// TODO: put them in a bag and then get the top 26 occurrences
// Hint: Look at select, collectChar, toBag, and topOccurrences
// Bonus: See if the same solution will work using asLazy
MutableList<CharIntPair> charIntPairs = null;

// TODO: Find the top vowel
// Hint: Use the detect method on MutableList with the isVowel method below to find the top vowel char value
char topVowel = 'a';
// TODO: Find the top consonant
// Hint: Use the detect method on MutableList with the isVowel method below to find the top consonant char value
char topConsonant = 'b';
private static final char DEFAULT_CHAR = ' ';
// Collecting all the alphabetic letters from getHaikuAsCharAdapter(), converting them to lowercase,
// putting them in a bag and then getting the top 26 occurrences.
MutableList<CharIntPair> charIntPairs = this.getHaikuAsCharAdapter()
.select(Character::isAlphabetic)
.collectChar(Character::toLowerCase)
.toBag()
.topOccurrences(26);

// Finding the top vowel.
CharIntPair topVowelPair = charIntPairs.detect(pair -> isVowel(pair.getOne()));
char topVowel = topVowelPair == null ? DEFAULT_CHAR : topVowelPair.getOne(); // Default to space if no vowel is found.

// Finding the top consonant.
CharIntPair topVowelPair = charIntPairs.detect(pair -> isVowel(pair.getOne()));
char topVowel = topVowelPair == null ? DEFAULT_CHAR : topVowelPair.getOne(); // Use the named constant here

return PrimitiveTuples.pair(topVowel, topConsonant);
}
Expand Down
2 changes: 1 addition & 1 deletion pom-jdk17.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.1.2</version>
<configuration>
<groups>SOLUTION</groups>
<excludedGroups>KATA</excludedGroups>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.1.2</version>
<configuration>
<groups>SOLUTION</groups>
<excludedGroups>KATA</excludedGroups>
Expand Down
Loading