Answer Key Guide
Answers Guide
en/answers_guide.md
I keep two answer files in every topic directory:
answer_basic_exercise.rbanswer_adv_exercise.rb
I include them because I want instructors and learners to have a clear reference solution after a real attempt. At the same time, I keep them outside the normal exercise flow on purpose.
The Boundary I Want To Protect
The standard runners and tests use:
example.rbbasic_exercise.rbadv_exercise.rb
They do not load:
answer_basic_exercise.rbanswer_adv_exercise.rb
That boundary matters to me. The goal of the course is not simply to get to passing code as quickly as possible. The goal is to practice the thinking that produces the code.
This is true for the full-course runner and for the topic runners. I want the answer files to remain teaching material, not part of the execution path.
How I Hope Learners Will Use The Answers
A good order looks like this:
- Read the topic notes first.
- Study
example.rband run the tests. - Attempt the basic and advanced exercises.
- Open the answer files only after making a genuine attempt.
- Compare the design choices, not just the final output.
When you read an answer file, I want you to look for more than correctness. Ask:
- Is the naming clearer than mine?
- Is the control flow simpler?
- Did the solution add a useful abstraction, or an unnecessary one?
- What would I borrow from this version if I rewrote my own?
- Did the code become clearer, or only shorter?
That is the right use of an answer key. It should sharpen your judgment, not replace it.
How Instructors Can Use The Answers
The answer files are useful for:
- preparing walkthroughs
- comparing different solution styles
- discussing tradeoffs in naming, control flow, and abstraction
- showing that Ruby solutions can be short without becoming careless
I do not mean the answer files to replace the exercises or to hide implementation details from the test suite. They work best when they remain clearly separate from the normal coding path.
File Layout Across The Course
The course currently has fifteen topic directories, and each of them includes the two answer files alongside the normal exercise files and tests.
Examples from different points in the course:
- topic_01_ruby_basics/answer_basic_exercise.rb
- topic_01_ruby_basics/answer_adv_exercise.rb
- topic_09_mini_capstone/answer_basic_exercise.rb
- topic_09_mini_capstone/answer_adv_exercise.rb
- topic_12_sqlite_queries/answer_basic_exercise.rb
- topic_15_reduce_accumulators/answer_adv_exercise.rb
I want the answer files to support review across the whole course, from the earliest syntax work to the later applied and transformation-heavy topics.