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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/acronym/canonical-data.json +3 -11
  4. data/problem-specifications/exercises/hamming/canonical-data.json +61 -31
  5. data/problem-specifications/exercises/react/canonical-data.json +472 -436
  6. data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +1 -1
  7. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +1 -1
  8. data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +1 -1
  9. data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +1 -1
  10. data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNATest.ceylon +1 -1
  11. data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +1 -1
  12. data/tracks/common-lisp/config.json +9 -9
  13. data/tracks/crystal/exercises/acronym/spec/acronym_spec.cr +0 -4
  14. data/tracks/crystal/exercises/binary/spec/binary_spec.cr +6 -6
  15. data/tracks/crystal/exercises/forth/spec/forth_spec.cr +48 -32
  16. data/tracks/crystal/exercises/hello-world/spec/hello_world_spec.cr +1 -9
  17. data/tracks/crystal/exercises/pascals-triangle/spec/pascals_triangle_spec.cr +13 -1
  18. data/tracks/crystal/generator/spec/exercise_generator_spec.cr +1 -1
  19. data/tracks/crystal/generator/src/generators/acronym.cr +1 -1
  20. data/tracks/crystal/generator/src/generators/binary.cr +2 -2
  21. data/tracks/crystal/generator/src/generators/flatten_array.cr +1 -1
  22. data/tracks/crystal/generator/src/generators/forth.cr +3 -3
  23. data/tracks/crystal/generator/src/generators/pascals-triangle.cr +11 -4
  24. data/tracks/delphi/exercises/phone-number/uPhoneNumberTests.pas +35 -10
  25. data/tracks/factor/exercises/isogram/README.md +2 -2
  26. data/tracks/fortran/.travis.yml +0 -1
  27. data/tracks/go/exercises/book-store/.meta/gen.go +3 -3
  28. data/tracks/go/exercises/book-store/.meta/hints.md +14 -0
  29. data/tracks/go/exercises/book-store/README.md +17 -1
  30. data/tracks/go/exercises/book-store/cases_test.go +17 -17
  31. data/tracks/go/exercises/book-store/example.go +13 -11
  32. data/tracks/go/exercises/bowling/.meta/gen.go +10 -8
  33. data/tracks/go/exercises/bowling/cases_test.go +2 -2
  34. data/tracks/go/exercises/bracket-push/.meta/gen.go +5 -3
  35. data/tracks/go/exercises/bracket-push/cases_test.go +2 -2
  36. data/tracks/go/exercises/dominoes/.meta/gen.go +7 -3
  37. data/tracks/go/exercises/dominoes/cases_test.go +12 -2
  38. data/tracks/go/exercises/nucleotide-count/.meta/gen.go +87 -0
  39. data/tracks/go/exercises/nucleotide-count/.meta/hints.md +20 -0
  40. data/tracks/go/exercises/nucleotide-count/cases_test.go +39 -0
  41. data/tracks/go/exercises/nucleotide-count/example.go +6 -16
  42. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +16 -93
  43. data/tracks/go/exercises/sum-of-multiples/.meta/gen.go +6 -4
  44. data/tracks/go/exercises/sum-of-multiples/cases_test.go +2 -2
  45. data/tracks/haskell/README.md +6 -5
  46. data/tracks/haskell/config.json +73 -73
  47. data/tracks/haskell/exercises/allergies/{HINTS.md → .meta/hints.md} +0 -0
  48. data/tracks/haskell/exercises/alphametics/{HINTS.md → .meta/hints.md} +0 -0
  49. data/tracks/haskell/exercises/anagram/{HINTS.md → .meta/hints.md} +0 -0
  50. data/tracks/haskell/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
  51. data/tracks/haskell/exercises/beer-song/{HINTS.md → .meta/hints.md} +0 -0
  52. data/tracks/haskell/exercises/binary-search-tree/{HINTS.md → .meta/hints.md} +0 -0
  53. data/tracks/haskell/exercises/bowling/{HINTS.md → .meta/hints.md} +0 -0
  54. data/tracks/haskell/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
  55. data/tracks/haskell/exercises/custom-set/{HINTS.md → .meta/hints.md} +0 -0
  56. data/tracks/haskell/exercises/food-chain/{HINTS.md → .meta/hints.md} +0 -0
  57. data/tracks/haskell/exercises/forth/{HINTS.md → .meta/hints.md} +0 -0
  58. data/tracks/haskell/exercises/go-counting/{HINTS.md → .meta/hints.md} +0 -0
  59. data/tracks/haskell/exercises/grade-school/{HINTS.md → .meta/hints.md} +0 -0
  60. data/tracks/haskell/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
  61. data/tracks/haskell/exercises/hello-world/package.yaml +1 -1
  62. data/tracks/haskell/exercises/house/{HINTS.md → .meta/hints.md} +0 -0
  63. data/tracks/haskell/exercises/isbn-verifier/README.md +1 -1
  64. data/tracks/haskell/exercises/largest-series-product/package.yaml +1 -1
  65. data/tracks/haskell/exercises/leap/{HINTS.md → .meta/hints.md} +0 -0
  66. data/tracks/haskell/exercises/leap/package.yaml +1 -1
  67. data/tracks/haskell/exercises/linked-list/{HINTS.md → .meta/hints.md} +0 -0
  68. data/tracks/haskell/exercises/matrix/{HINTS.md → .meta/hints.md} +0 -0
  69. data/tracks/haskell/exercises/meetup/{HINTS.md → .meta/hints.md} +0 -0
  70. data/tracks/haskell/exercises/minesweeper/package.yaml +1 -1
  71. data/tracks/haskell/exercises/nth-prime/package.yaml +1 -1
  72. data/tracks/haskell/exercises/nucleotide-count/package.yaml +1 -1
  73. data/tracks/haskell/exercises/octal/{HINTS.md → .meta/hints.md} +0 -0
  74. data/tracks/haskell/exercises/palindrome-products/{HINTS.md → .meta/hints.md} +0 -0
  75. data/tracks/haskell/exercises/parallel-letter-frequency/{HINTS.md → .meta/hints.md} +0 -0
  76. data/tracks/haskell/exercises/pascals-triangle/package.yaml +1 -1
  77. data/tracks/haskell/exercises/perfect-numbers/package.yaml +1 -1
  78. data/tracks/haskell/exercises/phone-number/package.yaml +1 -1
  79. data/tracks/haskell/exercises/phone-number/test/Tests.hs +10 -2
  80. data/tracks/haskell/exercises/pig-latin/package.yaml +1 -1
  81. data/tracks/haskell/exercises/queen-attack/{HINTS.md → .meta/hints.md} +0 -0
  82. data/tracks/haskell/exercises/rna-transcription/package.yaml +1 -1
  83. data/tracks/haskell/exercises/robot-name/{HINTS.md → .meta/hints.md} +0 -0
  84. data/tracks/haskell/exercises/robot-simulator/{HINTS.md → .meta/hints.md} +0 -0
  85. data/tracks/haskell/exercises/roman-numerals/{HINTS.md → .meta/hints.md} +0 -0
  86. data/tracks/haskell/exercises/roman-numerals/package.yaml +1 -1
  87. data/tracks/haskell/exercises/rotational-cipher/package.yaml +1 -1
  88. data/tracks/haskell/exercises/saddle-points/package.yaml +1 -1
  89. data/tracks/haskell/exercises/scrabble-score/package.yaml +1 -1
  90. data/tracks/haskell/exercises/secret-handshake/package.yaml +1 -1
  91. data/tracks/haskell/exercises/series/{HINTS.md → .meta/hints.md} +0 -0
  92. data/tracks/haskell/exercises/sgf-parsing/{HINTS.md → .meta/hints.md} +0 -0
  93. data/tracks/haskell/exercises/sieve/package.yaml +1 -1
  94. data/tracks/haskell/exercises/simple-linked-list/{HINTS.md → .meta/hints.md} +0 -0
  95. data/tracks/haskell/exercises/space-age/{HINTS.md → .meta/hints.md} +0 -0
  96. data/tracks/haskell/exercises/space-age/package.yaml +1 -1
  97. data/tracks/haskell/exercises/spiral-matrix/package.yaml +1 -1
  98. data/tracks/haskell/exercises/sublist/{HINTS.md → .meta/hints.md} +0 -0
  99. data/tracks/haskell/exercises/sublist/package.yaml +1 -1
  100. data/tracks/haskell/exercises/trinary/{HINTS.md → .meta/hints.md} +0 -0
  101. data/tracks/haskell/exercises/twelve-days/package.yaml +1 -1
  102. data/tracks/haskell/exercises/word-count/{HINTS.md → .meta/hints.md} +0 -0
  103. data/tracks/haskell/exercises/wordy/{HINTS.md → .meta/hints.md} +0 -0
  104. data/tracks/haskell/exercises/zebra-puzzle/package.yaml +1 -1
  105. data/tracks/java/exercises/phone-number/.meta/src/reference/java/PhoneNumber.java +10 -2
  106. data/tracks/java/exercises/phone-number/.meta/version +1 -0
  107. data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +56 -19
  108. data/tracks/purescript/config/exercise_readme.go.tmpl +0 -3
  109. data/tracks/swift/.travis.yml +0 -18
  110. data/tracks/swift/circle.yml +17 -6
  111. metadata +41 -37
  112. data/tracks/purescript/docs/EXERCISE_README_INSERT.md +0 -0
