# [48in24 Exercise] [04-09] Scrabble Score

This issue is a discussion for contributors to collaborate in getting ready to be featured in 48in24. Please refer to this forum topic for more info.

We will be featuring Scrabble Score from Apr 09 onwards.

### Staff jobs

These are things for Erik/Jeremy to do:

• Check/update exercise in Problem Specifications
• Create + schedule video

### Community jobs

For each track:

• Implement Scrabble Score
• Add approaches (and an approaches introduction!) for each idiomatic or interesting/educational approach.
• Add video walkthroughs (record yourself solving and digging deeper into the exercise).
• Highlight up to 16 different featured exercises (coming soon)

### Existing Approaches

You can use these as the basis for approaches on your own tracks. Feel free to copy/paste/reuse/rewrite/etc as you see fit! Maybe ask ChatGPT to translate to your programming language.

• `array-lookup` (c)
• `dictionary` (python)
• `enum` (python)
• `if-statements` (java)
• `map` (go, kotlin)
• `map-reduce` (java)
• `map-with-map` (scala)
• `match-with-map` (scala)
• `nested-tuple` (python)
• `switch-on-runes` (go)
• `switch-on-strings` (go)
• `switch-statement` (c, java)
• `two-sequences` (python)
• `when` (kotlin)

### Track Statuses

You can see an overview of which tracks have implemented the exercise at the #48in24 implementation status page.

I’ll work on porting the exercise to SQLite.

1 Like

I’ve currently gathered the following solutions to feature:

1. Go: iteration and switch
Use a for loop to iterate over the characters and a switch to determine the score

2. F#: pattern matching and higher-order function
Use pattern matching for the letter scores and higher-order function to sum

3. Python: IntEnum and generator expression
Define scores as an IntEnum class and use a generator expression

4. Groovy: string as key
Use a string as key

5. Rust: lookup table based on zero-based letter index
Create a lookup table where ‘a’ => 0, ‘z’ => 25 and then index into that table to sum

6. MIPS Assembly: lookup table based on zero-based letter index
Same solution as the Rust solution

7. AWK: multiple score by finding number of matching characters in string via regex
Use gsub with regex to find number of replacements i.e. chars for each score and multiply by score

8. JavaScript: build equation via regex replace of chars with their addition and eval
Regex replace characters with additions and build up equation and eval

If anyone has more suggestions, do let us know!

A variation on №5 I enjoyed was translating the string into another string in any base 11 through 16 as it shows an interesting equivalence of a one-to-one mapping from a single character to a single character without changing type before reduction. See on JavaSript track :

Wow, that is creative!

This is another good example where building the lookup table at compile time makes sense. In one of the previous 48in24 videos you featured a Nim solution that did this. If you have time, it would be great to show that you can also do that in modern C++ in a very readable fashion. Here’s one example:

Edit: The `constexpr` on line 35 makes sure that this can really happen at compile time.

Sorry, we’ve already recorded the video.

Alright, maybe there’ll be another chance…

exorcism-for-exercism - automatic summary of the video.

1 Like

Implement tests for Clojure

1 Like