[48in24 Exercise] [08-27] Pascal's Triangle

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 Pascal’s Triangle from Aug 27 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 Pascal’s Triangle
  • 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. Go: for loops
    Use for loops to iterate over the rows and columns

  2. Standard ML: recursion
    Use recursion

  3. F#: scan on rows
    Use scan to incrementally build up the rows

  4. F#: scan on row
    Use scan to incrementally build up the row

  5. Kotlin: generate lazy sequence
    Generate a lazy sequence (like scan) and take the N rows

  6. AWK: for loop using previous row
    Use a for loop and use previous rows values

  7. Prolog: pairwise combine previous row with 0 prepended and appended
    Get the previous row, and map that with 0 prepended and appended

  8. Nim: use factorial to calculate the binomial
    Use the factorial to calculate the binomial

  9. Julia: binomial and comprehension
    Use the binomial function to generate the values and a comprehension to create the rows

If anyone has more suggestions, do let us know!

let me toot my own horn: I came up with an extremely minimal solution in awk: glennj's solution for Pascal's Triangle in AWK on Exercism

3 Likes

That is my favorite solution of them all @glennj!

@BethanyG, I noticed the Python track doesn’t use an apostrophe in the exercise name (see python/config.json at a47255b9bba08739a8752e5f1c88b2cc0f5f49c3 · exercism/python · GitHub). If this is in error, should I make a quick PR to fix that?

@BNAndras Thanks for the head’s up! :smile: I was in there this morning re-ordering the Track Docs (thanks @glennj for bringing up and getting that issue fixed!), so I went ahead and fixed it:

[Python Track Config] Changed `Pascals Triangle` to `Pascal's Triangle` for the Exercise name. by BethanyG · Pull Request #3744 · exercism/python · GitHub.

Let’s hope I didn’t bork anything. :wink:

1 Like

@ErikSchierboom – FYI, the Python track has forced a recursive implementation here (not that you need to feature a Python solution). Might or might not be worth a mention that different tracks have different implementations/requirements.

A cursory Github search shows CoffeeScript, D, Gleam, J, jq, Powershell, SML, Vlang, and Wren have “Pascals Triangle” as well.

Edit - I submitted PRs for CoffeeScript and D, but if anybody wants to deal with the others, go ahead. Otherwise, I’ll get to it by the end of the week.

1 Like

Fixed in jq.

PRs created in wren and gleam.

1 Like