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.
- checksums.yaml +4 -4
- data/bin/verify-metadata +7 -11
- data/lib/trackler/version.rb +1 -1
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/luhn/luhn.mustache +9 -0
- data/tracks/clojure/exercises/luhn/src/example.clj +11 -9
- data/tracks/clojure/exercises/luhn/test/luhn_test.clj +29 -29
- data/tracks/clojure/exercises/nth-prime/project.clj +4 -0
- data/tracks/clojure/exercises/nth-prime/src/example.clj +33 -0
- data/tracks/clojure/exercises/nth-prime/test/nth_prime_test.clj +23 -0
- data/tracks/go/exercises/TRACK_HINTS.md +3 -0
- data/tracks/go/exercises/ocr-numbers/example.go +2 -0
- data/tracks/go/exercises/ocr-numbers/ocr_numbers_test.go +8 -0
- data/tracks/go/exercises/octal/octal_test.go +6 -6
- data/tracks/go/exercises/paasio/paasio_test.go +5 -3
- data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +6 -6
- data/tracks/go/exercises/strain/strain_test.go +37 -39
- data/tracks/julia/config.json +19 -0
- data/tracks/julia/exercises/etl/etl.jl +4 -0
- data/tracks/julia/exercises/etl/example.jl +11 -0
- data/tracks/julia/exercises/etl/runtests.jl +36 -0
- data/tracks/julia/exercises/pascals-triangle/example.jl +1 -0
- data/tracks/julia/exercises/pascals-triangle/pascals-triangle.jl +3 -0
- data/tracks/julia/exercises/pascals-triangle/runtests.jl +14 -0
- data/tracks/rust/config.json +22 -1
- data/tracks/rust/exercises/luhn-from/.gitignore +7 -0
- data/tracks/rust/exercises/luhn-from/Cargo.toml +3 -0
- data/tracks/rust/exercises/luhn-from/description.md +9 -0
- data/tracks/rust/exercises/luhn-from/example.rs +62 -0
- data/tracks/rust/exercises/luhn-from/metadata.yml +3 -0
- data/tracks/rust/exercises/luhn-from/tests/luhn-from.rs +101 -0
- data/tracks/rust/exercises/luhn-trait/.gitignore +7 -0
- data/tracks/rust/exercises/luhn-trait/Cargo.toml +3 -0
- data/tracks/rust/exercises/luhn-trait/description.md +17 -0
- data/tracks/rust/exercises/luhn-trait/example.rs +55 -0
- data/tracks/rust/exercises/luhn-trait/metadata.yml +3 -0
- data/tracks/rust/exercises/luhn-trait/tests/luhn-trait.rs +59 -0
- data/tracks/rust/exercises/nucleotide-codons/tests/codons.rs +24 -5
- data/tracks/rust/exercises/protein-translation/Cargo.lock +4 -0
- data/tracks/rust/exercises/protein-translation/Cargo.toml +4 -0
- data/tracks/rust/exercises/protein-translation/example.rs +40 -0
- data/tracks/rust/exercises/protein-translation/tests/proteins.rs +116 -0
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f1a3e4a5a11da7a5de103a0fb55263037dba6c
|
4
|
+
data.tar.gz: 046a666971406ee116df5a9830b13332a2fbc175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cff9d347f2f4ad9973fd4584c05ed5cf4e48b922521b09026bf248f94f721ceed614a8a728d6c0887e52eaec5db6dea5d3a04b2fdb7f03cd6ef65816cdeb464
|
7
|
+
data.tar.gz: 06896ee26a2bc013de9fa5720348313949c69a0f7ab5140a8f6c13fe00d0aa704d79e3d31a66e2a34c83be49e122f118292144a6acfd9de8bc262d57f57aad0f
|
data/bin/verify-metadata
CHANGED
@@ -4,20 +4,16 @@ require 'json'
|
|
4
4
|
|
5
5
|
require_relative '../lib/trackler'
|
6
6
|
|
7
|
-
|
8
|
-
Trackler.tracks.
|
9
|
-
track.problems.
|
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
|
-
|
17
|
-
unless
|
12
|
+
missing_problems = missing_problems.uniq
|
13
|
+
unless missing_problems.empty?
|
18
14
|
puts "missing:"
|
19
|
-
|
20
|
-
puts " #{
|
15
|
+
missing_problems.each do |problem|
|
16
|
+
puts " #{problem.slug}"
|
21
17
|
end
|
22
18
|
exit 1
|
23
19
|
end
|
data/lib/trackler/version.rb
CHANGED
data/tracks/clojure/config.json
CHANGED
@@ -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
|
23
|
-
"
|
23
|
+
(defn string->long
|
24
|
+
"Strips any non-digit characters and converts the string into a Long"
|
24
25
|
[n]
|
25
|
-
(
|
26
|
+
(-> n (string/replace #"[^0-9]+" "") Long/parseLong))
|
26
27
|
|
27
|
-
(defn
|
28
|
-
"
|
28
|
+
(defn valid?
|
29
|
+
"whether n has a valid luhn check-digit"
|
29
30
|
[n]
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
6
|
-
(
|
7
|
-
|
8
|
-
(
|
9
|
-
|
10
|
-
(
|
11
|
-
|
12
|
-
(
|
13
|
-
|
14
|
-
|
15
|
-
(
|
16
|
-
(
|
17
|
-
|
18
|
-
(
|
19
|
-
|
20
|
-
(
|
21
|
-
|
22
|
-
(
|
23
|
-
|
24
|
-
(
|
25
|
-
|
26
|
-
|
27
|
-
(
|
28
|
-
(
|
29
|
-
|
30
|
-
(
|
31
|
-
|
32
|
-
|
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,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
|
@@ -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
|
16
|
+
func TestTestVersion(t *testing.T) {
|
18
17
|
if testVersion != targetTestVersion {
|
19
|
-
t.
|
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("
|
102
|
-
"Found
|
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("
|
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", "
|
114
|
-
want := Strings{"zebra", "zombies", "
|
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("
|
120
|
-
"Found
|
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("
|
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("
|
156
|
-
"Found
|
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("
|
160
|
-
list, res, want)
|
158
|
+
t.Fatalf("%#v.Keep()\ngot: %#v\nwant: %#v", list, res, want)
|
161
159
|
}
|
162
160
|
}
|
163
161
|
|