[48in24 Exercise] [07-30] Kindergarten Garden

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 Kindergarten Garden from Jul 30 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 Kindergarten Garden
  • 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.

I’ve currently gathered the following solutions to feature:

  1. Python: explicit indexing, index of student as index
    Index into the rows explicitly using index of student name

  2. F#: explicit indexing, student name’s first letter as index and pattern matching
    Index into the rows explicitly and use map and pattern matching to convert to plant

  3. Nim: enum with char as value
    Easily convert from char to enum through enum value and student’s first letter

  4. Clojure: functional pipeline, partition, zip and combine
    Threading macro, partition rows, zip with student and combine

  5. Ruby: metaprogramming, regex to partition and transpose rows
    Use regular expression to partition, then transpose to make rows cols

If anyone has more suggestions, do let us know!

I’ll port for CoffeeScript and LFE.

1 Like

I’ve ported to Raku: Implement kindergarten-garden by m-dango · Pull Request #728 · exercism/raku · GitHub

Additionally, I have a solution in Perl which transforms the input via and index created with ord being used in substr: m-dango's solution for Kindergarten Garden in Perl on Exercism

I’ll tackle Erlang and Red next.

Just to be clear, that’s quite similar to JDygert's solution for Kindergarten Garden in F# on Exercism, right? But a lot more succinct.

I’m not too familiar with F#, but having a look the identical parts are.

Operating on 2 distinct lines by splitting them:

let rows = diagram.Split('\n')
split /\n/, $diagram

Converting the first letter of the name into an index:

let n = int (student.[0]) - int 'A'
ord($student) - ord('A')

And as for the differences:

F# looks to use an index for each individual character, whereas Perl uses the index to extract a 2 character string from both rows, which is then split. These both result in an array of 4 letters.

F# maps each individual letter from the resulting array, Perl uses the entire list as a way of creating a hash slice.

Fundamentally they appear to move in the same direction to achieve their result, with some variation in how the plant letters are obtained and consumed. If they’re a bit too similar I can invesigate a more distinct approach.

I do think they’re very similar. I could feature both though, where yours would be showcasing a more succinct way to do it.

2 Likes
3 Likes