[48in24 Exercise] [03-12] Parallel Letter Frequency

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 Parallel Letter Frequency from Mar 12 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 Parallel Letter Frequency
  • 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.

Track Statuses

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

There are relatively few tracks that have implemented this exercise, so lots of opportunities for PRs :)

FYI: For those eager to implement this in Python. It’s foregone, and until Python 3.13 is out, it can’t really be implemented. After 3.13, all bets … may be off. :wink:

Python 3.13 is due out in October, but we probably won’t upgrade until 2025. There will probably be a lot of testing involved…

2 Likes

I’m not sure how do implement this properly in PowerShell. I’m a bit hazy about the parallel process there. And after some reading it seems like it is mostly to be used to run different jobs simultaneously without sharing the same resource.

Maybe I need to read more and keep digging, only a couple of exercises left to implement and they are mostly something specific that not every language can handle: bank account, react and paasio, and this one.

This exercise won’t make sense for many tracks. If so, best thing to do is to add the slug to the exercises.foregone key in the track config.json

I’ll be looking at Dart and Wren, but no promises.

I think I need to set this one to foregone for Vim script. It should be doable in some form for Racket and Red though.

2 Likes

I’ll work on Racket, but Red’s still available.

I guess this exercise should be foregone for x86-64 Assembly.

I opened this PR: [48in24 Exercise] [03-12] Parallel Letter Frequency.

1 Like

For this exercise’s video, I currently have these solutions and taling points. If you know more or better versions of these, let me know.

  1. C#: convert regular enumerable to async enumerable

Use AsParallel to convert regular enumerable to async enumerable with same API

  1. Elixir: use async stream

Use Elixir’s built in Task.async_stream function to use parallel processing

  1. Elixir: partition work via full text, not per string

Instead of partitioning via each string input, concatenate the inputs and partition by string

  1. Go: goroutines and communication via channels

Create a goroutine for each text and communicate via channels

  1. Delphi: locking

Lock the resource being updated to prevent concurrent access

  1. Java: use concurrent data type

Use a special data type that allows for safe concurrent updating

  1. Rust: only use async for large inputs

Don’t use async small inputs, as sequential processing is then likely faster

  1. F#: use async computation expression

Using an async {} block will make code run async

Mention:

  • Concurrency issues
  • Downside of using locks
  • Difference between threads and green threads
  • No magic bullet: performance can be worse (measure!)

Maybe talk about the difference between ‘concurrent’ and ‘parallel’, sharing a single thread concurrently is totally different from running on multiple cores in parallel.

2 Likes

PR for adding to V lang: Add Parallel Letter Frequency exercise by kahgoh · Pull Request #200 · exercism/vlang · GitHub

I’ll try adding for Gleam over the next couple of days.

1 Like
1 Like

Topic: Using “build in” concurrency (race=out of order, hyper=preserve oder) on lists/arrays resulting in one-liner solution.

Silly new person question… what is the blocker for Python? Something to do with the test runners?

The parallel processing primitives in concurrent.futures have been around since 3.2, and there were alternatives before that.

Hi @mcskinner :wave: welcome to the Exercism forums!

This is not a limitation in the test runner.

This exercise was originally marked foregone for Python back in 2017, and I haven’t had a good reason to override the original reasons for setting it to that status.

The reference to Python 3.13 was partially humorous, and partially a nod to the fact that multithreading and multiprocessing strategies will most likely change in the absence of the GIL.

1 Like