trackler 2.2.1.92 → 2.2.1.93
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/acronym/canonical-data.json +3 -11
- data/problem-specifications/exercises/hamming/canonical-data.json +61 -31
- data/problem-specifications/exercises/react/canonical-data.json +472 -436
- data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +1 -1
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +1 -1
- data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +1 -1
- data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +1 -1
- data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNATest.ceylon +1 -1
- data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +1 -1
- data/tracks/common-lisp/config.json +9 -9
- data/tracks/crystal/exercises/acronym/spec/acronym_spec.cr +0 -4
- data/tracks/crystal/exercises/binary/spec/binary_spec.cr +6 -6
- data/tracks/crystal/exercises/forth/spec/forth_spec.cr +48 -32
- data/tracks/crystal/exercises/hello-world/spec/hello_world_spec.cr +1 -9
- data/tracks/crystal/exercises/pascals-triangle/spec/pascals_triangle_spec.cr +13 -1
- data/tracks/crystal/generator/spec/exercise_generator_spec.cr +1 -1
- data/tracks/crystal/generator/src/generators/acronym.cr +1 -1
- data/tracks/crystal/generator/src/generators/binary.cr +2 -2
- data/tracks/crystal/generator/src/generators/flatten_array.cr +1 -1
- data/tracks/crystal/generator/src/generators/forth.cr +3 -3
- data/tracks/crystal/generator/src/generators/pascals-triangle.cr +11 -4
- data/tracks/delphi/exercises/phone-number/uPhoneNumberTests.pas +35 -10
- data/tracks/factor/exercises/isogram/README.md +2 -2
- data/tracks/fortran/.travis.yml +0 -1
- data/tracks/go/exercises/book-store/.meta/gen.go +3 -3
- data/tracks/go/exercises/book-store/.meta/hints.md +14 -0
- data/tracks/go/exercises/book-store/README.md +17 -1
- data/tracks/go/exercises/book-store/cases_test.go +17 -17
- data/tracks/go/exercises/book-store/example.go +13 -11
- data/tracks/go/exercises/bowling/.meta/gen.go +10 -8
- data/tracks/go/exercises/bowling/cases_test.go +2 -2
- data/tracks/go/exercises/bracket-push/.meta/gen.go +5 -3
- data/tracks/go/exercises/bracket-push/cases_test.go +2 -2
- data/tracks/go/exercises/dominoes/.meta/gen.go +7 -3
- data/tracks/go/exercises/dominoes/cases_test.go +12 -2
- data/tracks/go/exercises/nucleotide-count/.meta/gen.go +87 -0
- data/tracks/go/exercises/nucleotide-count/.meta/hints.md +20 -0
- data/tracks/go/exercises/nucleotide-count/cases_test.go +39 -0
- data/tracks/go/exercises/nucleotide-count/example.go +6 -16
- data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +16 -93
- data/tracks/go/exercises/sum-of-multiples/.meta/gen.go +6 -4
- data/tracks/go/exercises/sum-of-multiples/cases_test.go +2 -2
- data/tracks/haskell/README.md +6 -5
- data/tracks/haskell/config.json +73 -73
- data/tracks/haskell/exercises/allergies/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/alphametics/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/anagram/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/beer-song/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/binary-search-tree/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/bowling/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/custom-set/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/food-chain/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/forth/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/go-counting/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/grade-school/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/hello-world/package.yaml +1 -1
- data/tracks/haskell/exercises/house/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/isbn-verifier/README.md +1 -1
- data/tracks/haskell/exercises/largest-series-product/package.yaml +1 -1
- data/tracks/haskell/exercises/leap/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/leap/package.yaml +1 -1
- data/tracks/haskell/exercises/linked-list/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/matrix/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/meetup/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/minesweeper/package.yaml +1 -1
- data/tracks/haskell/exercises/nth-prime/package.yaml +1 -1
- data/tracks/haskell/exercises/nucleotide-count/package.yaml +1 -1
- data/tracks/haskell/exercises/octal/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/palindrome-products/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/parallel-letter-frequency/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/pascals-triangle/package.yaml +1 -1
- data/tracks/haskell/exercises/perfect-numbers/package.yaml +1 -1
- data/tracks/haskell/exercises/phone-number/package.yaml +1 -1
- data/tracks/haskell/exercises/phone-number/test/Tests.hs +10 -2
- data/tracks/haskell/exercises/pig-latin/package.yaml +1 -1
- data/tracks/haskell/exercises/queen-attack/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/rna-transcription/package.yaml +1 -1
- data/tracks/haskell/exercises/robot-name/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/robot-simulator/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/roman-numerals/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/roman-numerals/package.yaml +1 -1
- data/tracks/haskell/exercises/rotational-cipher/package.yaml +1 -1
- data/tracks/haskell/exercises/saddle-points/package.yaml +1 -1
- data/tracks/haskell/exercises/scrabble-score/package.yaml +1 -1
- data/tracks/haskell/exercises/secret-handshake/package.yaml +1 -1
- data/tracks/haskell/exercises/series/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/sgf-parsing/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/sieve/package.yaml +1 -1
- data/tracks/haskell/exercises/simple-linked-list/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/space-age/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/space-age/package.yaml +1 -1
- data/tracks/haskell/exercises/spiral-matrix/package.yaml +1 -1
- data/tracks/haskell/exercises/sublist/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/sublist/package.yaml +1 -1
- data/tracks/haskell/exercises/trinary/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/twelve-days/package.yaml +1 -1
- data/tracks/haskell/exercises/word-count/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/wordy/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/haskell/exercises/zebra-puzzle/package.yaml +1 -1
- data/tracks/java/exercises/phone-number/.meta/src/reference/java/PhoneNumber.java +10 -2
- data/tracks/java/exercises/phone-number/.meta/version +1 -0
- data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +56 -19
- data/tracks/purescript/config/exercise_readme.go.tmpl +0 -3
- data/tracks/swift/.travis.yml +0 -18
- data/tracks/swift/circle.yml +17 -6
- metadata +41 -37
- data/tracks/purescript/docs/EXERCISE_README_INSERT.md +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
package brackets
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: 5c16d05 bracket-push: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 1.2.0
|
6
6
|
|
7
7
|
type bracketTest struct {
|
8
8
|
input string
|
@@ -37,8 +37,11 @@ func (d Dominoe) String() string {
|
|
37
37
|
|
38
38
|
type OneCase struct {
|
39
39
|
Description string
|
40
|
-
|
41
|
-
|
40
|
+
Comments []string
|
41
|
+
Input struct {
|
42
|
+
Dominoes []Dominoe
|
43
|
+
}
|
44
|
+
Expected bool
|
42
45
|
}
|
43
46
|
|
44
47
|
//func (c OneCase)
|
@@ -54,7 +57,8 @@ var testCases = []struct {
|
|
54
57
|
}{ {{range .J.Cases}}
|
55
58
|
{
|
56
59
|
{{printf "%q" .Description}},
|
57
|
-
|
60
|
+
{{range .Comments}}//{{.}}
|
61
|
+
{{end}}[]Dominoe{ {{range .Input.Dominoes}} {{printf "%v" .}}, {{end}} },
|
58
62
|
{{printf "%v" .Expected}},
|
59
63
|
}, {{end}}
|
60
64
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package dominoes
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 2.
|
4
|
+
// Commit: b5bc74d dominoes: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 2.1.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|
@@ -41,6 +41,11 @@ var testCases = []struct {
|
|
41
41
|
},
|
42
42
|
{
|
43
43
|
"disconnected - simple",
|
44
|
+
//This meets the requirement of being possibly-Euclidean.
|
45
|
+
//All vertices have even degree.
|
46
|
+
//Nevertheless, there is no chain here, as there's no way to get from 1 to 2.
|
47
|
+
//This test (and the two following) prevent solutions from using the even-degree test as the sole criterion,
|
48
|
+
//as that is not a sufficient condition.
|
44
49
|
[]Dominoe{Dominoe{1, 1}, Dominoe{2, 2}},
|
45
50
|
false,
|
46
51
|
},
|
@@ -56,6 +61,11 @@ var testCases = []struct {
|
|
56
61
|
},
|
57
62
|
{
|
58
63
|
"need backtrack",
|
64
|
+
//Some solutions may make a chain out of (1, 2), (2, 3), (3, 1)
|
65
|
+
//then decide that since there are no more dominoes containing a 1,
|
66
|
+
//there is no chain possible.
|
67
|
+
//There is indeed a chain here, so this test checks for this line of reasoning.
|
68
|
+
//You need to place the (2, 4) after the (1, 2) rather than the (2, 3).
|
59
69
|
[]Dominoe{Dominoe{1, 2}, Dominoe{2, 3}, Dominoe{3, 1}, Dominoe{2, 4}, Dominoe{2, 4}},
|
60
70
|
true,
|
61
71
|
},
|
@@ -0,0 +1,87 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"log"
|
5
|
+
"sort"
|
6
|
+
"strconv"
|
7
|
+
"strings"
|
8
|
+
"text/template"
|
9
|
+
|
10
|
+
"../../../gen"
|
11
|
+
)
|
12
|
+
|
13
|
+
func main() {
|
14
|
+
t, err := template.New("").Parse(tmpl)
|
15
|
+
if err != nil {
|
16
|
+
log.Fatal(err)
|
17
|
+
}
|
18
|
+
var j js
|
19
|
+
if err := gen.Gen("nucleotide-count", &j, t); err != nil {
|
20
|
+
log.Fatal(err)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
// The JSON structure we expect to be able to unmarshal into
|
25
|
+
type js struct {
|
26
|
+
exercise string
|
27
|
+
version string
|
28
|
+
Cases []struct {
|
29
|
+
Description string
|
30
|
+
Cases []OneCase
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
// OneCase represents each test case
|
35
|
+
type OneCase struct {
|
36
|
+
Description string
|
37
|
+
Property string
|
38
|
+
Input struct {
|
39
|
+
Strand string
|
40
|
+
}
|
41
|
+
Expected map[string]interface{}
|
42
|
+
}
|
43
|
+
|
44
|
+
// ErrorExpected returns true if an error should be raised
|
45
|
+
func (c OneCase) ErrorExpected() bool {
|
46
|
+
_, exists := c.Expected["error"]
|
47
|
+
return exists
|
48
|
+
}
|
49
|
+
|
50
|
+
// SortedMapString collects key:values for a map in sorted order
|
51
|
+
func (c OneCase) SortedMapString() string {
|
52
|
+
strs := make([]string, 0, len(c.Expected))
|
53
|
+
for k, v := range c.Expected {
|
54
|
+
switch t := v.(type) {
|
55
|
+
case float64:
|
56
|
+
strs = append(strs, `'`+k+`': `+strconv.FormatFloat(t, 'f', -1, 64))
|
57
|
+
default:
|
58
|
+
log.Fatalf("unexpected type %T for %v", t, v)
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
sort.Strings(strs)
|
63
|
+
return strings.Join(strs, ",")
|
64
|
+
}
|
65
|
+
|
66
|
+
// template applied to above data structure generates the Go test cases
|
67
|
+
var tmpl = `package dna
|
68
|
+
|
69
|
+
{{.Header}}
|
70
|
+
|
71
|
+
{{range .J.Cases}}// {{.Description}}
|
72
|
+
var testCases = []struct {
|
73
|
+
description string
|
74
|
+
strand string
|
75
|
+
expected Histogram
|
76
|
+
errorExpected bool
|
77
|
+
}{
|
78
|
+
{{range .Cases}}{
|
79
|
+
description: {{printf "%q" .Description}},
|
80
|
+
strand: {{printf "%#v" .Input.Strand}},
|
81
|
+
{{if .ErrorExpected}}errorExpected: true,
|
82
|
+
{{else}}expected: Histogram{ {{.SortedMapString}} },
|
83
|
+
{{- end}}
|
84
|
+
},
|
85
|
+
{{end}}{{end}}
|
86
|
+
}
|
87
|
+
`
|
@@ -0,0 +1,20 @@
|
|
1
|
+
## Implementation
|
2
|
+
|
3
|
+
You should define a custom type 'DNA' with a function 'Counts' that outputs two values:
|
4
|
+
|
5
|
+
- a frequency count for the given DNA strand
|
6
|
+
- an error (if there are invalid nucleotides)
|
7
|
+
|
8
|
+
Which is a good type for a DNA strand ?
|
9
|
+
|
10
|
+
Which is the best Go types to represent the output values ?
|
11
|
+
|
12
|
+
Take a look at the test cases to get a hint about what could be the possible inputs.
|
13
|
+
|
14
|
+
|
15
|
+
## note about the tests
|
16
|
+
You may be wondering about the `cases_test.go` file. We explain it in the
|
17
|
+
[leap exercise][leap-exercise-readme].
|
18
|
+
|
19
|
+
[leap-exercise-readme]: https://github.com/exercism/go/blob/master/exercises/leap/README.md
|
20
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
package dna
|
2
|
+
|
3
|
+
// Source: exercism/problem-specifications
|
4
|
+
// Commit: 879a096 nucleotide-count: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 1.3.0
|
6
|
+
|
7
|
+
// count all nucleotides in a strand
|
8
|
+
var testCases = []struct {
|
9
|
+
description string
|
10
|
+
strand string
|
11
|
+
expected Histogram
|
12
|
+
errorExpected bool
|
13
|
+
}{
|
14
|
+
{
|
15
|
+
description: "empty strand",
|
16
|
+
strand: "",
|
17
|
+
expected: Histogram{'A': 0, 'C': 0, 'G': 0, 'T': 0},
|
18
|
+
},
|
19
|
+
{
|
20
|
+
description: "can count one nucleotide in single-character input",
|
21
|
+
strand: "G",
|
22
|
+
expected: Histogram{'A': 0, 'C': 0, 'G': 1, 'T': 0},
|
23
|
+
},
|
24
|
+
{
|
25
|
+
description: "strand with repeated nucleotide",
|
26
|
+
strand: "GGGGGGG",
|
27
|
+
expected: Histogram{'A': 0, 'C': 0, 'G': 7, 'T': 0},
|
28
|
+
},
|
29
|
+
{
|
30
|
+
description: "strand with multiple nucleotides",
|
31
|
+
strand: "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC",
|
32
|
+
expected: Histogram{'A': 20, 'C': 12, 'G': 17, 'T': 21},
|
33
|
+
},
|
34
|
+
{
|
35
|
+
description: "strand with invalid nucleotides",
|
36
|
+
strand: "AGXXACT",
|
37
|
+
errorExpected: true,
|
38
|
+
},
|
39
|
+
}
|
@@ -5,35 +5,25 @@ import (
|
|
5
5
|
"strings"
|
6
6
|
)
|
7
7
|
|
8
|
-
// Histogram is a mapping from nucleotide to its count in given DNA
|
9
|
-
type Histogram map[byte]int
|
10
|
-
|
11
8
|
// DNA is a list of nucleotides
|
12
9
|
type DNA string
|
10
|
+
type Histogram map[byte]int
|
13
11
|
|
14
12
|
const validNucleotides = "ACGT"
|
15
13
|
|
16
|
-
// Count counts number of occurrences of given nucleotide in given DNA
|
17
|
-
func (dna DNA) Count(nucleotide byte) (count int, err error) {
|
18
|
-
if !strings.Contains(validNucleotides, string(nucleotide)) {
|
19
|
-
return 0, errors.New("dna: invalid nucleotide " + string(nucleotide))
|
20
|
-
}
|
21
|
-
|
22
|
-
return strings.Count(string(dna), string(nucleotide)), nil
|
23
|
-
}
|
24
|
-
|
25
14
|
// Counts generates a histogram of valid nucleotides in given DNA.
|
26
15
|
// Returns error if DNA contains invalid nucleotide.
|
27
16
|
func (dna DNA) Counts() (Histogram, error) {
|
28
17
|
var total int
|
29
|
-
|
18
|
+
result := make(Histogram)
|
19
|
+
|
30
20
|
for i := range validNucleotides {
|
31
21
|
nucleotide := validNucleotides[i]
|
32
|
-
|
33
|
-
total +=
|
22
|
+
result[nucleotide] = strings.Count(string(dna), string(nucleotide))
|
23
|
+
total += result[nucleotide]
|
34
24
|
}
|
35
25
|
if total != len(dna) {
|
36
26
|
return nil, errors.New("dna: contains invalid nucleotide")
|
37
27
|
}
|
38
|
-
return
|
28
|
+
return result, nil
|
39
29
|
}
|
@@ -5,99 +5,22 @@ import (
|
|
5
5
|
"testing"
|
6
6
|
)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
} else if count != tt.expected {
|
24
|
-
t.Fatalf("Got \"%v\", expected \"%v\"", count, tt.expected)
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
func TestHasErrorForInvalidNucleotides(t *testing.T) {
|
30
|
-
dna := DNA("GATTACA")
|
31
|
-
if _, err := dna.Count('X'); err == nil {
|
32
|
-
t.Fatalf("X is an invalid nucleotide, but no error was raised")
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
// In most cases, this test is pointless.
|
37
|
-
// Very occasionally it matters.
|
38
|
-
// Just roll with it.
|
39
|
-
func TestCountingDoesntChangeCount(t *testing.T) {
|
40
|
-
dna := DNA("CGATTGGG")
|
41
|
-
dna.Count('T')
|
42
|
-
count1, err := dna.Count('T')
|
43
|
-
if err != nil {
|
44
|
-
t.Fatal(err)
|
45
|
-
}
|
46
|
-
count2, err := dna.Count('T')
|
47
|
-
if err != nil {
|
48
|
-
t.Fatal(err)
|
49
|
-
}
|
50
|
-
if count1 != count2 || count2 != 2 {
|
51
|
-
t.Fatalf("Got %v, expected %v", []int{count1, count2}, []int{2, 2})
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
type histogramTest struct {
|
56
|
-
strand DNA
|
57
|
-
expected Histogram
|
58
|
-
err bool
|
59
|
-
}
|
60
|
-
|
61
|
-
var histogramTests = []histogramTest{
|
62
|
-
{
|
63
|
-
"",
|
64
|
-
Histogram{'A': 0, 'C': 0, 'T': 0, 'G': 0},
|
65
|
-
false,
|
66
|
-
},
|
67
|
-
{
|
68
|
-
"GGGGGGGG",
|
69
|
-
Histogram{'A': 0, 'C': 0, 'T': 0, 'G': 8},
|
70
|
-
false,
|
71
|
-
},
|
72
|
-
{
|
73
|
-
"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC",
|
74
|
-
Histogram{'A': 20, 'C': 12, 'T': 21, 'G': 17},
|
75
|
-
false,
|
76
|
-
},
|
77
|
-
{
|
78
|
-
"GGXXX",
|
79
|
-
nil,
|
80
|
-
true,
|
81
|
-
},
|
82
|
-
}
|
83
|
-
|
84
|
-
func TestSequenceHistograms(t *testing.T) {
|
85
|
-
for _, tt := range histogramTests {
|
86
|
-
counts, err := tt.strand.Counts()
|
87
|
-
if tt.err && err == nil {
|
88
|
-
t.Fatalf("DNA{ %q }: expected error but didn't get one.", tt.strand)
|
89
|
-
} else if !tt.err && err != nil {
|
90
|
-
t.Fatalf("DNA{ %q }: expected no error but got error %s", tt.strand, err.Error())
|
91
|
-
} else if !tt.err && !reflect.DeepEqual(counts, tt.expected) {
|
92
|
-
t.Fatalf("DNA{ %q }: Got %v, expected %v", tt.strand, counts, tt.expected)
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
func BenchmarkSequenceHistograms(b *testing.B) {
|
98
|
-
for _, tt := range histogramTests {
|
99
|
-
for i := 0; i < b.N; i++ {
|
100
|
-
tt.strand.Counts()
|
8
|
+
func TestCounts(t *testing.T) {
|
9
|
+
for _, tc := range testCases {
|
10
|
+
dna := DNA(tc.strand)
|
11
|
+
s, err := dna.Counts()
|
12
|
+
if tc.errorExpected {
|
13
|
+
if err == nil {
|
14
|
+
t.Fatalf("FAIL: %s\nCounts(%q)\nExpected error\nActual: %#v",
|
15
|
+
tc.description, tc.strand, s)
|
16
|
+
}
|
17
|
+
} else if err != nil {
|
18
|
+
t.Fatalf("FAIL: %s\nCounts(%q)\nExpected: %#v\nGot error: %q",
|
19
|
+
tc.description, tc.strand, tc.expected, err)
|
20
|
+
} else if !reflect.DeepEqual(s, tc.expected) {
|
21
|
+
t.Fatalf("FAIL: %s\nCounts(%q)\nExpected: %#v\nActual: %#v",
|
22
|
+
tc.description, tc.strand, tc.expected, s)
|
101
23
|
}
|
24
|
+
t.Logf("PASS: %s", tc.description)
|
102
25
|
}
|
103
26
|
}
|
@@ -22,9 +22,11 @@ func main() {
|
|
22
22
|
type js struct {
|
23
23
|
Cases []struct {
|
24
24
|
Description string
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
Input struct {
|
26
|
+
Factors []int
|
27
|
+
Limit int
|
28
|
+
}
|
29
|
+
Expected int
|
28
30
|
}
|
29
31
|
}
|
30
32
|
|
@@ -38,6 +40,6 @@ var varTests = []struct {
|
|
38
40
|
limit int
|
39
41
|
sum int
|
40
42
|
}{
|
41
|
-
{{range .J.Cases}}{ {{.Factors | printf "%#v"}}, {{.Limit}}, {{.Expected}}}, // {{.Description}}
|
43
|
+
{{range .J.Cases}}{ {{.Input.Factors | printf "%#v"}}, {{.Input.Limit}}, {{.Expected}}}, // {{.Description}}
|
42
44
|
{{end}}}
|
43
45
|
`
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package summultiples
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: fb5b0a1 sum-of-multiples: Apply new "input" policy
|
5
|
+
// Problem Specifications Version: 1.2.0
|
6
6
|
|
7
7
|
var varTests = []struct {
|
8
8
|
divisors []int
|
data/tracks/haskell/README.md
CHANGED
@@ -71,14 +71,13 @@ The [track anatomy documentation](https://github.com/exercism/docs/blob/master/l
|
|
71
71
|
├── config.json
|
72
72
|
├── docs
|
73
73
|
│ ├── ABOUT.md
|
74
|
+
├── EXERCISE_README_INSERT.md
|
74
75
|
│ ├── INSTALLATION.md
|
75
76
|
│ ├── LEARNING.md
|
76
77
|
│ ├── RESOURCES.md
|
77
78
|
│ └── TESTS.md
|
78
79
|
└── exercises
|
79
|
-
├── TRACK_HINTS.md
|
80
80
|
└── accumulate
|
81
|
-
│ ├── HINTS.md
|
82
81
|
│ ├── package.yaml
|
83
82
|
│ ├── stack.yaml
|
84
83
|
│ ├── examples
|
@@ -88,8 +87,10 @@ The [track anatomy documentation](https://github.com/exercism/docs/blob/master/l
|
|
88
87
|
│ │ └── Accumuĺate.hs
|
89
88
|
│ ├── src
|
90
89
|
│ │ └── Accumuĺate.hs
|
91
|
-
│
|
92
|
-
│
|
90
|
+
│ ├── test
|
91
|
+
│ │ └── Tests.hs
|
92
|
+
│ └── .meta
|
93
|
+
│ └── hints.md
|
93
94
|
└── allergies
|
94
95
|
│ ├── ...
|
95
96
|
└── ...
|
@@ -103,11 +104,11 @@ Each exercise has the following structure:
|
|
103
104
|
resolver for all the exercises.
|
104
105
|
- `package.yaml` is a file in the [hpack](https://github.com/sol/hpack#readme)
|
105
106
|
format that has all dependencies and build instructions for an exercise.
|
106
|
-
- `HINTS.md` is an optional file containing instructions and/or hints. It is used together with the respective `description.md` for the exercise from [problem-specifications](https://github.com/exercism/problem-specifications) to build the `README.md` file.
|
107
107
|
- `src/ModuleName.hs` is a [stub solution](#stub-solution).
|
108
108
|
- `examples/success-<name>/package.yaml` contains library dependencies for the [example solution](#example-solution). `<name>` is a unique name for the example - usually "standard" (as in `success-standard`), but it can be some other name in case of multiple example solutions.
|
109
109
|
- `examples/success-<name>/src/ModuleName.hs` is the source code of the sample solution.
|
110
110
|
- `test/Tests.hs` is the [test suite](#test-suite).
|
111
|
+
- `.meta/hints.md` is an optional file containing instructions and/or hints. It is used together with the respective `description.md` for the exercise from [problem-specifications](https://github.com/exercism/problem-specifications) to build the `README.md` file.
|
111
112
|
|
112
113
|
### Writing an issue
|
113
114
|
To report a bug you should [create an issue](https://help.github.com/articles/creating-an-issue/) on the [exercism/haskell repo](https://github.com/exercism/haskell/issues).
|