trackler 2.1.0.24 → 2.1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/CONTRIBUTING.md +5 -8
- data/README.md +7 -7
- data/common/CONTRIBUTING.md +0 -5
- data/common/exercises/accumulate/description.md +4 -1
- data/common/exercises/acronym/description.md +1 -1
- data/common/exercises/bank-account/description.md +2 -1
- data/common/exercises/book-store/description.md +2 -5
- data/common/exercises/bracket-push/description.md +2 -4
- data/common/exercises/change/description.md +2 -5
- data/common/exercises/circular-buffer/description.md +0 -2
- data/common/exercises/clock/description.md +0 -2
- data/common/exercises/collatz-conjecture/canonical-data.json +36 -0
- data/common/exercises/collatz-conjecture/description.md +25 -0
- data/common/exercises/collatz-conjecture/metadata.yml +4 -0
- data/common/exercises/counter/description.md +1 -2
- data/common/exercises/diamond/description.md +0 -4
- data/common/exercises/flatten-array/description.md +1 -1
- data/common/exercises/grade-school/description.md +2 -1
- data/common/exercises/grains/description.md +2 -1
- data/common/exercises/grep/description.md +3 -2
- data/common/exercises/kindergarten-garden/description.md +2 -1
- data/common/exercises/largest-series-product/description.md +2 -1
- data/common/exercises/matrix/description.md +2 -1
- data/common/exercises/nucleotide-codons/description.md +2 -1
- data/common/exercises/ocr-numbers/description.md +2 -1
- data/common/exercises/octal/description.md +3 -1
- data/common/exercises/pangram/description.md +2 -1
- data/common/exercises/perfect-numbers/description.md +2 -1
- data/common/exercises/poker/description.md +0 -2
- data/common/exercises/protein-translation/description.md +3 -2
- data/common/exercises/proverb/description.md +2 -1
- data/common/exercises/pythagorean-triplet/description.md +4 -2
- data/common/exercises/queen-attack/description.md +2 -1
- data/common/exercises/rectangles/description.md +1 -3
- data/common/exercises/rotational-cipher/description.md +0 -4
- data/common/exercises/scale-generator/description.md +0 -2
- data/common/exercises/secret-handshake/description.md +2 -2
- data/common/exercises/series/description.md +2 -1
- data/common/exercises/sieve/description.md +2 -1
- data/common/exercises/space-age/description.md +0 -2
- data/common/exercises/strain/description.md +4 -5
- data/common/exercises/sublist/description.md +3 -6
- data/common/exercises/sum-of-multiples/description.md +2 -1
- data/common/exercises/tournament/description.md +4 -3
- data/common/exercises/transpose/description.md +1 -3
- data/common/exercises/trinary/description.md +2 -1
- data/common/exercises/two-bucket/description.md +1 -3
- data/common/exercises/two-fer/canonical-data.json +24 -0
- data/common/exercises/two-fer/description.md +40 -0
- data/common/exercises/two-fer/metadata.yml +4 -0
- data/common/exercises/word-search/description.md +2 -4
- data/common/exercises/zebra-puzzle/description.md +1 -1
- data/lib/trackler.rb +10 -5
- data/lib/trackler/description.rb +2 -2
- data/lib/trackler/guaranteed_file.rb +15 -15
- data/lib/trackler/implementation.rb +5 -5
- data/lib/trackler/implementations.rb +2 -2
- data/lib/trackler/metadata.rb +2 -2
- data/lib/trackler/problem.rb +2 -96
- data/lib/trackler/problems.rb +3 -48
- data/lib/trackler/specification.rb +101 -0
- data/lib/trackler/specifications.rb +52 -0
- data/lib/trackler/track.rb +6 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/LICENSE +21 -0
- data/tracks/bash/README.md +0 -5
- data/tracks/c/LICENSE +21 -0
- data/tracks/c/README.md +0 -5
- data/tracks/clojure/LICENSE +2 -2
- data/tracks/clojure/README.org +0 -5
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/sublist/project.clj +4 -0
- data/tracks/clojure/exercises/sublist/src/example.clj +19 -0
- data/tracks/clojure/exercises/sublist/sublist.mustache +9 -0
- data/tracks/clojure/exercises/sublist/test/sublist_test.clj +40 -0
- data/tracks/cpp/LICENSE +2 -2
- data/tracks/cpp/README.md +0 -5
- data/tracks/csharp/LICENSE +2 -2
- data/tracks/csharp/README.md +0 -5
- data/tracks/delphi/LICENSE +2 -2
- data/tracks/delphi/README.md +0 -5
- data/tracks/ecmascript/LICENSE +2 -2
- data/tracks/ecmascript/README.md +0 -5
- data/tracks/elisp/.travis.yml +7 -3
- data/tracks/elisp/LICENSE +2 -2
- data/tracks/elisp/README.org +3 -6
- data/tracks/elisp/bin/test-examples +27 -0
- data/tracks/elisp/config.json +10 -0
- data/tracks/elisp/docs/LEARNING.org +0 -3
- data/tracks/elisp/exercises/grains/example.el +18 -0
- data/tracks/elisp/exercises/grains/grains-test.el +38 -0
- data/tracks/elisp/exercises/grains/grains.el +10 -0
- data/tracks/elisp/exercises/phone-number/example.el +34 -0
- data/tracks/elisp/exercises/phone-number/phone-number-test.el +43 -0
- data/tracks/elisp/exercises/phone-number/phone-number.el +9 -0
- data/tracks/elixir/LICENSE +2 -2
- data/tracks/elixir/README.md +0 -5
- data/tracks/elm/LICENSE +2 -2
- data/tracks/elm/README.md +0 -5
- data/tracks/erlang/LICENSE +2 -2
- data/tracks/erlang/README.md +0 -5
- data/tracks/erlang/SETUP.md +7 -0
- data/tracks/erlang/exercises/rotational-cipher/rebar.config +5 -5
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +18 -18
- data/tracks/factor/LICENSE +2 -2
- data/tracks/fortran/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- data/tracks/fortran/.gitignore +4 -0
- data/tracks/fortran/.travis.yml +17 -0
- data/tracks/fortran/LICENSE +21 -0
- data/tracks/fortran/Makefile +40 -0
- data/tracks/fortran/README.md +72 -0
- data/tracks/fortran/bin/fetch-configlet +32 -0
- data/tracks/fortran/config.json +32 -0
- data/tracks/{kotlin/SETUP.md → fortran/docs/ABOUT.md} +0 -0
- data/tracks/fortran/docs/INSTALLATION.md +0 -0
- data/tracks/fortran/docs/LEARNING.md +0 -0
- data/tracks/fortran/docs/RESOURCES.md +0 -0
- data/tracks/fortran/docs/TESTS.md +0 -0
- data/tracks/fortran/exercises/TRACK_HINTS.md +0 -0
- data/tracks/fortran/exercises/bob/bob.fun +114 -0
- data/tracks/fortran/exercises/bob/example.f90 +61 -0
- data/tracks/fortran/exercises/hello_world/example.f90 +9 -0
- data/tracks/fortran/exercises/hello_world/hello_world.fun +10 -0
- data/tracks/fortran/img/.keep +0 -0
- data/tracks/fsharp/LICENSE +2 -2
- data/tracks/fsharp/README.md +0 -5
- data/tracks/go/LICENSE +2 -2
- data/tracks/go/README.md +0 -5
- data/tracks/haskell/LICENSE +2 -2
- data/tracks/haskell/README.md +0 -5
- data/tracks/idris/LICENSE +2 -2
- data/tracks/idris/README.md +0 -5
- data/tracks/java/LICENSE +2 -2
- data/tracks/java/README.md +0 -7
- data/tracks/java/{SETUP.md → TRACK_HINTS.md} +0 -0
- data/tracks/java/config.json +5 -0
- data/tracks/java/exercises/_template/build.gradle +1 -0
- data/tracks/java/exercises/accumulate/build.gradle +1 -0
- data/tracks/java/exercises/acronym/build.gradle +1 -0
- data/tracks/java/exercises/all-your-base/build.gradle +1 -0
- data/tracks/java/exercises/allergies/build.gradle +1 -0
- data/tracks/java/exercises/anagram/build.gradle +1 -0
- data/tracks/java/exercises/atbash-cipher/build.gradle +1 -0
- data/tracks/java/exercises/beer-song/build.gradle +1 -0
- data/tracks/java/exercises/binary-search/build.gradle +1 -0
- data/tracks/java/exercises/binary/build.gradle +1 -0
- data/tracks/java/exercises/bob/build.gradle +1 -0
- data/tracks/java/exercises/book-store/build.gradle +1 -0
- data/tracks/java/exercises/bracket-push/build.gradle +1 -0
- data/tracks/java/exercises/change/build.gradle +1 -0
- data/tracks/java/exercises/clock/build.gradle +2 -1
- data/tracks/java/exercises/collatz-conjecture/build.gradle +18 -0
- data/tracks/java/exercises/collatz-conjecture/src/example/java/CollatzCalculator.java +19 -0
- data/tracks/java/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java +7 -0
- data/tracks/java/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java +59 -0
- data/tracks/java/exercises/crypto-square/build.gradle +1 -0
- data/tracks/java/exercises/diamond/build.gradle +1 -0
- data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +4 -4
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +6 -2
- data/tracks/java/exercises/difference-of-squares/build.gradle +1 -0
- data/tracks/java/exercises/difference-of-squares/src/main/java/.keep +0 -0
- data/tracks/java/exercises/etl/build.gradle +1 -0
- data/tracks/java/exercises/flatten-array/build.gradle +1 -0
- data/tracks/java/exercises/gigasecond/build.gradle +1 -0
- data/tracks/java/exercises/grade-school/build.gradle +1 -0
- data/tracks/java/exercises/hamming/build.gradle +1 -0
- data/tracks/java/exercises/hexadecimal/build.gradle +1 -0
- data/tracks/java/exercises/isogram/build.gradle +1 -0
- data/tracks/java/exercises/kindergarten-garden/build.gradle +1 -0
- data/tracks/java/exercises/largest-series-product/build.gradle +1 -0
- data/tracks/java/exercises/linked-list/build.gradle +1 -0
- data/tracks/java/exercises/luhn/build.gradle +1 -0
- data/tracks/java/exercises/matrix/build.gradle +2 -1
- data/tracks/java/exercises/meetup/build.gradle +1 -0
- data/tracks/java/exercises/minesweeper/build.gradle +1 -0
- data/tracks/java/exercises/nth-prime/build.gradle +1 -0
- data/tracks/java/exercises/ocr-numbers/build.gradle +1 -0
- data/tracks/java/exercises/octal/build.gradle +1 -0
- data/tracks/java/exercises/pangram/build.gradle +1 -0
- data/tracks/java/exercises/pascals-triangle/build.gradle +1 -0
- data/tracks/java/exercises/perfect-numbers/build.gradle +1 -0
- data/tracks/java/exercises/phone-number/build.gradle +1 -0
- data/tracks/java/exercises/pig-latin/build.gradle +1 -0
- data/tracks/java/exercises/queen-attack/build.gradle +1 -0
- data/tracks/java/exercises/raindrops/build.gradle +1 -0
- data/tracks/java/exercises/rectangles/build.gradle +1 -0
- data/tracks/java/exercises/rna-transcription/build.gradle +1 -0
- data/tracks/java/exercises/robot-simulator/build.gradle +1 -0
- data/tracks/java/exercises/roman-numerals/build.gradle +1 -0
- data/tracks/java/exercises/run-length-encoding/build.gradle +1 -0
- data/tracks/java/exercises/saddle-points/build.gradle +1 -0
- data/tracks/java/exercises/scrabble-score/build.gradle +1 -0
- data/tracks/java/exercises/secret-handshake/build.gradle +1 -0
- data/tracks/java/exercises/series/build.gradle +1 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/sieve/build.gradle +1 -0
- data/tracks/java/exercises/simple-cipher/build.gradle +1 -0
- data/tracks/java/exercises/simple-linked-list/build.gradle +1 -0
- data/tracks/java/exercises/space-age/build.gradle +1 -0
- data/tracks/java/exercises/strain/build.gradle +1 -0
- data/tracks/java/exercises/sublist/build.gradle +1 -0
- data/tracks/java/exercises/sum-of-multiples/build.gradle +1 -0
- data/tracks/java/exercises/triangle/build.gradle +1 -0
- data/tracks/java/exercises/trinary/build.gradle +1 -0
- data/tracks/java/exercises/twelve-days/build.gradle +2 -1
- data/tracks/java/exercises/word-count/build.gradle +1 -0
- data/tracks/java/exercises/wordy/build.gradle +1 -0
- data/tracks/javascript/LICENSE +2 -2
- data/tracks/javascript/README.md +0 -5
- data/tracks/julia/LICENSE +2 -2
- data/tracks/kotlin/LICENSE +2 -2
- data/tracks/kotlin/README.md +0 -7
- data/tracks/kotlin/TRACK_HINTS.md +1 -0
- data/tracks/kotlin/exercises/phone-number/src/example/kotlin/PhoneNumber.kt +1 -1
- data/tracks/kotlin/exercises/phone-number/src/test/kotlin/PhoneNumberTest.kt +7 -8
- data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +6 -6
- data/tracks/lfe/LICENSE +2 -2
- data/tracks/lfe/README.md +0 -5
- data/tracks/lisp/LICENSE +2 -2
- data/tracks/lisp/README.md +0 -5
- data/tracks/lua/LICENSE +2 -2
- data/tracks/lua/README.md +0 -5
- data/tracks/mips/LICENSE +2 -2
- data/tracks/mips/README.md +0 -5
- data/tracks/objective-c/LICENSE +2 -2
- data/tracks/objective-c/README.md +0 -5
- data/tracks/ocaml/LICENSE +2 -2
- data/tracks/ocaml/README.md +0 -5
- data/tracks/ocaml/config.json +54 -25
- data/tracks/ocaml/exercises/forth/.merlin +5 -0
- data/tracks/ocaml/exercises/forth/Makefile +11 -0
- data/tracks/ocaml/exercises/forth/example.ml +89 -0
- data/tracks/ocaml/exercises/forth/forth.mli +1 -0
- data/tracks/ocaml/exercises/forth/test.ml +147 -0
- data/tracks/ocaml/exercises/react/.merlin +5 -0
- data/tracks/ocaml/exercises/react/HINT.md +3 -0
- data/tracks/ocaml/exercises/react/Makefile +11 -0
- data/tracks/ocaml/exercises/react/example.ml +106 -0
- data/tracks/ocaml/exercises/react/react.mli +26 -0
- data/tracks/ocaml/exercises/react/test.ml +157 -0
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +5 -2
- data/tracks/ocaml/tools/test-generator/templates/forth/template.ml +114 -0
- data/tracks/perl5/LICENSE +2 -2
- data/tracks/perl6/LICENSE +2 -2
- data/tracks/perl6/README.md +0 -5
- data/tracks/perl6/config.json +5 -0
- data/tracks/perl6/exercises/clock/Example.pm6 +2 -2
- data/tracks/perl6/exercises/flatten-array/Example.pm6 +13 -0
- data/tracks/perl6/exercises/flatten-array/FlattenArray.pm6 +4 -0
- data/tracks/perl6/exercises/flatten-array/example.yaml +6 -0
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +80 -0
- data/tracks/php/LICENSE +2 -2
- data/tracks/php/README.md +0 -5
- data/tracks/powershell/.travis.yml +1 -0
- data/tracks/python/LICENSE +2 -2
- data/tracks/python/README.md +0 -5
- data/tracks/python/config.json +8 -0
- data/tracks/python/exercises/protein-translation/example.py +25 -0
- data/tracks/python/exercises/protein-translation/protein_translation.py +6 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +59 -0
- data/tracks/r/LICENSE +2 -2
- data/tracks/r/README.md +0 -5
- data/tracks/racket/LICENSE +2 -2
- data/tracks/racket/README.md +0 -5
- data/tracks/racket/config.json +5 -0
- data/tracks/racket/exercises/acronym/acronym-test.rkt +40 -0
- data/tracks/racket/exercises/acronym/acronym.rkt +3 -0
- data/tracks/racket/exercises/acronym/example.rkt +25 -0
- data/tracks/racket/exercises/grep/example.rkt +60 -26
- data/tracks/racket/exercises/grep/grep-test.rkt +154 -17
- data/tracks/racket/exercises/grep/grep.rkt +1 -18
- data/tracks/racket/exercises/grep/iliad.txt +9 -0
- data/tracks/racket/exercises/grep/midsummer-night.txt +7 -0
- data/tracks/racket/exercises/grep/paradise-lost.txt +8 -0
- data/tracks/ruby/README.md +4 -1
- data/tracks/ruby/exercises/acronym/.meta/.version +1 -1
- data/tracks/ruby/exercises/acronym/.meta/solutions/acronym.rb +1 -1
- data/tracks/ruby/exercises/acronym/acronym_test.rb +2 -7
- data/tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb +1 -1
- data/tracks/ruby/exercises/beer-song/.meta/generator/beer_song_case.rb +1 -1
- data/tracks/ruby/exercises/clock/.meta/generator/clock_case.rb +1 -1
- data/tracks/ruby/exercises/connect/.meta/generator/connect_case.rb +0 -3
- data/tracks/ruby/exercises/connect/.meta/generator/test_template.erb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/.version +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/solutions/difference_of_squares.rb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/difference_of_squares_test.rb +12 -17
- data/tracks/ruby/exercises/triangle/.meta/generator/triangle_case.rb +10 -2
- data/tracks/ruby/exercises/triangle/triangle_test.rb +17 -17
- data/tracks/ruby/exercises/wordy/.meta/generator/wordy_case.rb +1 -1
- data/tracks/ruby/lib/generator/case_values.rb +1 -1
- data/tracks/ruby/lib/generator/exercise_case.rb +16 -2
- data/tracks/ruby/lib/generator/exercise_case/assertion.rb +4 -4
- data/tracks/ruby/test/fixtures/xruby/exercises/alpha/.meta/generator/alpha_case.rb +1 -1
- data/tracks/ruby/test/generator/case_values_test.rb +28 -7
- data/tracks/ruby/test/generator/exercise_case/assertion_test.rb +7 -7
- data/tracks/ruby/test/generator/exercise_case_test.rb +21 -25
- data/tracks/ruby/test/wordy_cases_test.rb +4 -4
- data/tracks/rust/LICENSE +2 -2
- data/tracks/rust/README.md +0 -5
- data/tracks/rust/config.json +1 -0
- data/tracks/rust/exercises/etl/Cargo.toml +1 -1
- data/tracks/rust/exercises/etl/example.rs +2 -2
- data/tracks/rust/exercises/etl/tests/etl.rs +26 -32
- data/tracks/rust/exercises/forth/tests/forth.rs +20 -22
- data/tracks/rust/exercises/minesweeper/Cargo.toml +1 -1
- data/tracks/rust/exercises/minesweeper/example.rs +3 -0
- data/tracks/rust/exercises/minesweeper/tests/minesweeper.rs +44 -46
- data/tracks/rust/exercises/raindrops/Cargo.toml +1 -1
- data/tracks/rust/exercises/raindrops/tests/raindrops.rs +12 -0
- data/tracks/rust/exercises/rna-transcription/Cargo.toml +1 -1
- data/tracks/rust/exercises/rna-transcription/example.rs +13 -9
- data/tracks/rust/exercises/rna-transcription/tests/rna-transcription.rs +23 -5
- data/tracks/scala/LICENSE +2 -2
- data/tracks/scala/README.md +0 -5
- data/tracks/scheme/LICENSE +2 -2
- data/tracks/scheme/README.org +0 -6
- data/tracks/swift/Dangerfile +1 -1
- data/tracks/swift/LICENSE +2 -2
- data/tracks/swift/README.md +0 -6
- data/tracks/vbnet/.travis.yml +1 -0
- data/tracks/vimscript/.travis.yml +4 -0
- data/tracks/vimscript/.vintrc.yaml +5 -0
- data/tracks/vimscript/TRACK_HINTS.md +19 -1
- data/tracks/vimscript/bin/pre-push +18 -0
- data/tracks/vimscript/config.json +8 -1
- data/tracks/vimscript/docs/ABOUT.md +7 -6
- data/tracks/vimscript/docs/TESTS.md +4 -4
- data/tracks/vimscript/exercises/allergies/allergies.vader +68 -0
- data/tracks/vimscript/exercises/allergies/allergies.vim +29 -0
- data/tracks/vimscript/exercises/allergies/example.vim +23 -0
- data/tracks/vimscript/lib/generate.vim +89 -0
- metadata +81 -6
- data/tracks/java/exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java +0 -15
- data/tracks/ocaml/.vscode/launch.json +0 -13
@@ -3,6 +3,8 @@ open Core
|
|
3
3
|
open Model
|
4
4
|
open Yojson.Basic
|
5
5
|
|
6
|
+
let strip_quotes s = String.drop_prefix s 1 |> Fn.flip String.drop_suffix 1
|
7
|
+
|
6
8
|
let map_elements (to_str: json -> string) (parameters: (string * json) list): (string * string) list =
|
7
9
|
List.map parameters ~f:(fun (k,j) -> (k,to_str j))
|
8
10
|
|
@@ -36,6 +38,7 @@ let optional_strings ~(f: string -> bool) (parameters: (string * json) list): (s
|
|
36
38
|
let option_of_null (value: json): string = match value with
|
37
39
|
| `Null -> "None"
|
38
40
|
| `String s -> "(Some \"" ^ s ^ "\")"
|
41
|
+
| `List xs as l -> "(Some " ^ (json_to_string l) ^ ")"
|
39
42
|
| _ -> failwith "cannot handle this type"
|
40
43
|
|
41
44
|
let is_empty_string (value: json): bool = match value with
|
@@ -68,6 +71,7 @@ let edit_expected ~(stringify: json -> string) ~(slug: string) ~(value: json) =
|
|
68
71
|
| "change" -> edit_change_expected value
|
69
72
|
| "bowling" -> edit_bowling_expected value
|
70
73
|
| "binary-search" -> optional_int ~none:(-1) value
|
74
|
+
| "forth" -> option_of_null value
|
71
75
|
| _ -> stringify value
|
72
76
|
|
73
77
|
let edit_say (ps: (string * json) list) =
|
@@ -92,15 +96,14 @@ let edit_dominoes (ps: (string * json) list): (string * string) list =
|
|
92
96
|
| (k, v) -> (k, json_to_string v) in
|
93
97
|
List.map ps ~f:edit
|
94
98
|
|
99
|
+
|
95
100
|
let edit_space_age (ps: (string * json) list): (string * string) list =
|
96
|
-
let strip_quotes s = String.drop_prefix s 1 |> Fn.flip String.drop_suffix 1 in
|
97
101
|
let edit = function
|
98
102
|
| ("planet", v) -> ("planet", json_to_string v |> strip_quotes)
|
99
103
|
| (k, v) -> (k, json_to_string v) in
|
100
104
|
List.map ps ~f:edit
|
101
105
|
|
102
106
|
let edit_bowling (ps: (string * json) list): (string * string) list =
|
103
|
-
let strip_quotes s = String.drop_prefix s 1 |> Fn.flip String.drop_suffix 1 in
|
104
107
|
let edit = function
|
105
108
|
| ("property", v) -> ("property", json_to_string v |> strip_quotes)
|
106
109
|
| ("roll", `Int n) -> ("roll", let s = Int.to_string n in if n < 0 then ("(" ^ s ^ ")") else s)
|
@@ -0,0 +1,114 @@
|
|
1
|
+
open Core
|
2
|
+
open OUnit2
|
3
|
+
open Forth
|
4
|
+
|
5
|
+
let print_int_list_option (xs: int list option) = match xs with
|
6
|
+
| None -> "None"
|
7
|
+
| Some xs -> "Some [" ^ String.concat ~sep:";" (List.map ~f:Int.to_string xs) ^ "]"
|
8
|
+
let ae exp got _test_ctxt = assert_equal ~printer:print_int_list_option exp got
|
9
|
+
|
10
|
+
let (* SUITE parsing_and_numbers *)parsing_and_numbers_tests = [
|
11
|
+
(* TEST
|
12
|
+
"$description" >::
|
13
|
+
ae $expected (evaluate $input);
|
14
|
+
END TEST *)
|
15
|
+
]
|
16
|
+
(* END SUITE *)
|
17
|
+
|
18
|
+
let (* SUITE addition *)addition_tests = [
|
19
|
+
(* TEST
|
20
|
+
"$description" >::
|
21
|
+
ae $expected (evaluate $input);
|
22
|
+
END TEST *)
|
23
|
+
]
|
24
|
+
(* END SUITE *)
|
25
|
+
|
26
|
+
let (* SUITE subtraction *)subtraction_tests = [
|
27
|
+
(* TEST
|
28
|
+
"$description" >::
|
29
|
+
ae $expected (evaluate $input);
|
30
|
+
END TEST *)
|
31
|
+
]
|
32
|
+
(* END SUITE *)
|
33
|
+
|
34
|
+
let (* SUITE multiplication *)multiplication_tests = [
|
35
|
+
(* TEST
|
36
|
+
"$description" >::
|
37
|
+
ae $expected (evaluate $input);
|
38
|
+
END TEST *)
|
39
|
+
]
|
40
|
+
(* END SUITE *)
|
41
|
+
|
42
|
+
let (* SUITE division *)division_tests = [
|
43
|
+
(* TEST
|
44
|
+
"$description" >::
|
45
|
+
ae $expected (evaluate $input);
|
46
|
+
END TEST *)
|
47
|
+
]
|
48
|
+
(* END SUITE *)
|
49
|
+
|
50
|
+
let (* SUITE combined_arithmetic *)combined_arithmetic_tests = [
|
51
|
+
(* TEST
|
52
|
+
"$description" >::
|
53
|
+
ae $expected (evaluate $input);
|
54
|
+
END TEST *)
|
55
|
+
]
|
56
|
+
(* END SUITE *)
|
57
|
+
|
58
|
+
let (* SUITE dup *)dup_tests = [
|
59
|
+
(* TEST
|
60
|
+
"$description" >::
|
61
|
+
ae $expected (evaluate $input);
|
62
|
+
END TEST *)
|
63
|
+
]
|
64
|
+
(* END SUITE *)
|
65
|
+
|
66
|
+
let (* SUITE drop *)drop_tests = [
|
67
|
+
(* TEST
|
68
|
+
"$description" >::
|
69
|
+
ae $expected (evaluate $input);
|
70
|
+
END TEST *)
|
71
|
+
]
|
72
|
+
(* END SUITE *)
|
73
|
+
|
74
|
+
let (* SUITE swap *)swap_tests = [
|
75
|
+
(* TEST
|
76
|
+
"$description" >::
|
77
|
+
ae $expected (evaluate $input);
|
78
|
+
END TEST *)
|
79
|
+
]
|
80
|
+
(* END SUITE *)
|
81
|
+
|
82
|
+
let (* SUITE over *)over_tests = [
|
83
|
+
(* TEST
|
84
|
+
"$description" >::
|
85
|
+
ae $expected (evaluate $input);
|
86
|
+
END TEST *)
|
87
|
+
]
|
88
|
+
(* END SUITE *)
|
89
|
+
|
90
|
+
let (* SUITE user-defined_words *)user_defined_words_tests = [
|
91
|
+
(* TEST
|
92
|
+
"$description" >::
|
93
|
+
ae $expected (evaluate $input);
|
94
|
+
END TEST *)
|
95
|
+
]
|
96
|
+
(* END SUITE *)
|
97
|
+
|
98
|
+
let () =
|
99
|
+
run_test_tt_main (
|
100
|
+
"forth tests" >:::
|
101
|
+
List.concat [
|
102
|
+
parsing_and_numbers_tests;
|
103
|
+
addition_tests;
|
104
|
+
subtraction_tests;
|
105
|
+
multiplication_tests;
|
106
|
+
division_tests;
|
107
|
+
combined_arithmetic_tests;
|
108
|
+
dup_tests;
|
109
|
+
drop_tests;
|
110
|
+
swap_tests;
|
111
|
+
over_tests;
|
112
|
+
user_defined_words_tests
|
113
|
+
]
|
114
|
+
)
|
data/tracks/perl5/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/perl6/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/perl6/README.md
CHANGED
@@ -25,11 +25,6 @@ When adding a new exercise, ensure that the exercise is included in the `exercis
|
|
25
25
|
Set `EXERCISM` as an environment variable (e.g. `export EXERCISM=1` in bash), and run either `prove -re perl6`
|
26
26
|
to run all tests in all subdirectories, or `prove -e perl6 /path/to/test.t` to run an individual test file.
|
27
27
|
|
28
|
-
## License
|
29
|
-
|
30
|
-
The MIT License (MIT)
|
31
|
-
|
32
|
-
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
33
28
|
|
34
29
|
### Perl 6 icon
|
35
30
|
The Perl 6 "Camelia" logo is owned by Larry Wall and is released under version 2.0 of the Artistic License. We are using it to identify the Perl 6 language itself, not any part of Exercism, which we believe to be admissible under fair use. The version of the logo that we are using is a pink, black and white adaptation of the logo found on <http://en.wikipedia.org/wiki/Perl_6>.
|
data/tracks/perl6/config.json
CHANGED
@@ -3,10 +3,10 @@ unit class Clock:ver<1>;
|
|
3
3
|
has Int:D $.hour = 0;
|
4
4
|
has Int:D $.minute = 0;
|
5
5
|
|
6
|
-
method time
|
6
|
+
method time {
|
7
7
|
sprintf '%02d:%02d', ($!hour + $!minute div 60) % 24, $!minute % 60;
|
8
8
|
}
|
9
9
|
|
10
|
-
method add-minutes (Int:D $min)
|
10
|
+
method add-minutes (Int:D $min) {
|
11
11
|
$!minute += $min and return self;
|
12
12
|
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env perl6
|
2
|
+
use v6;
|
3
|
+
use Test;
|
4
|
+
use lib my $dir = $?FILE.IO.dirname;
|
5
|
+
use JSON::Tiny;
|
6
|
+
|
7
|
+
my $exercise = 'FlattenArray';
|
8
|
+
my $version = v1;
|
9
|
+
my $module = %*ENV<EXERCISM> ?? 'Example' !! $exercise;
|
10
|
+
plan 8;
|
11
|
+
|
12
|
+
use-ok $module or bail-out;
|
13
|
+
require ::($module);
|
14
|
+
|
15
|
+
if ::($exercise).^ver !~~ $version {
|
16
|
+
warn "\nExercise version mismatch. Further tests may fail!"
|
17
|
+
~ "\n$exercise is $(::($exercise).^ver.gist). "
|
18
|
+
~ "Test is $($version.gist).\n";
|
19
|
+
bail-out 'Example version must match test version.' if %*ENV<EXERCISM>;
|
20
|
+
}
|
21
|
+
|
22
|
+
require ::($module) <&flatten-array>;
|
23
|
+
|
24
|
+
my $c-data;
|
25
|
+
is-deeply &::('flatten-array')(.<input>), |.<expected description> for @($c-data<cases>);
|
26
|
+
|
27
|
+
if %*ENV<EXERCISM> && (my $c-data-file =
|
28
|
+
"$dir/../../x-common/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f
|
29
|
+
{ is-deeply $c-data, from-json($c-data-file.slurp), 'canonical-data' } else { skip }
|
30
|
+
|
31
|
+
done-testing;
|
32
|
+
|
33
|
+
INIT {
|
34
|
+
$c-data := from-json q:to/END/;
|
35
|
+
|
36
|
+
{
|
37
|
+
"exercise": "flatten-array",
|
38
|
+
"version": "1.1.0",
|
39
|
+
"cases": [
|
40
|
+
{
|
41
|
+
"description": "no nesting",
|
42
|
+
"property": "flatten",
|
43
|
+
"input": [0, 1, 2],
|
44
|
+
"expected": [0, 1, 2]
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"description": "flattens array with just integers present",
|
48
|
+
"property": "flatten",
|
49
|
+
"input": [1, [2, 3, 4, 5, 6, 7], 8],
|
50
|
+
"expected": [1, 2, 3, 4, 5, 6, 7, 8]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"description": "5 level nesting",
|
54
|
+
"property": "flatten",
|
55
|
+
"input": [0, 2, [[2, 3], 8, 100, 4, [[[50]]]], -2],
|
56
|
+
"expected": [0, 2, 2, 3, 8, 100, 4, 50, -2]
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"description": "6 level nesting",
|
60
|
+
"property": "flatten",
|
61
|
+
"input": [1, [2, [[3]], [4, [[5]]], 6, 7], 8],
|
62
|
+
"expected": [1, 2, 3, 4, 5, 6, 7, 8]
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"description": "6 level nest list with null values",
|
66
|
+
"property": "flatten",
|
67
|
+
"input": [0, 2, [[2, 3], 8, [[100]], null, [[null]]], -2],
|
68
|
+
"expected": [0, 2, 2, 3, 8, 100, -2]
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"description": "all values in nested list are null",
|
72
|
+
"property": "flatten",
|
73
|
+
"input": [null, [[[null]]], null, null, [[null, null], null], null],
|
74
|
+
"expected": []
|
75
|
+
}
|
76
|
+
]
|
77
|
+
}
|
78
|
+
|
79
|
+
END
|
80
|
+
}
|
data/tracks/php/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/php/README.md
CHANGED
@@ -48,11 +48,6 @@ If you need command line help for run make commands
|
|
48
48
|
- Follow the [PSR-2] coding style (xPHP uses a slightly [modified] version of [PSR-2]).
|
49
49
|
- Follow the [contributing guide].
|
50
50
|
|
51
|
-
## License
|
52
|
-
|
53
|
-
The MIT License (MIT)
|
54
|
-
|
55
|
-
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
56
51
|
|
57
52
|
|
58
53
|
[PSR-2]: http://www.php-fig.org/psr/psr-2
|
data/tracks/python/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/python/README.md
CHANGED
@@ -53,11 +53,6 @@ If you're interested, Tim Pope even has an [entire blog post](http://tbaggery.co
|
|
53
53
|
|
54
54
|
If you're new to Git take a look at [this short guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#git-basics).
|
55
55
|
|
56
|
-
## License
|
57
|
-
|
58
|
-
The MIT License (MIT)
|
59
|
-
|
60
|
-
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
61
56
|
|
62
57
|
## Python icon
|
63
58
|
The Python logo is an unregistered trademark. We are using a derived logo with the permission of the Python Software Foundation.
|
data/tracks/python/config.json
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
CODONS = {'AUG': "Methionine", 'UUU': "Phenylalanine",
|
2
|
+
'UUC': "Phenylalanine", 'UUA': "Leucine", 'UUG': "Leucine",
|
3
|
+
'UCU': "Serine", 'UCC': "Serine", 'UCA': "Serine",
|
4
|
+
'UCG': "Serine", 'UAU': "Tyrosine", 'UAC': "Tyrosine",
|
5
|
+
'UGU': "Cysteine", 'UGC': "Cysteine", 'UGG': "Tryptophan",
|
6
|
+
'UAA': "STOP", 'UAG': "STOP", 'UGA': "STOP"}
|
7
|
+
|
8
|
+
|
9
|
+
def of_codon(codon):
|
10
|
+
if codon not in CODONS:
|
11
|
+
raise ValueError('Invalid codon: %s' % codon)
|
12
|
+
return CODONS[codon]
|
13
|
+
|
14
|
+
|
15
|
+
def of_rna(strand):
|
16
|
+
proteins = []
|
17
|
+
for codon in map(of_codon, _chunkstring(strand, 3)):
|
18
|
+
if codon == 'STOP':
|
19
|
+
break
|
20
|
+
proteins.append(codon)
|
21
|
+
return proteins
|
22
|
+
|
23
|
+
|
24
|
+
def _chunkstring(string, n):
|
25
|
+
return (string[i:n + i] for i in range(0, len(string), n))
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
from protein_translation import of_codon, of_rna
|
4
|
+
|
5
|
+
|
6
|
+
class ProteinTranslationTests(unittest.TestCase):
|
7
|
+
|
8
|
+
def test_AUG_translates_to_methionine(self):
|
9
|
+
self.assertEqual('Methionine', of_codon('AUG'))
|
10
|
+
|
11
|
+
def test_identifies_Phenylalanine_codons(self):
|
12
|
+
for codon in ['UUU', 'UUC']:
|
13
|
+
self.assertEqual('Phenylalanine', of_codon(codon))
|
14
|
+
|
15
|
+
def test_identifies_Leucine_codons(self):
|
16
|
+
for codon in ['UUA', 'UUG']:
|
17
|
+
self.assertEqual('Leucine', of_codon(codon))
|
18
|
+
|
19
|
+
def test_identifies_Serine_codons(self):
|
20
|
+
for codon in ['UCU', 'UCC', 'UCA', 'UCG']:
|
21
|
+
self.assertEqual('Serine', of_codon(codon))
|
22
|
+
|
23
|
+
def test_identifies_Tyrosine_codons(self):
|
24
|
+
for codon in ['UAU', 'UAC']:
|
25
|
+
self.assertEqual('Tyrosine', of_codon(codon))
|
26
|
+
|
27
|
+
def test_identifies_Cysteine_codons(self):
|
28
|
+
for codon in ['UGU', 'UGC']:
|
29
|
+
self.assertEqual('Cysteine', of_codon(codon))
|
30
|
+
|
31
|
+
def test_identifies_Tryptophan_codons(self):
|
32
|
+
self.assertEqual('Tryptophan', of_codon('UGG'))
|
33
|
+
|
34
|
+
def test_identifies_stop_codons(self):
|
35
|
+
for codon in ['UAA', 'UAG', 'UGA']:
|
36
|
+
self.assertEqual('STOP', of_codon(codon))
|
37
|
+
|
38
|
+
def test_translates_rna_strand_into_correct_protein(self):
|
39
|
+
strand = 'AUGUUUUGG'
|
40
|
+
expected = ['Methionine', 'Phenylalanine', 'Tryptophan']
|
41
|
+
self.assertEqual(expected, of_rna(strand))
|
42
|
+
|
43
|
+
def test_stops_translation_if_stop_codon_present(self):
|
44
|
+
strand = 'AUGUUUUAA'
|
45
|
+
expected = ['Methionine', 'Phenylalanine']
|
46
|
+
self.assertEqual(expected, of_rna(strand))
|
47
|
+
|
48
|
+
def test_stops_translation_of_longer_strand(self):
|
49
|
+
strand = 'UGGUGUUAUUAAUGGUUU'
|
50
|
+
expected = ['Tryptophan', 'Cysteine', 'Tyrosine']
|
51
|
+
self.assertEqual(expected, of_rna(strand))
|
52
|
+
|
53
|
+
def test_invalid_codons(self):
|
54
|
+
with self.assertRaises(ValueError):
|
55
|
+
of_rna('CARROT')
|
56
|
+
|
57
|
+
|
58
|
+
if __name__ == '__main__':
|
59
|
+
unittest.main()
|