trackler 2.2.1.77 → 2.2.1.78
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/transpose/canonical-data.json +94 -116
- data/tracks/bash/config/maintainers.json +11 -1
- data/tracks/clojure/config.json +10 -2
- data/tracks/clojure/exercises/reverse-string/README.md +14 -0
- data/tracks/clojure/exercises/reverse-string/project.clj +4 -0
- data/tracks/clojure/exercises/reverse-string/src/example.clj +5 -0
- data/tracks/clojure/exercises/reverse-string/src/reverse_string.clj +5 -0
- data/tracks/clojure/exercises/reverse-string/test/reverse_string_test.clj +18 -0
- data/tracks/clojure/exercises/say/README.md +70 -0
- data/tracks/clojure/exercises/{two-fer → say}/project.clj +3 -3
- data/tracks/clojure/exercises/say/src/example.clj +9 -0
- data/tracks/clojure/exercises/say/src/say.clj +5 -0
- data/tracks/clojure/exercises/say/test/say_test.clj +48 -0
- data/tracks/coffeescript/docs/ABOUT.md +4 -9
- data/tracks/coffeescript/docs/INSTALLATION.md +2 -2
- data/tracks/erlang/exercises/pangram/rebar.config +1 -1
- data/tracks/erlang/exercises/pangram/src/example.erl +2 -3
- data/tracks/erlang/exercises/pangram/test/pangram_tests.erl +12 -13
- data/tracks/fsharp/exercises/grep/Example.fs +16 -20
- data/tracks/fsharp/exercises/grep/GrepTest.fs +154 -233
- data/tracks/fsharp/generators/Common.fs +7 -2
- data/tracks/fsharp/generators/Exercise.fs +51 -16
- data/tracks/fsharp/generators/Formatting.fs +13 -6
- data/tracks/fsharp/generators/Generators.fs +44 -14
- data/tracks/fsharp/generators/Rendering.fs +8 -1
- data/tracks/fsharp/generators/Templates/Generators/_GrepSetup.liquid +37 -0
- data/tracks/fsharp/generators/Templates/_TestClass.liquid +9 -3
- data/tracks/fsharp/generators/Templates/{_TestMethod.liquid → _TestFunction.liquid} +0 -0
- data/tracks/fsharp/generators/Templates/{_TestMethodBody.liquid → _TestFunctionBody.liquid} +0 -0
- data/tracks/fsharp/generators/Templates/_TestMember.liquid +3 -0
- data/tracks/fsharp/generators/Templates/_TestMemberBody.liquid +4 -0
- data/tracks/fsharp/generators/Templates/_TestModule.liquid +17 -0
- data/tracks/go/config.json +24 -0
- data/tracks/go/exercises/acronym/.meta/gen.go +5 -3
- data/tracks/go/exercises/acronym/acronym.go +0 -2
- data/tracks/go/exercises/acronym/cases_test.go +2 -2
- data/tracks/go/exercises/acronym/example.go +2 -3
- data/tracks/go/exercises/all-your-base/.meta/gen.go +9 -7
- data/tracks/go/exercises/all-your-base/cases_test.go +2 -2
- data/tracks/go/exercises/allergies/.meta/gen.go +10 -6
- data/tracks/go/exercises/allergies/cases_test.go +2 -2
- data/tracks/go/exercises/anagram/.meta/gen.go +7 -5
- data/tracks/go/exercises/anagram/cases_test.go +2 -2
- data/tracks/go/exercises/armstrong-numbers/.meta/gen.go +54 -0
- data/tracks/go/exercises/armstrong-numbers/armstrong_test.go +12 -0
- data/tracks/go/exercises/armstrong-numbers/cases_test.go +52 -0
- data/tracks/go/exercises/armstrong-numbers/example.go +24 -0
- data/tracks/go/exercises/binary-search/.meta/gen.go +7 -5
- data/tracks/go/exercises/binary-search/cases_test.go +2 -2
- data/tracks/go/exercises/book-store/.meta/gen.go +5 -3
- data/tracks/go/exercises/book-store/cases_test.go +2 -2
- data/tracks/go/exercises/connect/example.go +4 -5
- data/tracks/go/exercises/dominoes/.meta/gen.go +61 -0
- data/tracks/go/exercises/dominoes/.meta/hints.md +29 -0
- data/tracks/go/exercises/dominoes/README.md +67 -0
- data/tracks/go/exercises/dominoes/cases_test.go +72 -0
- data/tracks/go/exercises/dominoes/dominoes_test.go +106 -0
- data/tracks/go/exercises/dominoes/example.go +146 -0
- data/tracks/go/exercises/ledger/example.go +1 -1
- data/tracks/groovy/.gitignore +3 -0
- data/tracks/groovy/.travis.yml +10 -1
- data/tracks/groovy/bin/prepeare_exercise_builds.groovy +77 -0
- data/tracks/groovy/build.gradle +25 -0
- data/tracks/groovy/exercises/difference-of-squares/Example.groovy +3 -3
- data/tracks/groovy/exercises/gigasecond/GigasecondSpec.groovy +3 -3
- data/tracks/groovy/exercises/linked-list/{DoubleLinkedList.groovy → LinkedList.groovy} +0 -0
- data/tracks/groovy/exercises/linked-list/{DoubleLinkedListSpec.groovy → LinkedListSpec.groovy} +0 -0
- data/tracks/groovy/exercises/linked-list/README.md +1 -1
- data/tracks/groovy/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/tracks/groovy/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/tracks/groovy/gradlew +172 -0
- data/tracks/groovy/gradlew.bat +84 -0
- data/tracks/groovy/settings.gradle +9 -0
- data/tracks/ocaml/exercises/acronym/.merlin +1 -1
- data/tracks/ocaml/exercises/all-your-base/.merlin +1 -1
- data/tracks/ocaml/exercises/anagram/.merlin +1 -1
- data/tracks/ocaml/exercises/atbash-cipher/.merlin +1 -1
- data/tracks/ocaml/exercises/beer-song/.merlin +1 -1
- data/tracks/ocaml/exercises/binary-search/.merlin +1 -1
- data/tracks/ocaml/exercises/bob/.merlin +1 -1
- data/tracks/ocaml/exercises/bowling/.merlin +1 -1
- data/tracks/ocaml/exercises/change/.merlin +1 -1
- data/tracks/ocaml/exercises/difference-of-squares/.merlin +1 -1
- data/tracks/ocaml/exercises/etl/.merlin +1 -1
- data/tracks/ocaml/exercises/forth/.merlin +1 -1
- data/tracks/ocaml/exercises/grade-school/.merlin +1 -1
- data/tracks/ocaml/exercises/hamming/.merlin +1 -1
- data/tracks/ocaml/exercises/hangman/.merlin +1 -1
- data/tracks/ocaml/exercises/hello-world/.merlin +1 -1
- data/tracks/ocaml/exercises/hexadecimal/.merlin +1 -1
- data/tracks/ocaml/exercises/leap/.merlin +1 -1
- data/tracks/ocaml/exercises/list-ops/.merlin +1 -1
- data/tracks/ocaml/exercises/luhn/.merlin +1 -1
- data/tracks/ocaml/exercises/meetup/.merlin +1 -1
- data/tracks/ocaml/exercises/minesweeper/.merlin +1 -1
- data/tracks/ocaml/exercises/nucleotide-count/.merlin +1 -1
- data/tracks/ocaml/exercises/phone-number/.merlin +1 -1
- data/tracks/ocaml/exercises/prime-factors/.merlin +1 -1
- data/tracks/ocaml/exercises/raindrops/.merlin +1 -1
- data/tracks/ocaml/exercises/react/.merlin +1 -1
- data/tracks/ocaml/exercises/rectangles/.merlin +1 -1
- data/tracks/ocaml/exercises/rna-transcription/.merlin +1 -1
- data/tracks/ocaml/exercises/run-length-encoding/.merlin +1 -1
- data/tracks/ocaml/exercises/say/.merlin +1 -1
- data/tracks/ocaml/exercises/space-age/.merlin +1 -1
- data/tracks/ocaml/exercises/triangle/.merlin +1 -1
- data/tracks/ocaml/exercises/word-count/.merlin +1 -1
- data/tracks/ocaml/exercises/zipper/.merlin +1 -1
- data/tracks/typescript/config/maintainers.json +2 -2
- metadata +37 -12
- data/tracks/clojure/exercises/two-fer/README.md +0 -19
- data/tracks/clojure/exercises/two-fer/src/example.clj +0 -5
- data/tracks/clojure/exercises/two-fer/src/two_fer.clj +0 -5
- data/tracks/clojure/exercises/two-fer/test/two_fer_test.clj +0 -12
- data/tracks/erlang/exercises/pangram/include/exercism.hrl +0 -11
@@ -0,0 +1,17 @@
|
|
1
|
+
// This file was auto-generated based on version {{ Version }} of the canonical data.
|
2
|
+
|
3
|
+
module {{ TestModuleName }}
|
4
|
+
|
5
|
+
{%- for namespace in Namespaces -%}
|
6
|
+
open {{ namespace }}
|
7
|
+
{%- endfor -%}
|
8
|
+
|
9
|
+
open {{ TestedModuleName }}
|
10
|
+
{%- if Setup != empty -%}
|
11
|
+
|
12
|
+
{{ Setup }}
|
13
|
+
{%- endif -%}
|
14
|
+
|
15
|
+
{%- for method in Methods -%}
|
16
|
+
{{ method }}
|
17
|
+
{%- endfor -%}
|
data/tracks/go/config.json
CHANGED
@@ -734,6 +734,18 @@
|
|
734
734
|
"unlocked_by": "clock",
|
735
735
|
"uuid": "dbf4d64e-c02d-4bdf-8be1-43f9acb5f2ad"
|
736
736
|
},
|
737
|
+
{
|
738
|
+
"core": false,
|
739
|
+
"difficulty": 3,
|
740
|
+
"slug": "armstrong-numbers",
|
741
|
+
"topics": [
|
742
|
+
"algorithms",
|
743
|
+
"integers",
|
744
|
+
"mathematics"
|
745
|
+
],
|
746
|
+
"unlocked_by": "prime-factors",
|
747
|
+
"uuid": "b3f06c57-c0de-4b8f-bd16-782b2ce3f478"
|
748
|
+
},
|
737
749
|
{
|
738
750
|
"core": false,
|
739
751
|
"difficulty": 5,
|
@@ -1159,6 +1171,18 @@
|
|
1159
1171
|
"unlocked_by": "bank-account",
|
1160
1172
|
"uuid": "e31199ac-e657-4997-b931-63893a575c08"
|
1161
1173
|
},
|
1174
|
+
{
|
1175
|
+
"core": false,
|
1176
|
+
"difficulty": 4,
|
1177
|
+
"slug": "dominoes",
|
1178
|
+
"topics": [
|
1179
|
+
"algorithms",
|
1180
|
+
"arrays",
|
1181
|
+
"searching"
|
1182
|
+
],
|
1183
|
+
"unlocked_by": "flatten-array",
|
1184
|
+
"uuid": "2e5c9e76-decd-49db-be4b-353ebeb46b73"
|
1185
|
+
},
|
1162
1186
|
{
|
1163
1187
|
"deprecated": true,
|
1164
1188
|
"slug": "binary",
|
@@ -25,8 +25,10 @@ type js struct {
|
|
25
25
|
Cases []struct {
|
26
26
|
Description string
|
27
27
|
Property string
|
28
|
-
|
29
|
-
|
28
|
+
Input struct {
|
29
|
+
Phrase string
|
30
|
+
}
|
31
|
+
Expected string
|
30
32
|
}
|
31
33
|
}
|
32
34
|
}
|
@@ -43,7 +45,7 @@ type acronymTest struct {
|
|
43
45
|
|
44
46
|
var stringTestCases = []acronymTest {
|
45
47
|
{{range .J.Cases}} {{range .Cases}}{
|
46
|
-
input: {{printf "%q" .Phrase }},
|
48
|
+
input: {{printf "%q" .Input.Phrase }},
|
47
49
|
expected: {{printf "%q" .Expected }},
|
48
50
|
},
|
49
51
|
{{end}}{{end}}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package acronym
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: c5fb622 acronym: Update json for new "input" policy (#1032)
|
5
|
+
// Problem Specifications Version: 1.2.0
|
6
6
|
|
7
7
|
type acronymTest struct {
|
8
8
|
input string
|
@@ -1,7 +1,6 @@
|
|
1
1
|
package acronym
|
2
2
|
|
3
3
|
import (
|
4
|
-
"fmt"
|
5
4
|
"regexp"
|
6
5
|
"strings"
|
7
6
|
)
|
@@ -9,11 +8,11 @@ import (
|
|
9
8
|
func Abbreviate(s string) string {
|
10
9
|
regex := regexp.MustCompile("[A-Z]+[a-z]*|[a-z]+")
|
11
10
|
words := regex.FindAllString(s, -1)
|
12
|
-
abbr := []string{}
|
13
11
|
|
12
|
+
var abbr []string
|
14
13
|
for _, word := range words {
|
15
14
|
abbr = append(abbr, string(word[0]))
|
16
15
|
}
|
17
16
|
|
18
|
-
return
|
17
|
+
return strings.ToUpper(strings.Join(abbr, ""))
|
19
18
|
}
|
@@ -29,10 +29,12 @@ type js struct {
|
|
29
29
|
type oneCase struct {
|
30
30
|
Description string
|
31
31
|
Property string
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
Input struct {
|
33
|
+
InputBase int `json:"input_base"`
|
34
|
+
Digits []int `json:"digits"`
|
35
|
+
OutputBase int `json:"output_base"`
|
36
|
+
}
|
37
|
+
Expected interface{}
|
36
38
|
}
|
37
39
|
|
38
40
|
func (o oneCase) Result() []int {
|
@@ -70,9 +72,9 @@ var testCases = []struct {
|
|
70
72
|
}{ {{range .J.Cases}}
|
71
73
|
{
|
72
74
|
description: {{printf "%q" .Description}},
|
73
|
-
inputBase: {{printf "%d" .InputBase}},
|
74
|
-
inputDigits: {{printf "%#v" .
|
75
|
-
outputBase: {{printf "%d" .OutputBase}},
|
75
|
+
inputBase: {{printf "%d" .Input.InputBase}},
|
76
|
+
inputDigits: {{printf "%#v" .Input.Digits}},
|
77
|
+
outputBase: {{printf "%d" .Input.OutputBase}},
|
76
78
|
expected: {{printf "%#v" .Result}},
|
77
79
|
err: {{printf "%q" .Err}},
|
78
80
|
},{{end}}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package allyourbase
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 2.0
|
4
|
+
// Commit: bf4052e all-your-base: Update json to reflect changes to schema
|
5
|
+
// Problem Specifications Version: 2.1.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|
@@ -31,16 +31,20 @@ type testGroup struct {
|
|
31
31
|
Cases []json.RawMessage `property:"RAW"`
|
32
32
|
AllergicToCases []struct {
|
33
33
|
Description string
|
34
|
-
|
35
|
-
|
34
|
+
Input struct {
|
35
|
+
Score uint
|
36
|
+
}
|
37
|
+
Expected []struct {
|
36
38
|
Substance string
|
37
39
|
Result bool
|
38
40
|
}
|
39
41
|
} `property:"allergicTo"`
|
40
42
|
ListCases []struct {
|
41
43
|
Description string
|
42
|
-
|
43
|
-
|
44
|
+
Input struct {
|
45
|
+
Score uint
|
46
|
+
}
|
47
|
+
Expected []string
|
44
48
|
} `property:"list"`
|
45
49
|
}
|
46
50
|
|
@@ -64,7 +68,7 @@ var tmpl = `package allergies
|
|
64
68
|
{{- range .AllergicToCases }}
|
65
69
|
{
|
66
70
|
description: {{.Description | printf "%q"}},
|
67
|
-
score: {{.Score}},
|
71
|
+
score: {{.Input.Score}},
|
68
72
|
expected: []allergicResult{ {{range .Expected}}
|
69
73
|
{ {{.Substance | printf "%q"}}, {{.Result}} },{{end}}
|
70
74
|
},
|
@@ -80,7 +84,7 @@ var tmpl = `package allergies
|
|
80
84
|
expected []string
|
81
85
|
}{
|
82
86
|
{{- range .ListCases }}
|
83
|
-
{ {{.Description | printf "%q"}}, {{.Score}}, {{.Expected | printf "%#v"}}},
|
87
|
+
{ {{.Description | printf "%q"}}, {{.Input.Score}}, {{.Expected | printf "%#v"}}},
|
84
88
|
{{- end }}
|
85
89
|
}
|
86
90
|
{{- end }}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package allergies
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: 85dcb59 allergies: Update json for new "input" policy (#1033)
|
5
|
+
// Problem Specifications Version: 1.1.0
|
6
6
|
|
7
7
|
// allergicTo
|
8
8
|
type allergicResult struct {
|
@@ -29,9 +29,11 @@ type js struct {
|
|
29
29
|
// The JSON structure we expect to be able to unmarshal into
|
30
30
|
type OneCase struct {
|
31
31
|
Description string
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
Input struct {
|
33
|
+
Subject string
|
34
|
+
Candidates []string
|
35
|
+
}
|
36
|
+
Expected []string
|
35
37
|
}
|
36
38
|
|
37
39
|
// template applied to above data structure generates the Go test cases
|
@@ -47,8 +49,8 @@ var testCases = []struct {
|
|
47
49
|
}{ {{range .J.Cases}}
|
48
50
|
{
|
49
51
|
description: {{printf "%q" .Description}},
|
50
|
-
subject: {{printf "%q" .Subject}},
|
51
|
-
candidates: []string { {{range $line := .Candidates}}{{printf "\n%q," $line}}{{end}}},
|
52
|
+
subject: {{printf "%q" .Input.Subject}},
|
53
|
+
candidates: []string { {{range $line := .Input.Candidates}}{{printf "\n%q," $line}}{{end}}},
|
52
54
|
expected: []string { {{range $line := .Expected}}{{printf "\n%q," $line}}{{end}}},
|
53
55
|
},{{end}}
|
54
56
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package anagram
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.0
|
4
|
+
// Commit: a0f7663 anagram: Update json for new "input" policy (#1036)
|
5
|
+
// Problem Specifications Version: 1.1.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|
@@ -0,0 +1,54 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"log"
|
5
|
+
"text/template"
|
6
|
+
|
7
|
+
"../../../gen"
|
8
|
+
)
|
9
|
+
|
10
|
+
func main() {
|
11
|
+
t, err := template.New("").Parse(tmpl)
|
12
|
+
if err != nil {
|
13
|
+
log.Fatal(err)
|
14
|
+
}
|
15
|
+
var j js
|
16
|
+
if err := gen.Gen("armstrong-numbers", &j, t); err != nil {
|
17
|
+
log.Fatal(err)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
// The JSON structure we expect to be able to unmarshal into
|
22
|
+
type js struct {
|
23
|
+
Exercise string
|
24
|
+
Version string
|
25
|
+
Cases []oneCase
|
26
|
+
}
|
27
|
+
|
28
|
+
// Test cases
|
29
|
+
type oneCase struct {
|
30
|
+
Description string
|
31
|
+
Property string
|
32
|
+
Input struct {
|
33
|
+
Number int
|
34
|
+
}
|
35
|
+
Expected bool
|
36
|
+
}
|
37
|
+
|
38
|
+
// Template to generate test cases.
|
39
|
+
var tmpl = `package armstrong
|
40
|
+
|
41
|
+
{{.Header}}
|
42
|
+
|
43
|
+
var testCases = []struct {
|
44
|
+
description string
|
45
|
+
input int
|
46
|
+
expected bool
|
47
|
+
}{ {{range .J.Cases}}
|
48
|
+
{
|
49
|
+
description: {{printf "%q" .Description}},
|
50
|
+
input: {{printf "%#v" .Input.Number}},
|
51
|
+
expected: {{printf "%#v" .Expected}},
|
52
|
+
},{{end}}
|
53
|
+
}
|
54
|
+
`
|
@@ -0,0 +1,12 @@
|
|
1
|
+
package armstrong
|
2
|
+
|
3
|
+
import "testing"
|
4
|
+
|
5
|
+
func TestArmstrong(t *testing.T) {
|
6
|
+
for _, tc := range testCases {
|
7
|
+
if actual := IsNumber(tc.input); actual != tc.expected {
|
8
|
+
t.Fatalf("FAIL: %s\nExpected: %v\nActual: %v", tc.description, tc.expected, actual)
|
9
|
+
}
|
10
|
+
t.Logf("PASS: %s", tc.description)
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
package armstrong
|
2
|
+
|
3
|
+
// Source: exercism/problem-specifications
|
4
|
+
// Commit: 5c3baae armstrong-numbers: new exercise (#1018)
|
5
|
+
// Problem Specifications Version: 1.0.0
|
6
|
+
|
7
|
+
var testCases = []struct {
|
8
|
+
description string
|
9
|
+
input int
|
10
|
+
expected bool
|
11
|
+
}{
|
12
|
+
{
|
13
|
+
description: "Single digit numbers are Armstrong numbers",
|
14
|
+
input: 5,
|
15
|
+
expected: true,
|
16
|
+
},
|
17
|
+
{
|
18
|
+
description: "There are no 2 digit Armstrong numbers",
|
19
|
+
input: 10,
|
20
|
+
expected: false,
|
21
|
+
},
|
22
|
+
{
|
23
|
+
description: "Three digit number that is an Armstrong number",
|
24
|
+
input: 153,
|
25
|
+
expected: true,
|
26
|
+
},
|
27
|
+
{
|
28
|
+
description: "Three digit number that is not an Armstrong number",
|
29
|
+
input: 100,
|
30
|
+
expected: false,
|
31
|
+
},
|
32
|
+
{
|
33
|
+
description: "Four digit number that is an Armstrong number",
|
34
|
+
input: 9474,
|
35
|
+
expected: true,
|
36
|
+
},
|
37
|
+
{
|
38
|
+
description: "Four digit number that is not an Armstrong number",
|
39
|
+
input: 9475,
|
40
|
+
expected: false,
|
41
|
+
},
|
42
|
+
{
|
43
|
+
description: "Seven digit number that is an Armstrong number",
|
44
|
+
input: 9926315,
|
45
|
+
expected: true,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
description: "Seven digit number that is not an Armstrong number",
|
49
|
+
input: 9926314,
|
50
|
+
expected: false,
|
51
|
+
},
|
52
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
package armstrong
|
2
|
+
|
3
|
+
import "math"
|
4
|
+
|
5
|
+
func order(n int) (result int) {
|
6
|
+
for n != 0 {
|
7
|
+
result++
|
8
|
+
n = n / 10
|
9
|
+
}
|
10
|
+
return
|
11
|
+
}
|
12
|
+
|
13
|
+
// IsNumber returns true for an armstrong number
|
14
|
+
func IsNumber(n int) bool {
|
15
|
+
originalNumber := n
|
16
|
+
pow := order(n)
|
17
|
+
sum := 0
|
18
|
+
for n != 0 {
|
19
|
+
remainder := n % 10
|
20
|
+
sum += int(math.Pow(float64(remainder), float64(pow)))
|
21
|
+
n = n / 10
|
22
|
+
}
|
23
|
+
return originalNumber == sum
|
24
|
+
}
|
@@ -29,9 +29,11 @@ type js struct {
|
|
29
29
|
type oneCase struct {
|
30
30
|
Description string
|
31
31
|
Property string
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
Input struct {
|
33
|
+
Array []int
|
34
|
+
Value int
|
35
|
+
}
|
36
|
+
Expected int
|
35
37
|
}
|
36
38
|
|
37
39
|
// Template to generate test cases.
|
@@ -47,8 +49,8 @@ var testCases = []struct {
|
|
47
49
|
}{ {{range .J.Cases}}
|
48
50
|
{
|
49
51
|
description: {{printf "%q" .Description}},
|
50
|
-
slice: {{printf "%#v"
|
51
|
-
key: {{printf "%d" .Value}},
|
52
|
+
slice: {{printf "%#v" .Input.Array}},
|
53
|
+
key: {{printf "%d" .Input.Value}},
|
52
54
|
x: {{printf "%d" .Expected}},
|
53
55
|
},{{end}}
|
54
56
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
package binarysearch
|
2
2
|
|
3
3
|
// Source: exercism/problem-specifications
|
4
|
-
// Commit:
|
5
|
-
// Problem Specifications Version: 1.
|
4
|
+
// Commit: 6114d03 binary-search: Update json for new input policy
|
5
|
+
// Problem Specifications Version: 1.1.0
|
6
6
|
|
7
7
|
var testCases = []struct {
|
8
8
|
description string
|