[48in24 Exercise] [03-05] Circular Buffer

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 Circular Buffer from Mar 05 onwards.

Staff jobs

These are things for Erik/Jeremy to do:

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

Community jobs

For each track:

  • Implement Circular Buffer
  • 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.

This week’s exercise was swapped relatively late. For that reason, two of the featured tracks (Groovy and Scala) don’t yet implement this exercise. It would be great if someone could add the exercise to those tracks before we feature this exercise.

I can add Circular Buffer for Groovy.


Haven’t tried this exercise before, but I can try porting it for CoffeeScript and maybe CFML depending on time.

1 Like

Working on bash.

1 Like
1 Like

PR withdrawn. Just because you can do it, doesn’t mean you should…

Open discussion: list of exercises to forego in bash


Just to re-iterate, we need to implement this exercise in Groovy and Scala as those are the featured languages. Is there anybody that can help with that?

I’ll work on Groovy

1 Like

@glennj Maybe ask @keiraville first if they are still on it so you can avoid wasting time

@keiraville I have an implementation ready for PR. Shall I go ahead?

Yes go ahead @glennj

Done soon:

I’m having some difficulties finding different types of approaches to this exercise.
So far, what I have is:

  • Derive from a Queue class
  • Backed by dynamic array
  • Backed by static array with read and write index
  • Backed by static array with read index and size
  • Implemented as immutable data structure
  • Implemented using gen_server

Let me know if you know of more solutions :)

Some solutions use an array with size == capacity + 1 and store read_index and write_index in the range [0, size)

I use an array with size == capacity , with read_index in the range [0, size) and write_index in the range [read_index, read_index + size] . Perhaps clearer would be read_index in the range [0, size) , count in the range [0, size] so then write_index can be calculated as (read_index + count) % size

@BNAndras with the risk of being too forward, you added the reverse-string exercise to Scala. Would you be comfortable in adding circular-buffer to Scala too? If not, no worries.

Sure, I can give it a try.

1 Like
1 Like