- Install clojure.
- Fork it
- Clone repo (
https://github.com/{your-nickname}/battle_asserts.git) - Create your feature branch (
git checkout -b my-new-feature) - Make changes
- Run tests (
make test) - Run linters (
make checks) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
- Check if Request passed GithubActions
- Wait, until PR is reviewed
A description of the issue includes:
level— difficulty of the problem; possible values areelementary,easy,medium,hard.description— detailed description of the issue. Now supported laguages isruanden,enis required. You can runmake check-translationsfor list current translation progress.tags— tags that provides addittional info about task, array of strings.signature— function signature; map withinputandoutputtypes. Available typesinteger,float,string,array,hash (map, dicts). See examples in the existing issues.test-data— data in a specified format which will be used to test solutions. The first element in this list will be displayed as an example to players, so it should clarify and illustrate the problem as much as possible. Do not choose a trivial case for this example.
Example:
(ns battle-asserts.issues.array_sum)
(def level :elementary)
(def tags ["training" "collections"])
(def description
{:en "Calculate the sum of array." :ru "Рассчитайте сумму всех чисел в массиве."})
(def signature
{:input [{:argument-name "numbers" :type {:name "arr" :nested {:name "integer"}}}]
:output {:type {:name "integer"}}})
(def test-data
[{:expected 1 :arguments [[1]]}
{:expected 0 :arguments [[]]}
{:expected 10 :arguments [[1 2 3 4]]}])See examples in src/battle_asserts/issues/*.clj
An implementation of the issue includes:
arguments-generator— arguments generator for thesolutionfunction; generated arguments will be used to test players' solutions.solution— implemented correct solution. Example:
(ns battle-asserts.issues.array_sum)
(def level :elementary)
(def tags ["training" "collections"])
(def description
{:en "Calculate the sum of array." :ru "Рассчитайте сумму всех чисел в массиве."})
(def signature
{:input [{:argument-name "numbers" :type {:name "arr" :nested {:name "integer"}}}]
:output {:type {:name "integer"}}})
(def test-data
[{:expected 1 :arguments [[1]]}
{:expected 0 :arguments [[]]}
{:expected 10 :arguments [[1 2 3 4]]}])
(defn arguments-generator []
(gen/tuple (gen/list gen/small-integer))
(defn solution [numbers]
(apply + numbers))Corresponding tests are in test/test_helper.clj there is no need to add tests to this file, because tests runs dynamically, depending on the described signature, test-data, arguments-generator and solution.
run-solution-spec-testtests are checking that result type of solving issue is correct.run-generator-spec-testtests are checking that input signatures are correctly described forarguments-generator.run-solution-testtests are checking that test data solves correctly.run-test-data-spec-testtests are checking that test data corresponds to signature.run-description-testtests are checking that issue has minimal description.run-difficulty-testtests are checking that issue has correct difficulty level.
It will appear with auto-generated asserts on codebattle after merge .
make check-translationscheck current tasks translation progress.make check-tagscheck current tasks tagging progress.make check-generators-and-solutionscheck current tasks solution and arguments-generator progress.make collect-tagscheck tags stats, useful to check typo in tags.make collect-disabledcheck task disabled status.
- https://clojure.org/index
- https://clojure.org/guides/getting_started
- https://ru.code-basics.com/languages/clojure (currently, only in russian)