Tracks
/
Crystal
Crystal
/
Exercises
/
Parallel Letter Frequency
Parallel Letter Frequency

Parallel Letter Frequency

Medium

Instructions

Count the frequency of letters in texts using parallel computation.

Parallelism is about doing things in parallel that can also be done sequentially. A common example is counting the frequency of letters. Employ parallelism to calculate the total frequency of each letter in a list of texts.

Implementation

For building a concurrent/parallel program in Crystal, might this resource prove useful. In Crystal 1.19 a new Sync library was added which adds several primitives to make it easier to make high performance concurrent/parallel programs.

The online environment for this exercise is a bit different from most other exercises. Instead of compiling Crystal into a single-threaded binary, this exercises uses Crystal's experimental multi-threading capabilities. As such, the execution might behave differently than expected in some environments.

For local development, it is recommended that you have Crystal version 1.19.0 or later installed, and add -Dpreview_mt flag when compiling or running your code to enable multi-threading support.

Edit via GitHub The link opens in a new window or tab
Crystal Exercism

Ready to start Parallel Letter Frequency?

Sign up to Exercism to learn and master Crystal with 26 concepts142 exercises, and real human mentoring, all for free.

Deep Dive into Parallel Letter Frequency!

We explore the differences between concurrency and parallelism, looking at different approaches taken by languages such as JavaScript, Go, Elixir and Rust.