Add Knapsack exercise (48in24)

I’d like to implement Knapsack, which is listed in https://exercism.org/challenges/48in24/implementation_status.

One small point I’d like input on is its difficulty rating. On the one hand, in a few other tracks that I checked, I see that its difficulty is in the 4-6 range.

One the other hand, to me it seems (as I’ve been working on an example solution) at least as difficult as the exercises that have a difficulty of 8 in the Ruby track:

The reason I think it’s difficult is because of the level of optimization that’s required. There are a lot of reasonable-sounding approaches that won’t pass the tests, either because they’re not efficient enough with large inputs or because of edge cases. My first two off-the-cuff attempts didn’t pass the tests for these reasons, and in the end I had to do some research on algorithm design in order to understand how to solve it—something I typically don’t have to do for a first-pass solution.

So I think this should be an 8, so as not to mislead students. But if we need to give it a “medium” difficulty to match other tracks, just let me know.

  1. Difficulties are track dependent. Something might be simple on one track and hard on another.
  2. Difficulties have been notoriously hard to get right, given how many factors/dimensions can affect them. If you search the forum/Discord for difficulty, you’ll find many discussions about them.

Thanks! That’s good to know.

After looking up Knapsack in a few other tracks just now, I did find outliers from the 4-6 difficulty range: C (7) and TypeScript (9). So I think I’ll go with 8.

I’ll open a PR as soon as I get the green light here.

1 Like

Go for it!

Thanks! PR: Add Knapsack exercise by fpsvogel · Pull Request #1644 · exercism/ruby · GitHub

2 Likes