@@ -7,9 +7,16 @@ class PascalsTriangleGenerator < ExerciseGenerator
7
7
  end
8
8
 
9
9
  def test_cases
10
- JSON.parse(data)["rows"]["cases"].map do |test_case|
11
- PascalsTriangleTestCase.new(test_case) unless test_case["count"]?.nil?
12
- end.compact
10
+ test_cases = [] of JSON::Any
11
+ JSON.parse(data)["cases"].each do |group|
12
+ group.each do |a, b|
13
+ test_cases.concat(b) if a.as_s == "cases"
14
+ end
15
+ end
16
+
17
+ test_cases.map do |test_case|
18
+ PascalsTriangleTestCase.new(test_case)
19
+ end
13
20
  end
14
21
  end
15
22
 
@@ -29,7 +36,7 @@ class PascalsTriangleTestCase < ExerciseTestCase
29
36
  "PascalsTriangle.rows(#{count}).should eq(#{expected})"
30
37
  else
31
38
  <<-WL
32
- expect_raises do
39
+ expect_raises(ArgumentError) do
33
40
  PascalsTriangle.rows(#{count})
34
41
  end
35
42
  WL
@@ -10,6 +10,9 @@ interface
10
10
  uses
11
11
  DUnitX.TestFramework;
12
12
 
13
+ const
14
+ CanonicalVersion = '1.4.0';
15
+
13
16
  type
14
17
 
15
18
  [TestFixture]
@@ -29,15 +32,19 @@ type
29
32
 
30
33
  [Test]
31
34
  [Ignore]
32
- procedure Valid_when_11_digits_and_starting_with_1;
35
+ procedure Invalid_when_9_digits;
33
36
 
34
37
  [Test]
35
38
  [Ignore]
36
- procedure Invalid_when_9_digits;
39
+ procedure Invalid_when_11_digits_does_not_start_with_a_1;
37
40
 
38
41
  [Test]
39
42
  [Ignore]
40
- procedure Invalid_when_11_digits_does_not_start_with_a_1;
43
+ procedure Valid_when_11_digits_and_starting_with_1;
44
+
45
+ [Test]
46
+ [Ignore]
47
+ procedure Valid_when_11_digits_and_starting_with_1_even_with_punctuation;
41
48
 
42
49
  [Test]
43
50
  [Ignore]
@@ -53,15 +60,19 @@ type
53
60
 
54
61
  [Test]
55
62
  [Ignore]
56
- procedure Invalid_with_right_number_of_digits_but_letters_mixed_in;
63
+ procedure Invalid_if_area_code_starts_with_0;
57
64
 
58
65
  [Test]
59
66
  [Ignore]
60
- procedure Invalid_if_area_code_does_not_start_with_2_thru_9;
67
+ procedure Invalid_if_area_code_starts_with_1;
61
68
 
62
69
  [Test]
63
70
  [Ignore]
64
- procedure Invalid_if_exchange_code_does_not_start_with_2_thru_9;
71
+ procedure Invalid_if_exchange_code_starts_with_0;
72
+
73
+ [Test]
74
+ [Ignore]
75
+ procedure Invalid_if_exchange_code_starts_with_1;
65
76
 
66
77
  [Test]
67
78
  [Ignore('This is a bonus test')]
@@ -107,6 +118,13 @@ begin
107
118
  assert.AreEqual('2234567890', phone.Clean);
108
119
  end;
109
120
 
121
+ procedure PhoneNumberTests.Valid_when_11_digits_and_starting_with_1_even_with_punctuation;
122
+ var phone: IPhoneNumber;
123
+ begin
124
+ phone := NewPhoneNumber('+1 (223) 456-7890');
125
+ assert.AreEqual('2234567890', phone.Clean);
126
+ end;
127
+
110
128
  procedure PhoneNumberTests.Invalid_when_11_digits_does_not_start_with_a_1;
111
129
  var phone: IPhoneNumber;
112
130
  begin
@@ -142,27 +160,34 @@ begin
142
160
  assert.AreEqual('', phone.Clean);
143
161
  end;
144
162
 
145
- procedure PhoneNumberTests.Invalid_with_right_number_of_digits_but_letters_mixed_in;
163
+ procedure PhoneNumberTests.Invalid_if_area_code_starts_with_0;
146
164
  var phone: IPhoneNumber;
147
165
  begin
148
- phone := NewPhoneNumber('1a2b3c4d5e6f7g8h9i0j');
166
+ phone := NewPhoneNumber('(023) 456-7890');
149
167
  assert.AreEqual('', phone.Clean);
150
168
  end;
151
169
 
152
- procedure PhoneNumberTests.Invalid_if_area_code_does_not_start_with_2_thru_9;
170
+ procedure PhoneNumberTests.Invalid_if_area_code_starts_with_1;
153
171
  var phone: IPhoneNumber;
154
172
  begin
155
173
  phone := NewPhoneNumber('(123) 456-7890');
156
174
  assert.AreEqual('', phone.Clean);
157
175
  end;
158
176
 
159
- procedure PhoneNumberTests.Invalid_if_exchange_code_does_not_start_with_2_thru_9;
177
+ procedure PhoneNumberTests.Invalid_if_exchange_code_starts_with_0;
160
178
  var phone: IPhoneNumber;
161
179
  begin
162
180
  phone := NewPhoneNumber('(223) 056-7890');
163
181
  assert.AreEqual('', phone.Clean);
164
182
  end;
165
183
 
184
+ procedure PhoneNumberTests.Invalid_if_exchange_code_starts_with_1;
185
+ var phone: IPhoneNumber;
186
+ begin
187
+ phone := NewPhoneNumber('(223) 156-7890');
188
+ assert.AreEqual('', phone.Clean);
189
+ end;
190
+
166
191
  procedure PhoneNumberTests.Extract_area_code;
167
192
  var phone: IPhoneNumber;
168
193
  begin
@@ -14,7 +14,7 @@ The word *isograms*, however, is not an isogram, because the s repeats.
14
14
 
15
15
  ## Testing Exercises
16
16
 
17
- If you followed the [installation instructions](http://exercism.io/languages/factor/installing), just run the provided test suite against your implementation with `"exercise-name" test`.
17
+ If you followed the [installation instructions](http://exercism.io/languages/factor/installation), just run the provided test suite against your implementation with `"exercise-name" test`.
18
18
 
19
19
  ## Submitting Exercises
20
20
 
@@ -23,7 +23,7 @@ Note that, when trying to submit an exercise, make sure the solution is in the `
23
23
  For example, if you're submitting `bob.factor` for the Bob exercise, the submit command would be something like `exercism submit exercism/factor/bob/bob.factor`.
24
24
 
25
25
  For more detailed information about running tests, code style and linting,
26
- please see the [help page](http://exercism.io/languages/factor).
26
+ please see the [help page](http://exercism.io/languages/factor/help).
27
27
  ## Source
28
28
 
29
29
  Wikipedia [https://en.wikipedia.org/wiki/Isogram](https://en.wikipedia.org/wiki/Isogram)
@@ -4,7 +4,6 @@ language: c
4
4
  before_install:
5
5
  - sudo apt-get install gfortran
6
6
  - sudo apt-get install ruby-full
7
- - sudo apt-get install rubygems
8
7
 
9
8
  install:
10
9
  - sudo gem install funit
@@ -34,7 +34,7 @@ type OneCase struct {
34
34
  Input struct {
35
35
  Basket []int
36
36
  }
37
- Expected float64
37
+ Expected int
38
38
  }
39
39
 
40
40
  // template applied to above data structure generates the Go test cases
@@ -45,12 +45,12 @@ var tmpl = `package bookstore
45
45
  var testCases = []struct {
46
46
  description string
47
47
  basket []int
48
- expected float64
48
+ expected int
49
49
  }{{range .J.Groups}}{
50
50
  {{range .Cases}} {
51
51
  description: "{{.Description}}",
52
52
  basket: {{printf "%#v" .Input.Basket}},
53
- expected: {{printf "%.2f" .Expected}},
53
+ expected: {{printf "%d" .Expected}},
54
54
  },
55
55
  {{end}}}{{end}}
56
56
  `
@@ -0,0 +1,14 @@
1
+ ## Implementation
2
+
3
+ Define a single Go func, Cost, which calculates the cost
4
+ for a given list of books based on the defined discounts.
5
+
6
+ Use the following signature for func Cost:
7
+
8
+ ```
9
+ func Cost(books []int) int
10
+ ```
11
+ Cost will return the total cost (after discounts) in cents.
12
+ For example, for a single book, the cost is 800 cents, which equals $8.00.
13
+ Only integer calculations are necessary for this exercise.
14
+
@@ -67,6 +67,22 @@ For a total of $51.20
67
67
 
68
68
  And $51.20 is the price with the biggest discount.
69
69
 
70
+ ## Implementation
71
+
72
+ Define a single Go func, Cost, which calculates the cost
73
+ for a given list of books based on the defined discounts.
74
+
75
+ Use the following signature for func Cost:
76
+
77
+ ```
78
+ func Cost(books []int) int
79
+ ```
80
+ Cost will return the total cost (after discounts) in cents.
81
+ For example, for a single book, the cost is 800 cents, which equals $8.00.
82
+ Only integer calculations are necessary for this exercise.
83
+
84
+
85
+
70
86
  ## Running the tests
71
87
 
72
88
  To run the tests run the command `go test` from within the exercise directory.
@@ -86,7 +102,7 @@ you're having trouble, please visit the exercism.io [Go language page](http://ex
86
102
 
87
103
  ## Source
88
104
 
89
- [Inspired by the harry potter kata from Cyber-Dojo](http://cyber-dojo.org).
105
+ Inspired by the harry potter kata from Cyber-Dojo. [http://cyber-dojo.org](http://cyber-dojo.org)
90
106
 
91
107
  ## Submitting Incomplete Solutions
92
108
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -1,82 +1,82 @@
1
1
  package bookstore
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: 78006a2 move "targetgrouping" to "comments"
5
- // Problem Specifications Version: 1.2.0
4
+ // Commit: a2ed4f7 book-store: Clarify expected monetary denomination
5
+ // Problem Specifications Version: 1.3.0
6
6
 
7
7
  var testCases = []struct {
8
8
  description string
9
9
  basket []int
10
- expected float64
10
+ expected int
11
11
  }{
12
12
  {
13
13
  description: "Only a single book",
14
14
  basket: []int{1},
15
- expected: 8.00,
15
+ expected: 800,
16
16
  },
17
17
  {
18
18
  description: "Two of the same book",
19
19
  basket: []int{2, 2},
20
- expected: 16.00,
20
+ expected: 1600,
21
21
  },
22
22
  {
23
23
  description: "Empty basket",
24
24
  basket: []int{},
25
- expected: 0.00,
25
+ expected: 0,
26
26
  },
27
27
  {
28
28
  description: "Two different books",
29
29
  basket: []int{1, 2},
30
- expected: 15.20,
30
+ expected: 1520,
31
31
  },
32
32
  {
33
33
  description: "Three different books",
34
34
  basket: []int{1, 2, 3},
35
- expected: 21.60,
35
+ expected: 2160,
36
36
  },
37
37
  {
38
38
  description: "Four different books",
39
39
  basket: []int{1, 2, 3, 4},
40
- expected: 25.60,
40
+ expected: 2560,
41
41
  },
42
42
  {
43
43
  description: "Five different books",
44
44
  basket: []int{1, 2, 3, 4, 5},
45
- expected: 30.00,
45
+ expected: 3000,
46
46
  },
47
47
  {
48
48
  description: "Two groups of four is cheaper than group of five plus group of three",
49
49
  basket: []int{1, 1, 2, 2, 3, 3, 4, 5},
50
- expected: 51.20,
50
+ expected: 5120,
51
51
  },
52
52
  {
53
53
  description: "Group of four plus group of two is cheaper than two groups of three",
54
54
  basket: []int{1, 1, 2, 2, 3, 4},
55
- expected: 40.80,
55
+ expected: 4080,
56
56
  },
57
57
  {
58
58
  description: "Two each of first 4 books and 1 copy each of rest",
59
59
  basket: []int{1, 1, 2, 2, 3, 3, 4, 4, 5},
60
- expected: 55.60,
60
+ expected: 5560,
61
61
  },
62
62
  {
63
63
  description: "Two copies of each book",
64
64
  basket: []int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5},
65
- expected: 60.00,
65
+ expected: 6000,
66
66
  },
67
67
  {
68
68
  description: "Three copies of first book and 2 each of remaining",
69
69
  basket: []int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1},
70
- expected: 68.00,
70
+ expected: 6800,
71
71
  },
72
72
  {
73
73
  description: "Three each of first 2 books and 2 each of remaining books",
74
74
  basket: []int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2},
75
- expected: 75.20,
75
+ expected: 7520,
76
76
  },
77
77
  {
78
78
  description: "Four groups of four are cheaper than two groups each of five and three",
79
79
  basket: []int{1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5},
80
- expected: 102.40,
80
+ expected: 10240,
81
81
  },
82
82
  }
@@ -1,25 +1,23 @@
1
1
  package bookstore
2
2
 
3
- import (
4
- "math"
5
- )
3
+ import "math"
6
4
 
7
- const bookPrice = 8
5
+ const bookPrice = 800 // 800 cents = $8.00
8
6
 
9
- var discountTiers = [...]float64{0, 0.05, 0.1, 0.2, 0.25}
7
+ var discountTiers = [...]int{0, 5, 10, 20, 25}
10
8
 
11
9
  // Cost implements the book store exercise.
12
- func Cost(books []int) float64 {
10
+ func Cost(books []int) int {
13
11
  return cost(books, 0)
14
12
  }
15
13
 
16
- func cost(books []int, priceSoFar float64) float64 {
14
+ func cost(books []int, priceSoFar int) int {
17
15
  if len(books) == 0 {
18
16
  return priceSoFar
19
17
  }
20
18
 
21
19
  distinctBooks, remainingBooks := getDistinctBooks(books)
22
- minPrice := math.MaxFloat32
20
+ minPrice := math.MaxInt32
23
21
 
24
22
  for i := 1; i <= len(distinctBooks); i++ {
25
23
  newRemainingBooks := make([]int, len(remainingBooks))
@@ -27,7 +25,9 @@ func cost(books []int, priceSoFar float64) float64 {
27
25
  newRemainingBooks = append(newRemainingBooks, distinctBooks[i:]...)
28
26
 
29
27
  price := cost(newRemainingBooks, priceSoFar+groupCost(i))
30
- minPrice = math.Min(minPrice, price)
28
+ if price < minPrice {
29
+ minPrice = price
30
+ }
31
31
  }
32
32
 
33
33
  return minPrice
@@ -47,6 +47,8 @@ func getDistinctBooks(books []int) (distinct []int, remaining []int) {
47
47
  return
48
48
  }
49
49
 
50
- func groupCost(groupSize int) float64 {
51
- return float64(bookPrice*groupSize) * (1.00 - discountTiers[groupSize-1])
50
+ func groupCost(groupSize int) int {
51
+ normalPrice := bookPrice * groupSize
52
+ discount := (normalPrice * discountTiers[groupSize-1]) / 100
53
+ return normalPrice - discount
52
54
  }
@@ -29,11 +29,13 @@ type js struct {
29
29
  // template applied to above data structure generates the Go test cases
30
30
 
31
31
  type OneCase struct {
32
- Description string
33
- Property string
34
- PreviousRolls []int `json:"previous_rolls"`
35
- Roll int
36
- Expected interface{}
32
+ Description string
33
+ Property string
34
+ Input struct {
35
+ PreviousRolls []int
36
+ Roll int
37
+ }
38
+ Expected interface{}
37
39
  }
38
40
 
39
41
  // ScoreTest and RollTest help determine which type of test case
@@ -90,7 +92,7 @@ var scoreTestCases = []struct {
90
92
  }{ {{range .J.Cases}}
91
93
  {{if .ScoreTest}}{
92
94
  {{printf "%q" .Description}},
93
- {{printf "%#v" .PreviousRolls}},
95
+ {{printf "%#v" .Input.PreviousRolls}},
94
96
  {{printf "%v" .Valid}},
95
97
  {{printf "%d" .Score}},
96
98
  {{printf "%q" .ExplainText}},
@@ -106,9 +108,9 @@ var rollTestCases = []struct {
106
108
  }{ {{range .J.Cases}}
107
109
  {{if .RollTest}}{
108
110
  {{printf "%q" .Description}},
109
- {{printf "%#v" .PreviousRolls}},
111
+ {{printf "%#v" .Input.PreviousRolls}},
110
112
  {{printf "%v" .Valid}},
111
- {{printf "%d" .Roll}},
113
+ {{printf "%d" .Input.Roll}},
112
114
  {{printf "%q" .ExplainText}},
113
115
  },{{- end}}{{end}}
114
116
  }
@@ -1,8 +1,8 @@
1
1
  package bowling
2
2
 
3
3
  // Source: exercism/problem-specifications
4
- // Commit: 26e345e [Bowling] Fix case descriptions (#832)
5
- // Problem Specifications Version: 1.0.1
4
+ // Commit: dfdc0e2 bowling: bump version
5
+ // Problem Specifications Version: 1.1.0
6
6
 
7
7
  var scoreTestCases = []struct {
8
8
  description string
@@ -22,8 +22,10 @@ func main() {
22
22
  type js struct {
23
23
  Cases []struct {
24
24
  Description string
25
- Input string
26
- Expected bool
25
+ Input struct {
26
+ Value string
27
+ }
28
+ Expected bool
27
29
  }
28
30
  }
29
31
 
@@ -40,7 +42,7 @@ type bracketTest struct {
40
42
  var testCases = []bracketTest {
41
43
  {{range .J.Cases}}{
42
44
  // {{.Description}}
43
- {{printf "%q" .Input}},
45
+ {{printf "%q" .Input.Value}},
44
46
  {{.Expected}},
45
47
  },
46
48
  {{end}}}