Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Convert example to exemplar #3086

Merged
merged 7 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/concept-exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ For more information, watch [this video][video-stub-file] and check [this exampl

For more information, watch [this video][video-tests-file] and check [this example tests file][tests-file].

### Example implementation file
### Exemplar implementation file

**Purpose:** Provide an idiomatic implementation that passes all the tests.

- This implementation is the target code that we want a student to aim for.
- Mentors will be shown this code as the "target" when writing feedback
- The implementation should only use language features introduced by the exercise or its prerequisites (and their prerequisites, and so on).
- The example file is _not_ shown to the student when doing in-browser coding and is _not_ downloaded to the student's file system when using the CLI.
- The exemplar file is _not_ shown to the student when doing in-browser coding and is _not_ downloaded to the student's file system when using the CLI.

For more information, watch [this video][video-example-file] and check [this example file][example-file].

Expand Down Expand Up @@ -333,6 +333,6 @@ See [this example config.json file][config.json].
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[stub-file]: ../languages/csharp/exercises/concept/log-levels/LogLevels.cs
[tests-file]: ../languages/csharp/exercises/concept/log-levels/LogLevelsTests.cs
[example-file]: ../languages/csharp/exercises/concept/log-levels/.meta/Example.cs
[example-file]: ../languages/csharp/exercises/concept/log-levels/.meta/Exemplar.cs
[determining-concepts-naming]: ./maintainers/determining-concepts.md#naming-concepts
[migrating-your-config-json-files]: ./maintainers/migrating-your-config-json-files.md
10 changes: 5 additions & 5 deletions languages/c/docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ The structure of en exercise's directory is as follows (note the differing hyphe
+-- makefile
+-- README.md
+-- src
| +-- example.c
| +-- example.h | <my_exercise>.h
| +-- exemplar.c
| +-- exemplar.h | <my_exercise>.h
+-- test
+-- test_<my_exercise>.c
+-- vendor
Expand All @@ -106,12 +106,12 @@ The structure of en exercise's directory is as follows (note the differing hyphe
* `test` - contains the test file `test_<my exercise>.c` and a `vendor` directory containing the test harness [Unity](http://www.throwtheswitch.org/unity/) from [ThrowTheSwitch](http://www.throwtheswitch.org/#intro-1-section).
ThrowTheSwitch has a decent guide on [getting started with Unity](http://www.throwtheswitch.org/getting-started-with-unity/) should you desire a tutorial. The version of Unity used is indicated in [versions](https://github.com/exercism/c/blob/master/docs/VERSIONS.md). The layout of the test file is described in the [style guide](https://github.com/exercism/c/blob/master/docs/C_STYLE_GUIDE.md#test-file-layout). Tests should be written that satisfy the exercise's related `canonical-data.json` file in the [`problem-specifications`](https://github.com/exercism/problem-specifications) repository

* `src` - contains the example files `example.c` and `example.h`. These are both skipped by the `exercism` CLI when downloading to the client, so it is imperative that you do not reference the names of the files in your code.
* `src` - contains the example files `exemplar.c` and `exemplar.h`. These are both skipped by the `exercism` CLI when downloading to the client, so it is imperative that you do not reference the names of the files in your code.
If you need to provide a header file example that is necessary to run your tests it should be named `<my exercise>.h` instead.
Please also use [`include`](http://faculty.cs.niu.edu/~mcmahon/CS241/c241man/node90.html) guards in your header files.
The [tests](https://github.com/exercism/c/blob/master/docs/CONTRIBUTING.md#what-are-the-ci-scripts) can be run using the [`bin/run-tests`](https://github.com/exercism/c/blob/master/bin/run-tests) script which will rename the `example.{c|h}` files accordingly.
The [tests](https://github.com/exercism/c/blob/master/docs/CONTRIBUTING.md#what-are-the-ci-scripts) can be run using the [`bin/run-tests`](https://github.com/exercism/c/blob/master/bin/run-tests) script which will rename the `exemplar.{c|h}` files accordingly.

* `makefile` - is the makefile for the exercise as it would build using proper filenames (i.e. `<exercise>.c` and `<exercise>.h` instead of `example.c` and `example.h` respectively). Makefiles are expected to change very little between exercises so it should be easy to copy one from another exercise and adjust the filenames therein.
* `makefile` - is the makefile for the exercise as it would build using proper filenames (i.e. `<exercise>.c` and `<exercise>.h` instead of `exemplar.c` and `exemplar.h` respectively). Makefiles are expected to change very little between exercises so it should be easy to copy one from another exercise and adjust the filenames therein.

* `README.md` - is the readme that relates to the exercise. These can be generated by the [configlet](https://github.com/exercism/configlet#configlet) tool from the exercise's related `description.md` in the [`problem-specifications`](https://github.com/exercism/problem-specifications) repository, or alternatively a custom one can be written.

Expand Down
4 changes: 2 additions & 2 deletions languages/c/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
├── .meta
│ ├── config.json
│ ├── design.md
│ └── example.c
│ └── exemplar.c
├── makefile
├── &lt;NAME&gt;.c
├── &lt;NAME&gt;.h
Expand All @@ -56,7 +56,7 @@ The code files are track-specific and should be designed to help the student lea
- `<NAME>{.c|.h}`: the stub source and header implementation files, which are the starting point for students to work on the exercise.
- `test_<NAME>.c`: the unit test source file.
- `test-framework`: this directory contains the source files of unit test framework, [Unity][unity]
- `.meta/example{.c|.h}`: an example implementation that passes all the unit tests.
- `.meta/exemplar{.c|.h}`: an exemplar implementation that passes all the unit tests.

## Step 2: Add documentation files

Expand Down
44 changes: 22 additions & 22 deletions ...xercises/concept/bird-watcher/example.clj → ...ercises/concept/bird-watcher/exemplar.clj
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
(ns vectors)
(def last-week [0 2 5 3 7 8 4])
(def birds-per-day [2 5 0 7 4 1])
(defn today [birds]
(last birds))
(defn inc-bird [birds]
(update birds (dec (count birds)) inc))
(defn day-without-birds? [birds]
(pos? (count (filter zero? birds))))
(defn n-days-count [birds n]
(reduce + (take n birds)))
(defn busy-days [birds]
(count (filter #(>= % 5) birds)))
(defn odd-week? [birds]
(= birds [1 0 1 0 1 0 1]))
(ns vectors)

(def last-week [0 2 5 3 7 8 4])
(def birds-per-day [2 5 0 7 4 1])

(defn today [birds]
(last birds))

(defn inc-bird [birds]
(update birds (dec (count birds)) inc))

(defn day-without-birds? [birds]
(pos? (count (filter zero? birds))))

(defn n-days-count [birds n]
(reduce + (take n birds)))

(defn busy-days [birds]
(count (filter #(>= % 5) birds)))

(defn odd-week? [birds]
(= birds [1 0 1 0 1 0 1]))
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
├── .meta
| |── config.json
| |── design.md
| └── Example.clj
| └── Exemplar.clj
├── &lt;NAME&gt;.clj
└── &lt;NAME&gt;_test.clj
</pre>
Expand All @@ -51,7 +51,7 @@ The code files are track-specific and should be designed to help the student lea

- `<NAME>.clj`: the Clojure file.
- `<NAME>_test.clj`: the test suite.
- `.meta/Example.clj`: the example implementation file.
- `.meta/Exemplar.clj`: the exemplar implementation file.

## Step 2: Add documentation files

Expand Down
4 changes: 2 additions & 2 deletions languages/common-lisp/bin/generate-scaffolding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The binary can be run in the following way:
$ ./generate-scaffolding function-definition
Creating exercises/concept/function-definition/.meta/config.json...
Creating exercises/concept/function-definition/.meta/design.md...
Creating exercises/concept/function-definition/.meta/example.lisp...
Creating exercises/concept/function-definition/.meta/exemplar.lisp...
Creating exercises/concept/function-definition/.docs/after.md...
Creating exercises/concept/function-definition/.docs/hints.md...
Creating exercises/concept/function-definition/.docs/instructions.md...
Expand All @@ -30,7 +30,7 @@ then run:
CL-USER> (scaffolder:make-scaffold "enumeration")
Creating exercises/concept/enumeration/.meta/config.json...
Creating exercises/concept/enumeration/.meta/design.md...
Creating exercises/concept/enumeration/.meta/example.lisp...
Creating exercises/concept/enumeration/.meta/exemplar.lisp...
Creating exercises/concept/enumeration/.docs/after.md...
Creating exercises/concept/enumeration/.docs/hints.md...
Creating exercises/concept/enumeration/.docs/instructions.md...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ languages
├── .meta
| |── config.json
| |── design.md
| └── example.lisp
| └── exemplar.lisp
├── &lt;SLUG&gt;.lisp
└── &lt;SLUG&gt;-test.lisp
</pre>
Expand All @@ -62,7 +62,7 @@ The code files are track-specific and should be designed to help the student lea
point for students to work on the exercise.
- `<SLUG>-test.lisp`: the test suite which loads the implementation file and
FiveAM via quicklisp. Loading this file should _not_ auto-run the tests.
- `.meta/example.lisp`: an example implementation that passes all the
- `.meta/exemplar.lisp`: an exemplar implementation that passes all the
tests.

## Step 2: Add documentation files
Expand Down
6 changes: 3 additions & 3 deletions languages/cpp/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ languages
├── .meta
| |── config.json
│   ├── design.md
│   ├── example.cpp
│   └── example.h
│   ├── exemplar.cpp
│   └── exemplar.h
├── CMakeLists.txt
├── &lt;NAME&gt;.cpp
├── &lt;NAME&gt;.h
Expand All @@ -57,7 +57,7 @@ The code files are track-specific and should be designed to help the student lea
- `<NAME>.h` and `<NAME>.cpp`. the stub implementation files, which is the starting point for students to work on the exercise.
- `CMakeLists.txt`: the C++ project file.
- `<NAME>_test.cpp`: the test suite.
- `.meta/example.h` and `.meta/example.cpp`: an example implementation that passes all the tests.
- `.meta/exemplar.h` and `.meta/exemplar.cpp`: an exemplar implementation that passes all the tests.
- `test/tests_main.cpp`: generates test main from test library

## Step 2: Add documentation files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ languages
| └── introduction.md
├── .meta
| ├── design.md
| └── Example.cs
| └── Exemplar.cs
├── Properties.csproj
├── Properties.cs
└── PropertiesTest.cs
Expand Down Expand Up @@ -169,7 +169,7 @@ These files are specific to the C# track:
- `Properties.csproj`: the C# project file.
- `PropertiesTest.cs`: the test suite.
- `Properties.cs`. the stub implementation file, which is the starting point for students to work on the exercise.
- `.meta/Example.cs`: an example implementation that passes all the tests.
- `.meta/Exemplar.cs`: an exemplar implementation that passes all the tests.

Check out the [`floating-point-numbers exercise`][csharp-docs-concept-exercises-numbers-floating-point] for an example on what these files should look like.

Expand Down
8 changes: 4 additions & 4 deletions languages/csharp/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
├── .meta
| |── config.json
| |── design.md
| └── Example.cs
| └── Exemplar.cs
├── &lt;NAME&gt;.cs
├── &lt;NAME&gt;.csproj
└── &lt;NAME&gt;Tests.cs
Expand Down Expand Up @@ -77,7 +77,7 @@ For more information, please read [this in-depth description][tests-file], [watc

For more information, check [this example project file][example-project-file].

### Add `.meta/Example.cs` file
### Add `.meta/Exemplar.cs` file

**Purpose:** The idiomatic example implementation that passes all the tests.

Expand Down Expand Up @@ -145,7 +145,7 @@ If you have any questions regarding implementing the exercise, please post them
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[example-stub-file]: ../exercises/concept/log-levels/LogLevels.cs
[example-tests-file]: ../exercises/concept/log-levels/LogLevelsTests.cs
[example-example-file]: ../exercises/concept/log-levels/.meta/Example.cs
[example-example-file]: ../exercises/concept/log-levels/.meta/Exemplar.cs
[example-project-file]: ../exercises/concept/log-levels/LogLevels.csproj
[skip-fact]: ../exercises/concept/log-levels/LogLevelsTests.cs#L11
[test-name]: ../exercises/concept/log-levels/LogLevelsTests.cs#L24
Expand All @@ -161,5 +161,5 @@ If you have any questions regarding implementing the exercise, please post them
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[example-stub-file]: ../languages/csharp/exercises/concept/log-levels/LogLevels.cs
[example-tests-file]: ../languages/csharp/exercises/concept/log-levels/LogLevelsTests.cs
[example-example-file]: ../languages/csharp/exercises/concept/log-levels/.meta/Example.cs
[example-example-file]: ../languages/csharp/exercises/concept/log-levels/.meta/Exemplar.cs
[example-project-file]: ../exercises/concept/log-levels/LogLevels.csproj
4 changes: 2 additions & 2 deletions languages/elixir/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ languages
├── .meta
│ ├── config.json
│   ├── design.md
│ └── example.ex
│ └── exemplar.ex
├── lib
│   └── $elixir_slug.ex
├── mix.exs
Expand All @@ -62,7 +62,7 @@ Now create the following three files:

- `lib/$elixir_slug.ex`. the stub implementation file, which is the starting point for students to work on the exercise.
- `test/$elixir_slug_test.ex`: the test suite.
- `.meta/example.ex`: an example implementation that passes all the tests.
- `.meta/exemplar.ex`: an exemplar implementation that passes all the tests.

## Step 2: Add documentation files

Expand Down
4 changes: 2 additions & 2 deletions languages/elm/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
└── .meta
| └── config.json
| └── design.md
| └── Example.elm
| └── Exemplar.elm
├── elm.json
├── src
| └── &lt;NAME&gt;.elm
Expand All @@ -55,7 +55,7 @@ The code files are track-specific and should be designed to help the student lea
- An `elm.json` file.
- A stub implementation file (`src/<NAME>.elm`).
- A file containing the test suite (`tests/<NAME>.elm`).
- An example implementation file that passes all the tests (`.meta/Example.elm`).
- An exemplar implementation file that passes all the tests (`.meta/Exemplar.elm`).

## Step 2: Add documentation files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ languages
| └── hints.md
├── .meta
| |── design.md
| └── Example.el
| └── Exemplar.el
├── <NAME>.el
└── <NAME>_test.el
```
6 changes: 3 additions & 3 deletions languages/fsharp/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
├── .meta
| |── config.json
| |── design.md
| └── Example.fs
| └── Exemplar.fs
├── &lt;NAME&gt;.fs
├── &lt;NAME&gt;.fsproj
└── &lt;NAME&gt;Tests.fs
Expand Down Expand Up @@ -76,7 +76,7 @@ For more information, please read [this in-depth description][tests-file], [watc

For more information, check [this example project file][example-project-file].

### Add `.meta/Example.fs` file
### Add `.meta/Exemplar.fs` file

**Purpose:** The idiomatic example implementation that passes all the tests.

Expand Down Expand Up @@ -143,5 +143,5 @@ If you have any questions regarding implementing this exercise, please post them
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[example-stub-file]: ../exercises/concept/log-levels/LogLevels.fs
[example-tests-file]: ../exercises/concept/log-levels/LogLevelsTests.fs
[example-example-file]: ../exercises/concept/log-levels/.meta/Example.fs
[example-example-file]: ../exercises/concept/log-levels/.meta/Exemplar.fs
[example-project-file]: ../exercises/concept/log-levels/LogLevels.fsproj
4 changes: 2 additions & 2 deletions languages/go/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ languages
├── .meta
| |── config.json
| |── design.md
| └── example.go
| └── exemplar.go
├── &lt;NAME&gt;.go
└── &lt;NAME&gt;_test.go
</pre>
Expand All @@ -51,7 +51,7 @@ The code files are track-specific and should be designed to help the student lea

- `<NAME>.go`. the stub implementation file, which is the starting point for students to work on the exercise.
- `<NAME>_test.go`: the test suite.
- `.meta/example.go`: an example implementation that passes all the tests.
- `.meta/exemplar.go`: an exemplar implementation that passes all the tests.

## Step 2: Add documentation files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ languages
│ └── <NAME>.hs
├── test
│ └── Tests.hs
├── examples
├── exemplars
│ ├── success-... (default: standard)
│ │ ├── package.yaml
│ │ └── src
Expand All @@ -67,7 +67,7 @@ These are files specific to the Haskell track:
- `stack.yaml`: The Stack configuration file.
- `src/<NAME>.hs`: The stub file being handed to the student.
- `test/Tests.hs`: The test suite being handed to the student.
- `examples/success-...`: A directory containing an example solution.
- `exemplars/success-...`: A directory containing an exemplar solution.
- `package.yaml`: That example solution's Stack project file.
- `src/<NAME>.hs>`: That example solution's source code.

Expand Down
4 changes: 2 additions & 2 deletions languages/java/reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ languages
|── .meta
| |── design.md
| |── config.json
| └── example
| └── exemplar
| |── build.gradle
| └── src
| └── main
Expand All @@ -71,7 +71,7 @@ Now create the following three files:

- `src/main/java/<slug>.java`. the stub implementation file, which is the starting point for students to work on the exercise.
- `src/test/java/<slug>Test.java`: the test suite, please use `assertj` to describe assertions instead of those offered by JUnit.
- `.meta/example/src/main/java/<slug>.java`: an example implementation that passes all the tests.
- `.meta/exemplar/src/main/java/<slug>.java`: an exemplar implementation that passes all the tests.

Append to `languages/java/exercises/settings.gradle` the following line: `concept:<slug>`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ languages
├── .eslintrc
├── .gitignore
├── babel.config.js
├── example.js
├── exemplar.js
├── &lt;slug&gt;.js
├── &lt;slug&gt;.spec.js
├── package.json
Expand Down Expand Up @@ -87,7 +87,7 @@ Now create the following three files:

- `<slug>.cs`. the stub implementation file, which is the starting point for students to work on the exercise.
- `<slug>.spec.js`: the test suite.
- `example.js`: an example implementation that passes all the tests.
- `exemplar.js`: an exemplar implementation that passes all the tests.

## Step 2: Add documentation files

Expand Down
3 changes: 0 additions & 3 deletions languages/javascript/scripts/scaffold/template/example.js

This file was deleted.

3 changes: 3 additions & 0 deletions languages/javascript/scripts/scaffold/template/exemplar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
This is an exemplar implementation that passes all the tests.
*/
Loading