Skip to content

Instantly share code, notes, and snippets.

@icecreamhead
icecreamhead / ScoreWordGame.java
Last active November 6, 2023 16:15
scoreWordGame (Cassidoo #325)
class ScoreWordGame {
static final String[] wordList = new String[]{"apple", "banana", "cherry", "date", "fig"};
static final Map<Character, Integer> letterScores = Stream.iterate(97, x -> x <= 122, x -> x + 1)
.collect(Collectors.toMap(x -> (char) (int) x, x -> x - 96));
static void scoreWordGame(String[] wordList, Map<Character, Integer> letterScores) {
Arrays.stream(wordList)
.map(w -> new Word(w, w.length() * w.chars().map(c -> letterScores.get((char) c)).sum()))

Keybase proof

I hereby claim:

  • I am icecreamhead on github.
  • I am icecreamhead (https://keybase.io/icecreamhead) on keybase.
  • I have a public key ASBB-zexELRmyEeREi5m-xn0CNgPMGXf-5-ad87JJqsK1wo

To claim this, I am signing this object: