Skip to content

Conversation

@Thomaskri0801
Copy link

No description provided.

Copy link

@ninja-aruna ninja-aruna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. However, for ease of maintenace / reability., you could put letters with the same score in a loop that adds them to your hashmap like this:

private static final Map<Character, Integer> LETTER_SCORES = new HashMap<>();
static {
for (char c : new char[] { 'A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T' }) {
LETTER_SCORES.put(c, 1);
}
for (char c : new char[] { 'D', 'G' }) {
LETTER_SCORES.put(c, 2);
}
for (char c : new char[] { 'B', 'C', 'M', 'P' }) {
LETTER_SCORES.put(c, 3);
}
for (char c : new char[] { 'F', 'H', 'V', 'W', 'Y' }) {
LETTER_SCORES.put(c, 4);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants