trackler 2.0.8.6 → 2.0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/bin/verify-metadata +7 -11
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/clojure/config.json +5 -0
  5. data/tracks/clojure/exercises/luhn/luhn.mustache +9 -0
  6. data/tracks/clojure/exercises/luhn/src/example.clj +11 -9
  7. data/tracks/clojure/exercises/luhn/test/luhn_test.clj +29 -29
  8. data/tracks/clojure/exercises/nth-prime/project.clj +4 -0
  9. data/tracks/clojure/exercises/nth-prime/src/example.clj +33 -0
  10. data/tracks/clojure/exercises/nth-prime/test/nth_prime_test.clj +23 -0
  11. data/tracks/go/exercises/TRACK_HINTS.md +3 -0
  12. data/tracks/go/exercises/ocr-numbers/example.go +2 -0
  13. data/tracks/go/exercises/ocr-numbers/ocr_numbers_test.go +8 -0
  14. data/tracks/go/exercises/octal/octal_test.go +6 -6
  15. data/tracks/go/exercises/paasio/paasio_test.go +5 -3
  16. data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +6 -6
  17. data/tracks/go/exercises/strain/strain_test.go +37 -39
  18. data/tracks/julia/config.json +19 -0
  19. data/tracks/julia/exercises/etl/etl.jl +4 -0
  20. data/tracks/julia/exercises/etl/example.jl +11 -0
  21. data/tracks/julia/exercises/etl/runtests.jl +36 -0
  22. data/tracks/julia/exercises/pascals-triangle/example.jl +1 -0
  23. data/tracks/julia/exercises/pascals-triangle/pascals-triangle.jl +3 -0
  24. data/tracks/julia/exercises/pascals-triangle/runtests.jl +14 -0
  25. data/tracks/rust/config.json +22 -1
  26. data/tracks/rust/exercises/luhn-from/.gitignore +7 -0
  27. data/tracks/rust/exercises/luhn-from/Cargo.toml +3 -0
  28. data/tracks/rust/exercises/luhn-from/description.md +9 -0
  29. data/tracks/rust/exercises/luhn-from/example.rs +62 -0
  30. data/tracks/rust/exercises/luhn-from/metadata.yml +3 -0
  31. data/tracks/rust/exercises/luhn-from/tests/luhn-from.rs +101 -0
  32. data/tracks/rust/exercises/luhn-trait/.gitignore +7 -0
  33. data/tracks/rust/exercises/luhn-trait/Cargo.toml +3 -0
  34. data/tracks/rust/exercises/luhn-trait/description.md +17 -0
  35. data/tracks/rust/exercises/luhn-trait/example.rs +55 -0
  36. data/tracks/rust/exercises/luhn-trait/metadata.yml +3 -0
  37. data/tracks/rust/exercises/luhn-trait/tests/luhn-trait.rs +59 -0
  38. data/tracks/rust/exercises/nucleotide-codons/tests/codons.rs +24 -5
  39. data/tracks/rust/exercises/protein-translation/Cargo.lock +4 -0
  40. data/tracks/rust/exercises/protein-translation/Cargo.toml +4 -0
  41. data/tracks/rust/exercises/protein-translation/example.rs +40 -0
  42. data/tracks/rust/exercises/protein-translation/tests/proteins.rs +116 -0
  43. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc2b57e4b486bcc77b52bbfe5bc1098cca12d924
4
- data.tar.gz: d622632279a4be7e8db15ab4e4bcd7d83c0aec7a
3
+ metadata.gz: 24f1a3e4a5a11da7a5de103a0fb55263037dba6c
4
+ data.tar.gz: 046a666971406ee116df5a9830b13332a2fbc175
5
5
  SHA512:
6
- metadata.gz: 41d9d8c01652e2ff4bce110e180162b96c4c14986571e015a0a43a4fb95a1096f2db408290e552bda51c791eca1e860b80d13183a06d30a054de9ffd1acaa7de
7
- data.tar.gz: 5313d089495cab376191ceb9096ecfd8208717b3491accab4e41bb7b43b48482bb4cde70da981f88fce929dc03544222c224969b3bc35d742df08d3df42db3c4
6
+ metadata.gz: 7cff9d347f2f4ad9973fd4584c05ed5cf4e48b922521b09026bf248f94f721ceed614a8a728d6c0887e52eaec5db6dea5d3a04b2fdb7f03cd6ef65816cdeb464
7
+ data.tar.gz: 06896ee26a2bc013de9fa5720348313949c69a0f7ab5140a8f6c13fe00d0aa704d79e3d31a66e2a34c83be49e122f118292144a6acfd9de8bc262d57f57aad0f
@@ -4,20 +4,16 @@ require 'json'
4
4
 
5
5
  require_relative '../lib/trackler'
6
6
 
7
- omissions = []
8
- Trackler.tracks.each do |track|
9
- track.problems.each do |problem|
10
- unless Trackler.problems[problem.slug].exists?
11
- omissions << slug
12
- end
13
- end
7
+ missing_problems = []
8
+ Trackler.tracks.reject do |track|
9
+ missing_problems += track.problems.reject(&:exists?)
14
10
  end
15
11
 
16
- omissions = omissions.uniq
17
- unless omissions.empty?
12
+ missing_problems = missing_problems.uniq
13
+ unless missing_problems.empty?
18
14
  puts "missing:"
19
- omissions.each do |omission|
20
- puts " #{omission}"
15
+ missing_problems.each do |problem|
16
+ puts " #{problem.slug}"
21
17
  end
22
18
  exit 1
23
19
  end
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.8.6"
2
+ VERSION = "2.0.8.7"
3
3
  end
@@ -292,6 +292,11 @@
292
292
  "slug": "acronym",
293
293
  "topics": []
294
294
  },
295
+ {
296
+ "difficulty": 1,
297
+ "slug": "nth-prime",
298
+ "topics": []
299
+ },
295
300
  {
296
301
  "difficulty": 1,
297
302
  "slug": "pig-latin",
@@ -0,0 +1,9 @@
1
+ (ns luhn-test
2
+ (:require [clojure.test :refer [deftest is testing]]
3
+ luhn))
4
+
5
+ (deftest validity-tests
6
+ {{#valid}}
7
+ (testing "{{{description}}}"
8
+ (is ({{{expected}}}? (luhn/valid? "{{{input}}}"))))
9
+ {{/valid}})
@@ -1,4 +1,5 @@
1
- (ns luhn)
1
+ (ns luhn
2
+ (:require [clojure.string :as string]))
2
3
 
3
4
  (defn to-reversed-digits
4
5
  "returns a lazy sequence of least to most significant digits of n"
@@ -19,14 +20,15 @@
19
20
  (apply +))
20
21
  (mod 10)))
21
22
 
22
- (defn valid?
23
- "whether n has a valid luhn check-digit"
23
+ (defn string->long
24
+ "Strips any non-digit characters and converts the string into a Long"
24
25
  [n]
25
- (zero? (checksum n)))
26
+ (-> n (string/replace #"[^0-9]+" "") Long/parseLong))
26
27
 
27
- (defn add-check-digit
28
- "given a number, adds a luhn check digit at the end"
28
+ (defn valid?
29
+ "whether n has a valid luhn check-digit"
29
30
  [n]
30
- (let [n-shifted (* 10 n)
31
- check-digit (- 10 (checksum n-shifted))]
32
- (+ n-shifted check-digit)))
31
+ ; Numbers with non digit/whitespace or only 1 digit are invalid
32
+ (if (or (re-find #"[^0-9\s]+" n) (>= 1 (count (string/trim n))))
33
+ false
34
+ (zero? (-> n string->long checksum))))
@@ -1,32 +1,32 @@
1
1
  (ns luhn-test
2
- (:require [clojure.test :refer [deftest is]]
2
+ (:require [clojure.test :refer [deftest is testing]]
3
3
  luhn))
4
4
 
5
- (deftest checksum-works
6
- (is (= 2 (luhn/checksum 10)))
7
- (is (= 9 (luhn/checksum 90)))
8
- (is (= 1 (luhn/checksum 100)))
9
- (is (= 2 (luhn/checksum 1000)))
10
- (is (= 1 (luhn/checksum 10000000000000000)))
11
- (is (= 6 (luhn/checksum 1111)))
12
- (is (= 0 (luhn/checksum 8763)))
13
- (is (= 0 (luhn/checksum 2323200577663554))))
14
-
15
- (deftest valid?-works
16
- (is (= true (luhn/valid? 18)))
17
- (is (= true (luhn/valid? 59)))
18
- (is (= false (luhn/valid? 63)))
19
- (is (= true (luhn/valid? 8763)))
20
- (is (= false (luhn/valid? 1111)))
21
- (is (= true (luhn/valid? 4242424242424242)))
22
- (is (= true (luhn/valid? 2323200577663554)))
23
- (is (= false (luhn/valid? 2323200577663555)))
24
- (is (= false (luhn/valid? 2223200577663554)))
25
- (is (= false (luhn/valid? 3323200577663554))))
26
-
27
- (deftest add-check-digit-works
28
- (is (= 18 (luhn/add-check-digit 1)))
29
- (is (= 59 (luhn/add-check-digit 5)))
30
- (is (= 8763 (luhn/add-check-digit 876)))
31
- (is (= 4242424242424242 (luhn/add-check-digit 424242424242424)))
32
- (is (= 2323200577663554 (luhn/add-check-digit 232320057766355))))
5
+ (deftest validity-tests
6
+ (testing "single digit strings can not be valid"
7
+ (is (false? (luhn/valid? "1"))))
8
+ (testing "A single zero is invalid"
9
+ (is (false? (luhn/valid? "0"))))
10
+ (testing "simple valid sin"
11
+ (is (true? (luhn/valid? " 5 9 "))))
12
+ (testing "valid Canadian SIN"
13
+ (is (true? (luhn/valid? "046 454 286"))))
14
+ (testing "invalid Canadian SIN"
15
+ (is (false? (luhn/valid? "046 454 287"))))
16
+ (testing "invalid credit card"
17
+ (is (false? (luhn/valid? "8273 1232 7352 0569"))))
18
+ (testing "valid strings with a non-digit added become invalid"
19
+ (is (false? (luhn/valid? "046a 454 286"))))
20
+ (testing "punctuation is not allowed"
21
+ (is (false? (luhn/valid? "055-444-285"))))
22
+ (testing "symbols are not allowed"
23
+ (is (false? (luhn/valid? "055£ 444$ 285"))))
24
+ (testing "single zero with space is invalid"
25
+ (is (false? (luhn/valid? " 0"))))
26
+ (testing "lots of zeros are valid"
27
+ (is (true? (luhn/valid? " 00000"))))
28
+ (testing "another valid sin"
29
+ (is (true? (luhn/valid? "055 444 285"))))
30
+ (testing "nine doubled is nine"
31
+ (is (true? (luhn/valid? "091"))))
32
+ )
@@ -0,0 +1,4 @@
1
+ (defproject nth-prime "0.1.0-SNAPSHOT"
2
+ :description "nth-prime exercise."
3
+ :url "https://github.com/exercism/xclojure/tree/master/exercises/nth-prime"
4
+ :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -0,0 +1,33 @@
1
+ (ns nth-prime)
2
+
3
+ (defn sqrt
4
+ "Wrapper around java's sqrt method."
5
+ [number]
6
+ (int (Math/ceil (Math/sqrt number))))
7
+
8
+ (defn divides?
9
+ "Helper function to decide if a number is evenly divided by divisor."
10
+ [number divisor]
11
+ (zero? (mod number divisor)))
12
+
13
+ (defn- prime-by-trial-division?
14
+ "Simple trial division prime check."
15
+ [number]
16
+ (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))
17
+
18
+ (defn prime? [number]
19
+ (or (= 2 number)
20
+ (and (odd? number) (prime-by-trial-division? number))))
21
+
22
+ (defn next-prime [start]
23
+ (loop [n (inc start)]
24
+ (if (prime? n)
25
+ n
26
+ (recur (inc n)))))
27
+
28
+ (def primes (iterate next-prime 1))
29
+
30
+ (defn nth-prime [index]
31
+ (when-not (pos? index)
32
+ (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
33
+ (nth primes index))
@@ -0,0 +1,23 @@
1
+ (ns nth-prime-test
2
+ (:require [clojure.test :refer [deftest testing is]]
3
+ nth-prime))
4
+
5
+ (deftest first-prime
6
+ (testing "the first prime is 2"
7
+ (is (= 2 (nth-prime/nth-prime 1)))))
8
+
9
+ (deftest second-prime
10
+ (testing "the second prime is 3"
11
+ (is (= 3 (nth-prime/nth-prime 2)))))
12
+
13
+ (deftest sixth-prime
14
+ (testing "the sixth prime is 13"
15
+ (is (= 13 (nth-prime/nth-prime 6)))))
16
+
17
+ (deftest ten-thousand-first-prime
18
+ (testing "the ten thousand and first prime is 104743"
19
+ (is (= 104743 (nth-prime/nth-prime 10001)))))
20
+
21
+ (deftest zeroth-prime
22
+ (testing "there is no zeroth prime"
23
+ (is (thrown? IllegalArgumentException (nth-prime/nth-prime 0)))))
@@ -7,6 +7,9 @@ flag:
7
7
 
8
8
  go test -bench .
9
9
 
10
+ Keep in mind that each reviewer will run benchmarks on a different machine, with
11
+ different specs, so the results from these benchmark tests may vary.
12
+
10
13
  ## Further information
11
14
 
12
15
  For more detailed information about the Go track, including how to get help if
@@ -2,6 +2,8 @@ package ocr
2
2
 
3
3
  import "strings"
4
4
 
5
+ const testVersion = 1
6
+
5
7
  var digit = map[string]byte{
6
8
  " _ | ||_| ": '0',
7
9
  " | | ": '1',
@@ -25,6 +25,8 @@ import (
25
25
  "testing"
26
26
  )
27
27
 
28
+ const targetTestVersion = 1
29
+
28
30
  var tests = []struct {
29
31
  in string
30
32
  out []string
@@ -121,6 +123,12 @@ var tests = []struct {
121
123
 
122
124
  var _ = recognizeDigit // step 1.
123
125
 
126
+ func TestTestVersion(t *testing.T) {
127
+ if testVersion != targetTestVersion {
128
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
129
+ }
130
+ }
131
+
124
132
  func TestRecognize(t *testing.T) {
125
133
  for _, test := range tests {
126
134
  if res := Recognize(test.in); !reflect.DeepEqual(res, test.out) {
@@ -18,6 +18,12 @@ var testCases = []struct {
18
18
  {"35682", 0, true},
19
19
  }
20
20
 
21
+ func TestTestVersion(t *testing.T) {
22
+ if testVersion != targetTestVersion {
23
+ t.Fatalf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
24
+ }
25
+ }
26
+
21
27
  func TestParseOctal(t *testing.T) {
22
28
  for _, test := range testCases {
23
29
  actualNum, actualErr := ParseOctal(test.input)
@@ -38,12 +44,6 @@ func TestParseOctal(t *testing.T) {
38
44
  }
39
45
  }
40
46
 
41
- func TestTestVersion(t *testing.T) {
42
- if testVersion != targetTestVersion {
43
- t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
44
- }
45
- }
46
-
47
47
  func BenchmarkParseOctal(b *testing.B) {
48
48
  b.StopTimer()
49
49
 
@@ -11,13 +11,15 @@ import (
11
11
  "time"
12
12
  )
13
13
 
14
- // testVersion identifies the API tested by the test program.
15
14
  const targetTestVersion = 3
16
15
 
17
- func TestMultiThreaded(t *testing.T) {
16
+ func TestTestVersion(t *testing.T) {
18
17
  if testVersion != targetTestVersion {
19
- t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
18
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
20
19
  }
20
+ }
21
+
22
+ func TestMultiThreaded(t *testing.T) {
21
23
  mincpu := 2
22
24
  minproc := 2
23
25
  ncpu := runtime.NumCPU()
@@ -75,6 +75,12 @@ var bonusData = []struct {
75
75
  ""},
76
76
  }
77
77
 
78
+ func TestTestVersion(t *testing.T) {
79
+ if testVersion != targetTestVersion {
80
+ t.Fatalf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
81
+ }
82
+ }
83
+
78
84
  func TestPalindromeProducts(t *testing.T) {
79
85
  // Uncomment the following line to add the bonus test to the default tests
80
86
  // testData = append(testData, bonusData...)
@@ -109,12 +115,6 @@ func TestPalindromeProducts(t *testing.T) {
109
115
  }
110
116
  }
111
117
 
112
- func TestTestVersion(t *testing.T) {
113
- if testVersion != targetTestVersion {
114
- t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
115
- }
116
- }
117
-
118
118
  func BenchmarkPalindromeProducts(b *testing.B) {
119
119
  for i := 0; i < b.N; i++ {
120
120
  for _, test := range testData {
@@ -21,12 +21,6 @@ import (
21
21
 
22
22
  const targetTestVersion = 1
23
23
 
24
- func TestTestVersion(t *testing.T) {
25
- if testVersion != targetTestVersion {
26
- t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
27
- }
28
- }
29
-
30
24
  func lt10(x int) bool { return x < 10 }
31
25
  func gt10(x int) bool { return x > 10 }
32
26
  func odd(x int) bool { return x&1 == 1 }
@@ -51,26 +45,6 @@ var keepTests = []struct {
51
45
  Ints{2, 4}},
52
46
  }
53
47
 
54
- func TestKeepInts(t *testing.T) {
55
- for _, test := range keepTests {
56
- // setup here copies test.list, preserving the nil value if it is nil
57
- // and making a fresh copy of the underlying array otherwise.
58
- cp := test.list
59
- if cp != nil {
60
- cp = append(Ints{}, cp...)
61
- }
62
- switch res := cp.Keep(test.pred); {
63
- case !reflect.DeepEqual(cp, test.list):
64
- t.Fatalf("Ints%v.Keep() should not modify its reciever. "+
65
- "Found %v, reciever should stay %v",
66
- test.list, cp, test.list)
67
- case !reflect.DeepEqual(res, test.want):
68
- t.Fatalf("Ints%v.Keep() = %v, want %v",
69
- test.list, res, test.want)
70
- }
71
- }
72
- }
73
-
74
48
  var discardTests = []struct {
75
49
  pred func(int) bool
76
50
  list Ints
@@ -90,6 +64,32 @@ var discardTests = []struct {
90
64
  Ints{1, 3, 5}},
91
65
  }
92
66
 
67
+ func TestTestVersion(t *testing.T) {
68
+ if testVersion != targetTestVersion {
69
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
70
+ }
71
+ }
72
+
73
+ func TestKeepInts(t *testing.T) {
74
+ for _, test := range keepTests {
75
+ // setup here copies test.list, preserving the nil value if it is nil
76
+ // and making a fresh copy of the underlying array otherwise.
77
+ cp := test.list
78
+ if cp != nil {
79
+ cp = append(Ints{}, cp...)
80
+ }
81
+ switch res := cp.Keep(test.pred); {
82
+ case !reflect.DeepEqual(cp, test.list):
83
+ t.Fatalf("%#v.Keep() should not modify its receiver. "+
84
+ "Found %#v, receiver should stay %#v",
85
+ test.list, cp, test.list)
86
+ case !reflect.DeepEqual(res, test.want):
87
+ t.Fatalf("%#v.Keep()\ngot: %#v\nwant: %#v",
88
+ test.list, res, test.want)
89
+ }
90
+ }
91
+ }
92
+
93
93
  func TestDiscardInts(t *testing.T) {
94
94
  for _, test := range discardTests {
95
95
  cp := test.list
@@ -98,11 +98,11 @@ func TestDiscardInts(t *testing.T) {
98
98
  }
99
99
  switch res := cp.Discard(test.pred); {
100
100
  case !reflect.DeepEqual(cp, test.list):
101
- t.Fatalf("Ints%v.Discard() should not modify its reciever. "+
102
- "Found %v, reciever should stay %v",
101
+ t.Fatalf("%#v.Discard() should not modify its receiver. "+
102
+ "Found %#v, receiver should stay %#v",
103
103
  test.list, cp, test.list)
104
104
  case !reflect.DeepEqual(res, test.want):
105
- t.Fatalf("Ints%v.Discard() = %v, want %v",
105
+ t.Fatalf("%#v.Discard()\ngot: %#v\nwant: %#v",
106
106
  test.list, res, test.want)
107
107
  }
108
108
  }
@@ -110,18 +110,17 @@ func TestDiscardInts(t *testing.T) {
110
110
 
111
111
  func TestKeepStrings(t *testing.T) {
112
112
  zword := func(s string) bool { return len(s) > 0 && s[0] == 'z' }
113
- list := Strings{"apple", "zebra", "banana", "zombies", "cherimoya", "zelot"}
114
- want := Strings{"zebra", "zombies", "zelot"}
113
+ list := Strings{"apple", "zebra", "banana", "zombies", "cherimoya", "zealot"}
114
+ want := Strings{"zebra", "zombies", "zealot"}
115
115
 
116
116
  cp := append(Strings{}, list...) // make copy, as with TestInts
117
117
  switch res := cp.Keep(zword); {
118
118
  case !reflect.DeepEqual(cp, list):
119
- t.Fatalf("Strings%v.Keep() should not modify its reciever. "+
120
- "Found %v, reciever should stay %v",
119
+ t.Fatalf("%#v.Keep() should not modify its receiver. "+
120
+ "Found %#v, receiver should stay %#v",
121
121
  list, cp, list)
122
122
  case !reflect.DeepEqual(res, want):
123
- t.Fatalf("Strings%v.Keep() = %v, want %v",
124
- list, res, want)
123
+ t.Fatalf("%#v.Keep()\ngot: %#v\nwant: %#v", list, res, want)
125
124
  }
126
125
  }
127
126
 
@@ -152,12 +151,11 @@ func TestKeepLists(t *testing.T) {
152
151
  cp := append(Lists{}, list...)
153
152
  switch res := cp.Keep(has5); {
154
153
  case !reflect.DeepEqual(cp, list):
155
- t.Fatalf("Lists%v.Keep() should not modify its reciever. "+
156
- "Found %v, reciever should stay %v",
154
+ t.Fatalf("%#v.Keep() should not modify its receiver. "+
155
+ "Found %#v, receiver should stay %#v",
157
156
  list, cp, list)
158
157
  case !reflect.DeepEqual(res, want):
159
- t.Fatalf("Lists%v.Keep() = %v, want %v",
160
- list, res, want)
158
+ t.Fatalf("%#v.Keep()\ngot: %#v\nwant: %#v", list, res, want)
161
159
  }
162
160
  }
163
161