Add initial exercises

Once you've implemented the hello-world exercise, the next task is to implement 20+ other exercises.

Exercise types

There are two types of exercises you can implement:

  • Concept Exercises: they are designed to teach one or more concepts to a student. Check the documentation for more information.
  • Practice Exercises: they are designed to practice learned concepts. Check the documentation for more information.

In general, we recommend new tracks start with implementing Practice Exercises, as they're easier to implement and require less thinking upfront. Concept Exercises can always be added later, once your track is up and running properly.

Choose exercises

To help tracks implement Practice Exercises, we've created the exercism/problem-specifications repository. This repository contains metadata for over 100+ Practice Exercises, which different tracks can then use to implement their track-specific version of these exercises from. For this reason, you'll see the same exercises implemented across many different tracks.

So how do you select the 20+ from this list of 100+ exercises? Here are some guidelines.

Select exercises that have students practice a wide variety of concepts

There is a lot of variety in concepts used in the 100+ exercises. You should aim to implement exercises that have students practice a wide variety of concepts. So instead of implementing 20 exercises that focus on strings, try to implement exercises that focus on different concepts.

Here are some concepts with sample exercises:

Concepts Exercises
Bit manipulation allergies, secret-handshake
Booleans leap
Classes circular-buffer, robot-name
Concurrency bank-account
Conditionals raindrops
Dates and time gigasecond, meetup
Equality clock
Floating-point numbers darts, space-age
Laziness alphametics, zebra-puzzle
Lists resistor-color, spiral-matrix
Loops collatz-conjecture, protein-translation
Maps nucleotide-count
Numbers leap, grains
Randomness dnd-character, robot-name
Strings bob, isogram,
Trees binary-search-tree, pov

Select exercises with varying degrees of difficulty

Some exercises will be more difficult to implement than others. You should aim to implement exercises with varying degrees of difficulty: some easy ones, some intermediate ones and some hard ones.

How difficult an exercise is depends on several factors, such as the involved concepts and the track's language. It might help to check what the exercise looks like in other tracks that have implemented the exercise, to better get a feel for what the implementation could look like.

Here are some difficulties with exercises:

Select exercises that fit your track

Not all exercises may fit your track. You should only select those exercises that fit your track; better to not implement an exercise than to implement one that does not make sense. As an example, the lens-person exercise has the student working with lenses, which many languages don't support.

If you find an exercise that doesn't fit your track, you can add its slug to the exercises.foregone array in the track config.json file. This will ensure that tooling will ignore that exercise.

Sample curriculum

To make this all a bit more concrete, this is what a sample selection of initial exercises could look like:

Exercise Difficulty Concepts
hello-world Easy None (initial exercise)
leap Easy Numbers, Booleans
gigasecond Easy Dates and time
isogram Easy Strings
resistor-color Easy Lists
nucleotide-count Easy Maps
collatz-conjecture Easy Loops
darts Easy Floating-point numbers
two-fer Easy String formatting, Optional arguments
high-scores Easy Collection processing
raindrops Intermediate Conditionals
bob Intermediate Strings
allergies Intermediate Bit manipulation
series Intermediate Exceptions
circular-buffer Intermediate Classes
meetup Intermediate Dates and time
yacht Intermediate Lists
dominoes Hard Tuples, Laziness
diamond Hard String formatting
alphametics Hard Laziness
forth Hard Parsing

Implement exercises

Scaffold exercise

Having selected the exercises you want include in your track, the next step is to implement them. You can quickly scaffold a new Practice Exercise by running the following commands from the track's root directory:

bin/configlet create --practice-exercise <slug>

For more information, check the configlet create docs

Implement exercise

Once the scaffolded files have been created, you'll then have to:

  • Add tests to the tests file
  • Add an example implementation
  • Define the stub file's contents
  • Within the exercise's .meta/config.json file:
    • Add the GitHub username of the exercise's authors to the authors key
  • Within the track's config.json file:
    • Check/update the exercise's difficulty
    • Add concepts to the practices key (only required when the track has concept exercises)
    • Add concepts to the prerequisites key (only required when the track has concept exercises)

Add tests

A key part of adding an exercise is adding tests. Rougly speaking, there are two options when adding tests for one of the above exercises:

  1. Implement the tests from scratch, using the test cases from the exercise's canonical-data.json file as found in the problem-specifications repo.
  2. Port the tests from another track's implementation (tip: go to<slug> to get an overview of which tracks have implemented a specific exercise).

The second option can be particularly appealing, as it can give you results quickly. Keep in mind, though, that you should tweak the implementation to best fit your track. As an example, some tracks do not use classes but only work with functions. If your track usually works with objects though, you should adapt the implementation to what best fits your track.