trackler 2.0.6.27 → 2.0.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/common/exercises/atbash-cipher/canonical-data.json +0 -5
- data/common/exercises/forth/canonical-data.json +0 -7
- data/common/exercises/forth/description.md +1 -1
- data/common/exercises/run-length-encoding/description.md +3 -0
- data/common/exercises/scrabble-score/canonical-data.json +0 -5
- data/lib/trackler/version.rb +1 -1
- data/tracks/go/exercises/accumulate/accumulate_test.go +8 -0
- data/tracks/go/exercises/accumulate/example.go +2 -0
- data/tracks/haskell/exercises/etl/test/Tests.hs +9 -10
- data/tracks/haskell/exercises/phone-number/examples/success-standard/src/Phone.hs +3 -20
- data/tracks/haskell/exercises/phone-number/src/Phone.hs +1 -7
- data/tracks/haskell/exercises/phone-number/test/Tests.hs +24 -75
- data/tracks/julia/config.json +21 -1
- data/tracks/julia/exercises/scrabble-score/example.jl +9 -0
- data/tracks/julia/exercises/scrabble-score/runtests.jl +51 -0
- data/tracks/julia/exercises/scrabble-score/scrabble-score.jl +3 -0
- data/tracks/julia/exercises/trinary/example.jl +4 -0
- data/tracks/julia/exercises/trinary/runtests.jl +47 -0
- data/tracks/julia/exercises/trinary/trinary.jl +3 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 736e4db3e2429c9b67fb27e87f41a30a6132a752
|
4
|
+
data.tar.gz: 1eb49babc9e28e63b04bfbd2cedeef4912fc776c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b530e182140aad12d98661877c4adec3caedb925da0c1e57811026cb6addd88d53a61f3685e9881b662434ae0e7466abbc34686c7467cb8c5c82efcdbaec07cb
|
7
|
+
data.tar.gz: 3a2a7504e6a45ae664f5d013a57bd44a4e93866f040bbcf2c9bf17993fe60cf02be5b1aad47959f6039e66b0bbca21bd006e92abe81aae2585f4d1aacd7de949
|
@@ -46,11 +46,6 @@
|
|
46
46
|
"description": "encode all the letters",
|
47
47
|
"phrase": "The quick brown fox jumps over the lazy dog.",
|
48
48
|
"expected": "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
|
49
|
-
},
|
50
|
-
{
|
51
|
-
"description": "encode ignores non ascii",
|
52
|
-
"phrase": "non ascii éignored",
|
53
|
-
"expected": "mlmzh xrrrt mlivw"
|
54
49
|
}
|
55
50
|
]
|
56
51
|
},
|
@@ -308,13 +308,6 @@
|
|
308
308
|
],
|
309
309
|
"expected": [1, 1]
|
310
310
|
},
|
311
|
-
{
|
312
|
-
"description": "can consist of arbitrary characters such as Unicode characters",
|
313
|
-
"input": [
|
314
|
-
": € 220371 ; €"
|
315
|
-
],
|
316
|
-
"expected": [220371]
|
317
|
-
},
|
318
311
|
{
|
319
312
|
"description": "cannot redefine numbers",
|
320
313
|
"input": [
|
@@ -14,7 +14,7 @@ To keep things simple the only data type you need to support is signed
|
|
14
14
|
integers of at least 16 bits size.
|
15
15
|
|
16
16
|
You should use the following rules for the syntax: a number is a
|
17
|
-
sequence of one or more (
|
17
|
+
sequence of one or more (ASCII) digits, a word is a sequence of one or
|
18
18
|
more letters, digits, symbols or punctuation that is not a number.
|
19
19
|
(Forth probably uses slightly different rules, but this is close
|
20
20
|
enough.)
|
data/lib/trackler/version.rb
CHANGED
@@ -6,6 +6,8 @@ import (
|
|
6
6
|
"testing"
|
7
7
|
)
|
8
8
|
|
9
|
+
const targetTestVersion = 1
|
10
|
+
|
9
11
|
func echo(c string) string {
|
10
12
|
return c
|
11
13
|
}
|
@@ -26,6 +28,12 @@ var tests = []struct {
|
|
26
28
|
{[]string{"HELLO", "WORLD"}, []string{"hello", "world"}, strings.ToUpper, "strings.ToUpper"},
|
27
29
|
}
|
28
30
|
|
31
|
+
func TestTestVersion(t *testing.T) {
|
32
|
+
if testVersion != targetTestVersion {
|
33
|
+
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
29
37
|
func TestAccumulate(t *testing.T) {
|
30
38
|
for _, test := range tests {
|
31
39
|
actual := Accumulate(test.given, test.converter)
|
@@ -12,24 +12,23 @@ main = hspecWith defaultConfig {configFastFail = True} specs
|
|
12
12
|
specs :: Spec
|
13
13
|
specs = describe "etl" $
|
14
14
|
|
15
|
-
--
|
16
|
-
-- for the test cases in `exercism/x-common`.
|
15
|
+
-- Test cases adapted from `exercism/x-common/etl` on 2017-01-31.
|
17
16
|
|
18
17
|
describe "transform" $ do
|
19
18
|
|
20
|
-
it "
|
19
|
+
it "a single letter" $
|
21
20
|
transform (fromList [(1, "A")])
|
22
21
|
`shouldBe` fromList [('a', 1)]
|
23
22
|
|
24
|
-
it "
|
25
|
-
transform (fromList [(1, "
|
26
|
-
`shouldBe` fromList [('a', 1), ('e', 1)]
|
23
|
+
it "single score with multiple letters" $
|
24
|
+
transform (fromList [(1, "AEIOU")])
|
25
|
+
`shouldBe` fromList [('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1)]
|
27
26
|
|
28
|
-
it "
|
29
|
-
transform (fromList [(1, "
|
30
|
-
`shouldBe` fromList [('a', 1), ('
|
27
|
+
it "multiple scores with multiple letters" $
|
28
|
+
transform (fromList [(1, "AE"), (2, "DG")])
|
29
|
+
`shouldBe` fromList [('a', 1), ('e', 1), ('d', 2), ('g', 2)]
|
31
30
|
|
32
|
-
it "
|
31
|
+
it "multiple scores with differing numbers of letters" $
|
33
32
|
transform (fromList fullInput)
|
34
33
|
`shouldBe` fromList fullOutput
|
35
34
|
|
@@ -1,28 +1,11 @@
|
|
1
|
-
module Phone (number
|
2
|
-
import Data.Char (isDigit)
|
1
|
+
module Phone (number) where
|
2
|
+
import Data.Char (isDigit, isLetter)
|
3
3
|
|
4
4
|
number :: String -> Maybe String
|
5
5
|
number input
|
6
|
+
| any isLetter input = Nothing
|
6
7
|
| len == 10 = Just digits
|
7
8
|
| len == 11 && head digits == '1' = Just $ tail digits
|
8
9
|
| otherwise = Nothing
|
9
10
|
where digits = filter isDigit input
|
10
11
|
len = length digits
|
11
|
-
|
12
|
-
parts :: String -> Maybe (String, String, String)
|
13
|
-
parts input = case number input of
|
14
|
-
Nothing -> Nothing
|
15
|
-
Just digits -> Just (ac, exchange, subscriber)
|
16
|
-
where
|
17
|
-
(ac, exchangeSubscriber) = splitAt 3 digits
|
18
|
-
(exchange, subscriber) = splitAt 3 exchangeSubscriber
|
19
|
-
|
20
|
-
areaCode :: String -> Maybe String
|
21
|
-
areaCode input = case parts input of
|
22
|
-
Just (ac, _, _) -> Just ac
|
23
|
-
Nothing -> Nothing
|
24
|
-
|
25
|
-
prettyPrint :: String -> Maybe String
|
26
|
-
prettyPrint input = case parts input of
|
27
|
-
Just (ac, exchange, subscriber) -> Just $ "(" ++ ac ++ ") " ++ exchange ++ "-" ++ subscriber
|
28
|
-
Nothing -> Nothing
|
@@ -1,10 +1,4 @@
|
|
1
|
-
module Phone (
|
2
|
-
|
3
|
-
areaCode :: String -> Maybe String
|
4
|
-
areaCode = error "You need to implement this function."
|
1
|
+
module Phone (number) where
|
5
2
|
|
6
3
|
number :: String -> Maybe String
|
7
4
|
number = error "You need to implement this function."
|
8
|
-
|
9
|
-
prettyPrint :: String -> Maybe String
|
10
|
-
prettyPrint = error "You need to implement this function."
|
@@ -4,115 +4,64 @@ import Data.Foldable (for_)
|
|
4
4
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
5
5
|
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
|
6
6
|
|
7
|
-
import Phone (
|
7
|
+
import Phone (number)
|
8
8
|
|
9
9
|
main :: IO ()
|
10
10
|
main = hspecWith defaultConfig {configFastFail = True} specs
|
11
11
|
|
12
12
|
specs :: Spec
|
13
|
-
specs = describe "phone-number" $
|
14
|
-
describe "number"
|
15
|
-
describe "areaCode" $ for_ areaCodeCases $ test areaCode
|
16
|
-
describe "prettyPrint" $ for_ prettyPrintCases $ test prettyPrint
|
13
|
+
specs = describe "phone-number" $
|
14
|
+
describe "number" $ for_ cases test
|
17
15
|
where
|
18
|
-
test
|
16
|
+
test Case{..} = it description $ number input `shouldBe` expected
|
19
17
|
|
20
|
-
--
|
21
|
-
-- for the test cases in `exercism/x-common`.
|
18
|
+
-- Test cases adapted from `exercism/x-common/phone-number` on 2017-01-31.
|
22
19
|
|
23
20
|
data Case = Case { description :: String
|
24
21
|
, input :: String
|
25
22
|
, expected :: Maybe String
|
26
23
|
}
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
[ Case { description = "cleans number"
|
25
|
+
cases :: [Case]
|
26
|
+
cases =
|
27
|
+
[ Case { description = "cleans the number"
|
31
28
|
, input = "(123) 456-7890"
|
32
29
|
, expected = Just "1234567890"
|
33
30
|
}
|
34
|
-
, Case { description = "cleans another number"
|
35
|
-
, input = "(612) 555-1212"
|
36
|
-
, expected = Just "6125551212"
|
37
|
-
}
|
38
31
|
, Case { description = "cleans number with dots"
|
39
32
|
, input = "123.456.7890"
|
40
33
|
, expected = Just "1234567890"
|
41
34
|
}
|
42
|
-
, Case { description = "cleans
|
43
|
-
, input = "
|
44
|
-
, expected = Just "
|
35
|
+
, Case { description = "cleans numbers with multiple spaces"
|
36
|
+
, input = "123 456 7890 "
|
37
|
+
, expected = Just "1234567890"
|
45
38
|
}
|
46
|
-
, Case { description = "
|
47
|
-
, input = "
|
48
|
-
, expected =
|
39
|
+
, Case { description = "invalid when 9 digits"
|
40
|
+
, input = "123456789"
|
41
|
+
, expected = Nothing
|
49
42
|
}
|
50
43
|
, Case { description = "invalid when 11 digits"
|
51
44
|
, input = "21234567890"
|
52
45
|
, expected = Nothing
|
53
46
|
}
|
54
|
-
, Case { description = "
|
55
|
-
, input = "
|
56
|
-
, expected =
|
47
|
+
, Case { description = "valid when 11 digits and first is 1"
|
48
|
+
, input = "11234567890"
|
49
|
+
, expected = Just "1234567890"
|
57
50
|
}
|
58
51
|
, Case { description = "invalid when 12 digits"
|
59
|
-
, input = "
|
52
|
+
, input = "321234567890"
|
60
53
|
, expected = Nothing
|
61
54
|
}
|
62
|
-
, Case { description = "invalid
|
63
|
-
, input = ""
|
55
|
+
, Case { description = "invalid with letters"
|
56
|
+
, input = "123-abc-7890"
|
64
57
|
, expected = Nothing
|
65
58
|
}
|
66
|
-
, Case { description = "invalid
|
67
|
-
, input = "
|
59
|
+
, Case { description = "invalid with punctuations"
|
60
|
+
, input = "123-@:!-7890"
|
68
61
|
, expected = Nothing
|
69
62
|
}
|
70
|
-
, Case { description = "
|
71
|
-
, input = "
|
72
|
-
, expected = Just "2358132134"
|
73
|
-
}
|
74
|
-
, Case { description = "valid with trailing characters"
|
75
|
-
, input = "987 654 3210 - bob"
|
76
|
-
, expected = Just "9876543210"
|
77
|
-
}
|
78
|
-
, Case { description = "valid amidst text and punctuation"
|
79
|
-
, input = "Here it is: 415-888-0000. Thanks!"
|
80
|
-
, expected = Just "4158880000"
|
81
|
-
}
|
82
|
-
]
|
83
|
-
|
84
|
-
areaCodeCases :: [Case]
|
85
|
-
areaCodeCases =
|
86
|
-
[ Case { description = "area code"
|
87
|
-
, input = "1234567890"
|
88
|
-
, expected = Just "123"
|
89
|
-
}
|
90
|
-
, Case { description = "area code with parentheses"
|
91
|
-
, input = "(612) 555-1212"
|
92
|
-
, expected = Just "612"
|
93
|
-
}
|
94
|
-
, Case { description = "area code with leading characters"
|
95
|
-
, input = "my number is 235 813 2134"
|
96
|
-
, expected = Just "235"
|
97
|
-
}
|
98
|
-
, Case { description = "invalid area code"
|
99
|
-
, input = " (-) "
|
63
|
+
, Case { description = "invalid with right number of digits but letters mixed in"
|
64
|
+
, input = "1a2b3c4d5e6f7g8h9i0j"
|
100
65
|
, expected = Nothing
|
101
66
|
}
|
102
67
|
]
|
103
|
-
|
104
|
-
prettyPrintCases :: [Case]
|
105
|
-
prettyPrintCases =
|
106
|
-
[ Case { description = "pretty print"
|
107
|
-
, input = "1234567890"
|
108
|
-
, expected = Just "(123) 456-7890"
|
109
|
-
}
|
110
|
-
, Case { description = "pretty print with full US phone number"
|
111
|
-
, input = "12345678901"
|
112
|
-
, expected = Just "(234) 567-8901"
|
113
|
-
}
|
114
|
-
, Case { description = "pretty print amidst text and punctuation"
|
115
|
-
, input = "Here it is: 415-888-0000. Thanks!"
|
116
|
-
, expected = Just "(415) 888-0000"
|
117
|
-
}
|
118
|
-
]
|
data/tracks/julia/config.json
CHANGED
@@ -53,10 +53,20 @@
|
|
53
53
|
"difficulty": 1,
|
54
54
|
"topics": [
|
55
55
|
"control-flow (conditionals)",
|
56
|
-
"integers",
|
56
|
+
"integers",
|
57
57
|
"mathematics"
|
58
58
|
]
|
59
59
|
},
|
60
|
+
{
|
61
|
+
"slug": "scrabble-score",
|
62
|
+
"difficulty": 1,
|
63
|
+
"topics": [
|
64
|
+
"control-flow (loops)",
|
65
|
+
"control-flow (conditionals)",
|
66
|
+
"arrays",
|
67
|
+
"strings"
|
68
|
+
]
|
69
|
+
},
|
60
70
|
{
|
61
71
|
"slug": "anagram",
|
62
72
|
"difficulty": 2,
|
@@ -76,6 +86,16 @@
|
|
76
86
|
"unicode",
|
77
87
|
"control-flow (if-else statements)"
|
78
88
|
]
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"slug": "trinary",
|
92
|
+
"difficulty": 2,
|
93
|
+
"topics": [
|
94
|
+
"arrays",
|
95
|
+
"strings",
|
96
|
+
"integers",
|
97
|
+
"mathematics"
|
98
|
+
]
|
79
99
|
}
|
80
100
|
],
|
81
101
|
"deprecated": [
|
@@ -0,0 +1,9 @@
|
|
1
|
+
function score(str::AbstractString)
|
2
|
+
rank = Dict('a'=>1, 'e'=>1, 'i'=>1, 'o'=>1, 'u'=>1, 'l'=>1,
|
3
|
+
'n'=>1, 'r'=>1, 's'=>1, 't'=>1, 'd'=>2, 'g'=>2,
|
4
|
+
'b'=>3, 'c'=>3, 'm'=>3, 'p'=>3, 'f'=>4, 'h'=>4,
|
5
|
+
'v'=>4, 'w'=>4, 'y'=>4, 'k'=>5, 'j'=>8, 'x'=>8,
|
6
|
+
'q'=>10, 'z'=>10)
|
7
|
+
length(str) == 0 && return 0
|
8
|
+
mapreduce(x->get(rank, x, 0), +, lowercase(str))
|
9
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("scrabble-score.jl")
|
4
|
+
|
5
|
+
@testset "lowercase letter" begin
|
6
|
+
@test score("a") == 1
|
7
|
+
end
|
8
|
+
|
9
|
+
@testset "uppercase letter" begin
|
10
|
+
@test score("A") == 1
|
11
|
+
end
|
12
|
+
|
13
|
+
@testset "valuable letter" begin
|
14
|
+
@test score("f") == 4
|
15
|
+
end
|
16
|
+
|
17
|
+
@testset "short word" begin
|
18
|
+
@test score("at") == 2
|
19
|
+
end
|
20
|
+
|
21
|
+
@testset "short, valuable word" begin
|
22
|
+
@test score("zoo") == 12
|
23
|
+
end
|
24
|
+
|
25
|
+
@testset "medium word" begin
|
26
|
+
@test score("street") == 6
|
27
|
+
end
|
28
|
+
|
29
|
+
@testset "medium, valuable word" begin
|
30
|
+
@test score("quirky") == 22
|
31
|
+
end
|
32
|
+
|
33
|
+
@testset "long, mixed-case word" begin
|
34
|
+
@test score("OxyphenButazone") == 41
|
35
|
+
end
|
36
|
+
|
37
|
+
@testset "english-like word" begin
|
38
|
+
@test score("pinata") == 8
|
39
|
+
end
|
40
|
+
|
41
|
+
@testset "non-english letter is not scored" begin
|
42
|
+
@test score("piñata") == 7
|
43
|
+
end
|
44
|
+
|
45
|
+
@testset "empty input" begin
|
46
|
+
@test score("") == 0
|
47
|
+
end
|
48
|
+
|
49
|
+
@testset "entire alphabet available" begin
|
50
|
+
@test score("abcdefghijklmnopqrstuvwxyz") == 87
|
51
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("trinary.jl")
|
4
|
+
|
5
|
+
@testset "trinary 1 is decimal 1" begin
|
6
|
+
@test trinary_to_decimal("1") == 1
|
7
|
+
end
|
8
|
+
|
9
|
+
@testset "trinary 2 is decimal 2" begin
|
10
|
+
@test trinary_to_decimal("2") == 2
|
11
|
+
end
|
12
|
+
|
13
|
+
@testset "trinary 10 is decimal 3" begin
|
14
|
+
@test trinary_to_decimal("10") == 3
|
15
|
+
end
|
16
|
+
|
17
|
+
@testset "trinary 11 is decimal 4" begin
|
18
|
+
@test trinary_to_decimal("11") == 4
|
19
|
+
end
|
20
|
+
|
21
|
+
@testset "trinary 100 is decimal 9" begin
|
22
|
+
@test trinary_to_decimal("100") == 9
|
23
|
+
end
|
24
|
+
|
25
|
+
@testset "trinary 112 is decimal 14" begin
|
26
|
+
@test trinary_to_decimal("112") == 14
|
27
|
+
end
|
28
|
+
|
29
|
+
@testset "trinary 222 is decimal 26" begin
|
30
|
+
@test trinary_to_decimal("222") == 26
|
31
|
+
end
|
32
|
+
|
33
|
+
@testset "trinary 1122000120 is decimal 32091" begin
|
34
|
+
@test trinary_to_decimal("1122000120") == 32091
|
35
|
+
end
|
36
|
+
|
37
|
+
@testset "invalid trinary digits returns 0" begin
|
38
|
+
@test trinary_to_decimal("1234") == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
@testset "invalid word as input returns 0" begin
|
42
|
+
@test trinary_to_decimal("carrot") == 0
|
43
|
+
end
|
44
|
+
|
45
|
+
@testset "invalid numbers with letters as input returns 0" begin
|
46
|
+
@test trinary_to_decimal("0a1b2c") == 0
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.6.
|
4
|
+
version: 2.0.6.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -4157,6 +4157,12 @@ files:
|
|
4157
4157
|
- tracks/julia/exercises/rna-transcription/example.jl
|
4158
4158
|
- tracks/julia/exercises/rna-transcription/rna-transcription.jl
|
4159
4159
|
- tracks/julia/exercises/rna-transcription/runtests.jl
|
4160
|
+
- tracks/julia/exercises/scrabble-score/example.jl
|
4161
|
+
- tracks/julia/exercises/scrabble-score/runtests.jl
|
4162
|
+
- tracks/julia/exercises/scrabble-score/scrabble-score.jl
|
4163
|
+
- tracks/julia/exercises/trinary/example.jl
|
4164
|
+
- tracks/julia/exercises/trinary/runtests.jl
|
4165
|
+
- tracks/julia/exercises/trinary/trinary.jl
|
4160
4166
|
- tracks/julia/exercises/word-count/example.jl
|
4161
4167
|
- tracks/julia/exercises/word-count/runtests.jl
|
4162
4168
|
- tracks/julia/exercises/word-count/word-count.jl
|