nature-of-code / noc-book-2

The 2024 edition of The Nature of Code with p5.js. Includes Notion workflow and build system.
https://natureofcode.com
1.17k stars 82 forks source link

Exercise Solutions #55

Closed shiffman closed 2 weeks ago

shiffman commented 2 years ago

The first edition of the book came with some exercise solutions (not all). Picking up on the conversation from #54, I'm filing an issue (for later) to develop a way to either include exercise solutions in the book text itself or separate repo.

shiffman commented 1 month ago

It's time for me to finally get organized about the exercise solutions. @jasongao97 could we build a page identical to https://natureofcode.com/examples/ for this? As well as possible include a link to exercise solutions (when one exists) on the page itself? When I create one I can add a link to the p5 web editor sketch in Notion (similar to what we do with the examples.)

shiffman commented 1 month ago

We could start with this one! https://natureofcode.com/random/#exercise-010

shiffman commented 1 month ago

For exercise solutions that are already in the book, we can leave them as is and add them to the new exercise "index" page. For any new exercise solutions that get added after the fact, we'll mark them with a special emoji so that they are skipped in the PDF build. I lean towards including them on the website for now.

Screenshot 2024-09-24 at 9 32 37 AM

Maybe we use the previous "web only" emoji system?

sidwellr commented 1 month ago

The exercise solutions page will not be identical to the examples page. Unlike the examples, not all exercises are code (or even code snippets). For example Exercise 0.2 is two probability questions; clicking on it should go to a page with a short explanation of the answers (not just "0.59% and 0.45%").

More importantly, most exercises have multiple solutions. Especially open-ended ones like Exercise 0.4 (a paint splatter simulation), but even simple ones like Exercise 0.1 (walker with tendency to move down and right), with a note "The solution follows in the next section" has solutions besides the one in Example 0.3 (A walker that tends to move to the right). My solution to Exercise 0.10 (noise-based landscape) is quite different from the one in the book (https://editor.p5js.org/rsidwell/sketches/moPaJyM23 if you are interested).

So a couple of things to consider when designing the exercise solutions page:

  1. Should the solutions include explanatory text to help understand the solution? Or just the solutions themselves?
  2. Should the website contain multiple solutions to the exercises? Or just show one way to do it?
  3. Some readers who are having trouble with an exercise may appreciate a hint to help them figure it out rather than just seeing a solution. (But that's a whole lot of work!)
  4. How should readers contribute their own solutions to exercises (as the book invites them to)?
shiffman commented 1 month ago

These are great points! I hadn't considered this so thoroughly. I think, for now, I will focus on p5.js sketches that are "answers" to solutions. If you follow this discussion into #1025 you'll see the proposed language of "suggested answer", which I think covers the idea of "one suggested solution."

For readers to contribute, they can open an issue with their solution and I would manually add it. We could also create a markdown page in this github repo for additional "community" solutions if there is enough interest.

sidwellr commented 1 month ago

Another place for readers to share "community" solutions is the Passenger Showcase on the Coding Train website. The last paragraph of the Introduction also invites sharing there. There is just one problem: Passenger Showcase must be tied to a video, and not all NoC videos have been created yet. Perhaps you could find some time to create short introduction videos for each chapter to provide an anchor for reader contributions.

shiffman commented 4 weeks ago

Just connecting this with #1038

shiffman commented 2 weeks ago

Let's track this in #1025