trackler 2.1.0.27 → 2.1.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +9 -349
- data/common/exercises/forth/canonical-data.json +1 -7
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/config.json +5 -0
- data/tracks/bash/exercises/anagram/anagram_tests.sh +99 -0
- data/tracks/bash/exercises/anagram/example.sh +23 -0
- data/tracks/delphi/config.json +8 -1
- data/tracks/delphi/exercises/two-fer/twofer.dpr +60 -0
- data/tracks/delphi/exercises/two-fer/utwoferExample.pas +17 -0
- data/tracks/delphi/exercises/two-fer/utwoferTest.pas +71 -0
- data/tracks/dlang/README.md +9 -5
- data/tracks/dlang/bin/test-exercise +14 -5
- data/tracks/dlang/docs/INSTALLATION.md +24 -0
- data/tracks/dlang/docs/TESTS.md +6 -6
- data/tracks/dlang/exercises/bob/dub.sdl +2 -0
- data/tracks/dlang/exercises/bob/{bob_example.d → example/bob.d} +0 -5
- data/tracks/dlang/exercises/bob/{bob.d → source/bob.d} +0 -5
- data/tracks/dlang/exercises/circular-buffer/dub.sdl +2 -0
- data/tracks/dlang/exercises/circular-buffer/{circular_buffer_example.d → example/circular_buffer.d} +0 -5
- data/tracks/dlang/exercises/circular-buffer/{circular_buffer.d → source/circular_buffer.d} +0 -5
- data/tracks/dlang/exercises/crypto-square/dub.sdl +2 -0
- data/tracks/dlang/exercises/crypto-square/{crypto_square_example.d → example/crypto_square.d} +0 -5
- data/tracks/dlang/exercises/crypto-square/{crypto_square.d → source/crypto_square.d} +0 -5
- data/tracks/dlang/exercises/difference-of-squares/dub.sdl +2 -0
- data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares_example.d → example/difference_of_squares.d} +0 -2
- data/tracks/dlang/exercises/difference-of-squares/{difference_of_squares.d → source/difference_of_squares.d} +0 -2
- data/tracks/dlang/exercises/etl/dub.sdl +2 -0
- data/tracks/dlang/exercises/etl/{etl_example.d → example/etl.d} +0 -5
- data/tracks/dlang/exercises/etl/{etl.d → source/etl.d} +0 -5
- data/tracks/dlang/exercises/gigasecond/dub.sdl +2 -0
- data/tracks/dlang/exercises/gigasecond/{gigasecond_example.d → example/gigasecond.d} +0 -2
- data/tracks/dlang/exercises/gigasecond/{gigasecond.d → source/gigasecond.d} +0 -2
- data/tracks/dlang/exercises/hamming/dub.sdl +2 -0
- data/tracks/dlang/exercises/hamming/{hamming_example.d → example/hamming.d} +0 -5
- data/tracks/dlang/exercises/hamming/{hamming.d → source/hamming.d} +0 -5
- data/tracks/dlang/exercises/hello-world/dub.sdl +2 -0
- data/tracks/dlang/exercises/hello-world/{hello_world_example.d → example/hello_world.d} +0 -2
- data/tracks/dlang/exercises/hello-world/{hello_world.d → source/hello_world.d} +0 -0
- data/tracks/dlang/exercises/leap/dub.sdl +2 -0
- data/tracks/dlang/exercises/leap/{leap_example.d → example/leap.d} +0 -2
- data/tracks/dlang/exercises/leap/{leap.d → source/leap.d} +0 -2
- data/tracks/dlang/exercises/nucleotide-count/dub.sdl +2 -0
- data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count_example.d → example/nucleotide_count.d} +0 -4
- data/tracks/dlang/exercises/nucleotide-count/{nucleotide_count.d → source/nucleotide_count.d} +0 -4
- data/tracks/dlang/exercises/pangram/dub.sdl +2 -0
- data/tracks/dlang/exercises/pangram/{pangram_example.d → example/pangram.d} +0 -2
- data/tracks/dlang/exercises/pangram/{pangram.d → source/pangram.d} +0 -2
- data/tracks/dlang/exercises/raindrops/dub.sdl +2 -0
- data/tracks/dlang/exercises/raindrops/{raindrops_example.d → example/raindrops.d} +0 -2
- data/tracks/dlang/exercises/raindrops/{raindrops.d → source/raindrops.d} +0 -2
- data/tracks/dlang/exercises/react/dub.sdl +2 -0
- data/tracks/dlang/exercises/react/{react_example.d → example/react.d} +0 -2
- data/tracks/dlang/exercises/react/{react.d → source/react.d} +0 -2
- data/tracks/dlang/exercises/rna-transcription/dub.sdl +2 -0
- data/tracks/dlang/exercises/rna-transcription/{rna_transcription_example.d → example/rna_transcription.d} +0 -2
- data/tracks/dlang/exercises/rna-transcription/{rna_transcription.d → source/rna_transcription.d} +0 -2
- data/tracks/dlang/exercises/robot-name/dub.sdl +2 -0
- data/tracks/dlang/exercises/robot-name/{robot_name_example.d → example/robot_name.d} +0 -5
- data/tracks/dlang/exercises/robot-name/{robot_name.d → source/robot_name.d} +0 -4
- data/tracks/dlang/exercises/roman-numerals/dub.sdl +2 -0
- data/tracks/dlang/exercises/roman-numerals/{roman_numerals_example.d → example/roman_numerals.d} +0 -4
- data/tracks/dlang/exercises/roman-numerals/{roman_numerals.d → source/roman_numerals.d} +0 -4
- data/tracks/dlang/exercises/series/dub.sdl +2 -0
- data/tracks/dlang/exercises/series/{series_example.d → example/series.d} +0 -5
- data/tracks/dlang/exercises/series/{series.d → source/series.d} +0 -5
- data/tracks/dlang/exercises/triangle/dub.sdl +2 -0
- data/tracks/dlang/exercises/triangle/{triangle_example.d → example/triangle.d} +0 -5
- data/tracks/dlang/exercises/triangle/{triangle.d → source/triangle.d} +0 -5
- data/tracks/elisp/.github/stale.yml +0 -0
- data/tracks/elisp/exercises/grains/grains-test.el +12 -12
- data/tracks/elisp/exercises/robot-name/robot-name-test.el +8 -19
- data/tracks/elisp/exercises/word-count/word-count-test.el +27 -27
- data/tracks/fortran/Makefile +3 -2
- data/tracks/fortran/config.json +21 -2
- data/tracks/fortran/exercises/difference-of-squares/difference_of_squares.fun +42 -0
- data/tracks/fortran/exercises/difference-of-squares/example.f90 +35 -0
- data/tracks/fortran/exercises/{hello_world → hello-world}/example.f90 +0 -0
- data/tracks/fortran/exercises/{hello_world → hello-world}/hello_world.fun +0 -0
- data/tracks/fortran/exercises/raindrops/example.f90 +26 -0
- data/tracks/fortran/exercises/raindrops/raindrops.fun +78 -0
- data/tracks/fortran/exercises/rna-transcription/example.f90 +27 -0
- data/tracks/fortran/exercises/rna-transcription/rna_transcription.fun +38 -0
- data/tracks/go/exercises/acronym/.meta/gen.go +51 -0
- data/tracks/go/exercises/acronym/acronym_test.go +1 -15
- data/tracks/go/exercises/acronym/cases_test.go +37 -0
- data/tracks/go/exercises/acronym/example.go +1 -1
- data/tracks/go/exercises/secret-handshake/.meta/gen.go +49 -0
- data/tracks/go/exercises/secret-handshake/cases_test.go +24 -0
- data/tracks/go/exercises/secret-handshake/example.go +1 -1
- data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +1 -17
- data/tracks/java/config.json +23 -23
- data/tracks/java/exercises/book-store/src/example/java/{Bookstore.java → BookStore.java} +5 -12
- data/tracks/java/exercises/book-store/src/test/java/BookStoreTest.java +113 -0
- data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +5 -4
- data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +5 -5
- data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +5 -5
- data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +10 -10
- data/tracks/purescript/config.json +7 -0
- data/tracks/purescript/exercises/hamming/bower.json +16 -0
- data/tracks/purescript/exercises/hamming/examples/src/Hamming.purs +14 -0
- data/tracks/purescript/exercises/hamming/test/Main.purs +46 -0
- data/tracks/scala/config.json +7 -0
- data/tracks/scala/exercises/bob/example.scala +3 -3
- data/tracks/scala/exercises/bob/src/main/scala/Bob.scala +2 -2
- data/tracks/scala/exercises/bob/src/test/scala/BobTest.scala +83 -53
- data/tracks/scala/exercises/book-store/build.sbt +3 -0
- data/tracks/scala/exercises/book-store/example.scala +49 -0
- data/tracks/scala/exercises/book-store/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/book-store/src/test/scala/BookStoreTest.scala +70 -0
- data/tracks/scala/exercises/difference-of-squares/example.scala +3 -3
- data/tracks/scala/exercises/difference-of-squares/src/main/scala/DifferenceOfSquares.scala +8 -0
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/DifferenceOfSquaresTest.scala +49 -0
- data/tracks/scala/exercises/leap/example.scala +4 -3
- data/tracks/scala/exercises/leap/src/main/scala/Leap.scala +2 -2
- data/tracks/scala/exercises/leap/src/test/scala/LeapTest.scala +12 -20
- data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +46 -35
- data/tracks/scala/testgen/src/main/scala/BobTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/BookStoreTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/DifferenceOfSquaresTestGenerator.scala +17 -0
- data/tracks/scala/testgen/src/main/scala/LeapTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/RaindropsTestGenerator.scala +15 -0
- data/tracks/vimscript/config.json +5 -0
- data/tracks/vimscript/exercises/triangle/example.vim +28 -0
- data/tracks/vimscript/exercises/triangle/triangle.vader +92 -0
- data/tracks/vimscript/exercises/triangle/triangle.vim +24 -0
- metadata +93 -44
- data/tracks/java/exercises/book-store/src/test/java/BookstoreTest.java +0 -119
- data/tracks/scala/exercises/difference-of-squares/src/main/scala/Squares.scala +0 -8
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/SquaresTest.scala +0 -56
@@ -5,23 +5,7 @@ import (
|
|
5
5
|
"testing"
|
6
6
|
)
|
7
7
|
|
8
|
-
const targetTestVersion =
|
9
|
-
|
10
|
-
var tests = []struct {
|
11
|
-
code uint
|
12
|
-
h []string
|
13
|
-
}{
|
14
|
-
{1, []string{"wink"}},
|
15
|
-
{2, []string{"double blink"}},
|
16
|
-
{4, []string{"close your eyes"}},
|
17
|
-
{8, []string{"jump"}},
|
18
|
-
{3, []string{"wink", "double blink"}},
|
19
|
-
{19, []string{"double blink", "wink"}},
|
20
|
-
{31, []string{"jump", "close your eyes", "double blink", "wink"}},
|
21
|
-
{0, nil},
|
22
|
-
{32, nil},
|
23
|
-
{33, []string{"wink"}},
|
24
|
-
}
|
8
|
+
const targetTestVersion = 2
|
25
9
|
|
26
10
|
func TestTestVersion(t *testing.T) {
|
27
11
|
if testVersion != targetTestVersion {
|
data/tracks/java/config.json
CHANGED
@@ -60,6 +60,11 @@
|
|
60
60
|
"difficulty": 3,
|
61
61
|
"topics": []
|
62
62
|
},
|
63
|
+
{
|
64
|
+
"slug": "perfect-numbers",
|
65
|
+
"difficulty": 3,
|
66
|
+
"topics": []
|
67
|
+
},
|
63
68
|
{
|
64
69
|
"slug": "sum-of-multiples",
|
65
70
|
"difficulty": 4,
|
@@ -105,6 +110,11 @@
|
|
105
110
|
"difficulty": 4,
|
106
111
|
"topics": []
|
107
112
|
},
|
113
|
+
{
|
114
|
+
"slug": "saddle-points",
|
115
|
+
"difficulty": 4,
|
116
|
+
"topics": []
|
117
|
+
},
|
108
118
|
{
|
109
119
|
"slug": "diamond",
|
110
120
|
"difficulty": 4,
|
@@ -271,38 +281,38 @@
|
|
271
281
|
"topics": []
|
272
282
|
},
|
273
283
|
{
|
274
|
-
"slug": "
|
275
|
-
"difficulty":
|
284
|
+
"slug": "clock",
|
285
|
+
"difficulty": 7,
|
276
286
|
"topics": []
|
277
287
|
},
|
278
288
|
{
|
279
|
-
"slug": "
|
289
|
+
"slug": "book-store",
|
280
290
|
"difficulty": 8,
|
281
291
|
"topics": []
|
282
292
|
},
|
283
293
|
{
|
284
|
-
"slug": "
|
285
|
-
"difficulty":
|
294
|
+
"slug": "simple-cipher",
|
295
|
+
"difficulty": 8,
|
286
296
|
"topics": []
|
287
297
|
},
|
288
298
|
{
|
289
|
-
"slug": "
|
290
|
-
"difficulty":
|
299
|
+
"slug": "change",
|
300
|
+
"difficulty": 8,
|
291
301
|
"topics": []
|
292
302
|
},
|
293
303
|
{
|
294
|
-
"slug": "
|
295
|
-
"difficulty":
|
304
|
+
"slug": "palindrome-products",
|
305
|
+
"difficulty": 8,
|
296
306
|
"topics": []
|
297
307
|
},
|
298
308
|
{
|
299
|
-
"slug": "
|
300
|
-
"difficulty":
|
309
|
+
"slug": "pythagorean-triplet",
|
310
|
+
"difficulty": 9,
|
301
311
|
"topics": []
|
302
312
|
},
|
303
313
|
{
|
304
|
-
"slug": "
|
305
|
-
"difficulty":
|
314
|
+
"slug": "custom-set",
|
315
|
+
"difficulty": 10,
|
306
316
|
"topics": []
|
307
317
|
},
|
308
318
|
{
|
@@ -315,16 +325,6 @@
|
|
315
325
|
"difficulty": 1,
|
316
326
|
"topics": []
|
317
327
|
},
|
318
|
-
{
|
319
|
-
"slug": "book-store",
|
320
|
-
"difficulty": 1,
|
321
|
-
"topics": []
|
322
|
-
},
|
323
|
-
{
|
324
|
-
"slug": "saddle-points",
|
325
|
-
"difficulty": 1,
|
326
|
-
"topics": []
|
327
|
-
},
|
328
328
|
{
|
329
329
|
"slug": "run-length-encoding",
|
330
330
|
"difficulty": 1,
|
@@ -2,23 +2,17 @@ import java.util.ArrayList;
|
|
2
2
|
import java.util.List;
|
3
3
|
import java.util.stream.Collectors;
|
4
4
|
|
5
|
-
class
|
5
|
+
class BookStore {
|
6
6
|
|
7
7
|
private static final int BOOK_PRICE = 8, MAX_GROUP_SIZE = 5;
|
8
8
|
|
9
9
|
private static double[] DISCOUNT_TIERS = {0, 5, 10, 20, 25};
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
Bookstore(List<Integer> books) {
|
14
|
-
this.books = books;
|
15
|
-
}
|
16
|
-
|
17
|
-
double calculateTotalCost() {
|
18
|
-
return calculateTotalCost(this.books, 0);
|
11
|
+
double calculateBasketCost(final List<Integer> books) {
|
12
|
+
return calculateBasketCost(books, 0);
|
19
13
|
}
|
20
14
|
|
21
|
-
private double
|
15
|
+
private double calculateBasketCost(final List<Integer> books, final double priceSoFar) {
|
22
16
|
if (books.size() == 0) {
|
23
17
|
return priceSoFar;
|
24
18
|
}
|
@@ -38,8 +32,7 @@ class Bookstore {
|
|
38
32
|
remainingBooks.remove(newGroupBook);
|
39
33
|
}
|
40
34
|
|
41
|
-
double price =
|
42
|
-
|
35
|
+
double price = calculateBasketCost(remainingBooks, priceSoFar + costOfGroupSize(newGroupBooks.size()));
|
43
36
|
minPrice = Math.min(minPrice, price);
|
44
37
|
}
|
45
38
|
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import static org.junit.Assert.assertEquals;
|
2
|
+
|
3
|
+
import java.util.Collections;
|
4
|
+
import java.util.List;
|
5
|
+
import java.util.Arrays;
|
6
|
+
|
7
|
+
import org.junit.Before;
|
8
|
+
import org.junit.Ignore;
|
9
|
+
import org.junit.Test;
|
10
|
+
|
11
|
+
public class BookStoreTest {
|
12
|
+
|
13
|
+
// This is sufficient accuracy since we're handling currency values, which should be equal to within 2 decimal places.
|
14
|
+
private static final double EQUALITY_TOLERANCE = 0.001;
|
15
|
+
|
16
|
+
private BookStore bookStore;
|
17
|
+
|
18
|
+
@Before
|
19
|
+
public void setUp() {
|
20
|
+
bookStore = new BookStore();
|
21
|
+
}
|
22
|
+
|
23
|
+
@Test
|
24
|
+
public void onlyASingleBook() {
|
25
|
+
List<Integer> books = Collections.singletonList(1);
|
26
|
+
assertEquals(8, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
27
|
+
}
|
28
|
+
|
29
|
+
@Ignore("Remove to run test")
|
30
|
+
@Test
|
31
|
+
public void twoOfSameBook() {
|
32
|
+
List<Integer> books = Arrays.asList(1, 1);
|
33
|
+
assertEquals(16, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
34
|
+
}
|
35
|
+
|
36
|
+
@Ignore("Remove to run test")
|
37
|
+
@Test
|
38
|
+
public void emptyBasket() {
|
39
|
+
List<Integer> books = Collections.emptyList();
|
40
|
+
assertEquals(0, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
41
|
+
}
|
42
|
+
|
43
|
+
@Ignore("Remove to run test")
|
44
|
+
@Test
|
45
|
+
public void twoDifferentBooks() {
|
46
|
+
List<Integer> books = Arrays.asList(1, 2);
|
47
|
+
assertEquals(15.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
48
|
+
}
|
49
|
+
|
50
|
+
@Ignore("Remove to run test")
|
51
|
+
@Test
|
52
|
+
public void threeDifferentBooks() {
|
53
|
+
List<Integer> books = Arrays.asList(1, 2, 3);
|
54
|
+
assertEquals(21.6, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
55
|
+
}
|
56
|
+
|
57
|
+
@Ignore("Remove to run test")
|
58
|
+
@Test
|
59
|
+
public void fourDifferentBooks() {
|
60
|
+
List<Integer> books = Arrays.asList(1, 2, 3, 4);
|
61
|
+
assertEquals(25.6, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
62
|
+
}
|
63
|
+
|
64
|
+
@Ignore("Remove to run test")
|
65
|
+
@Test
|
66
|
+
public void fiveDifferentBooks() {
|
67
|
+
List<Integer> books = Arrays.asList(1, 2, 3, 4, 5);
|
68
|
+
assertEquals(30, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
69
|
+
}
|
70
|
+
|
71
|
+
@Ignore("Remove to run test")
|
72
|
+
@Test
|
73
|
+
public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() {
|
74
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5);
|
75
|
+
assertEquals(51.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
76
|
+
}
|
77
|
+
|
78
|
+
@Ignore("Remove to run test")
|
79
|
+
@Test
|
80
|
+
public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() {
|
81
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 4);
|
82
|
+
assertEquals(40.8, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
83
|
+
}
|
84
|
+
|
85
|
+
@Ignore("Remove to run test")
|
86
|
+
@Test
|
87
|
+
public void twoEachOfFirst4BooksAnd1CopyEachOfRest() {
|
88
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5);
|
89
|
+
assertEquals(55.60, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
90
|
+
}
|
91
|
+
|
92
|
+
@Ignore("Remove to run test")
|
93
|
+
@Test
|
94
|
+
public void twoCopiesOfEachBook() {
|
95
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5);
|
96
|
+
assertEquals(60.00, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
97
|
+
}
|
98
|
+
|
99
|
+
@Ignore("Remove to run test")
|
100
|
+
@Test
|
101
|
+
public void threeCopiesOfFirstBookAnd2EachOfRemaining() {
|
102
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1);
|
103
|
+
assertEquals(68.00, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
104
|
+
}
|
105
|
+
|
106
|
+
@Ignore("Remove to run test")
|
107
|
+
@Test
|
108
|
+
public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() {
|
109
|
+
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2);
|
110
|
+
assertEquals(75.20, bookStore.calculateBasketCost(books), EQUALITY_TOLERANCE);
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import java.util.ArrayList;
|
2
1
|
import java.util.Collections;
|
2
|
+
import java.util.HashSet;
|
3
3
|
import java.util.List;
|
4
|
+
import java.util.Set;
|
4
5
|
|
5
6
|
final class Matrix {
|
6
7
|
|
@@ -10,8 +11,8 @@ final class Matrix {
|
|
10
11
|
this.values = values;
|
11
12
|
}
|
12
13
|
|
13
|
-
|
14
|
-
final
|
14
|
+
Set<MatrixCoordinate> getSaddlePoints() {
|
15
|
+
final Set<MatrixCoordinate> result = new HashSet<>();
|
15
16
|
|
16
17
|
if (values.isEmpty()) {
|
17
18
|
return result;
|
@@ -38,7 +39,7 @@ final class Matrix {
|
|
38
39
|
return values.stream()
|
39
40
|
.map(row -> row.get(column))
|
40
41
|
.min(Integer::compareTo)
|
41
|
-
.
|
42
|
+
.orElseThrow(() -> new IllegalArgumentException("Column cannot be empty"));
|
42
43
|
}
|
43
44
|
|
44
45
|
}
|
@@ -2,11 +2,11 @@ final class MatrixCoordinate {
|
|
2
2
|
|
3
3
|
private final int row;
|
4
4
|
|
5
|
-
private final int
|
5
|
+
private final int col;
|
6
6
|
|
7
|
-
MatrixCoordinate(final int row, final int
|
7
|
+
MatrixCoordinate(final int row, final int col) {
|
8
8
|
this.row = row;
|
9
|
-
this.
|
9
|
+
this.col = col;
|
10
10
|
}
|
11
11
|
|
12
12
|
// Generated equals and hashcode.
|
@@ -18,13 +18,13 @@ final class MatrixCoordinate {
|
|
18
18
|
|
19
19
|
final MatrixCoordinate that = (MatrixCoordinate) o;
|
20
20
|
|
21
|
-
return row == that.row &&
|
21
|
+
return row == that.row && col == that.col;
|
22
22
|
}
|
23
23
|
|
24
24
|
@Override
|
25
25
|
public int hashCode() {
|
26
26
|
int result = row;
|
27
|
-
result = 31 * result +
|
27
|
+
result = 31 * result + col;
|
28
28
|
return result;
|
29
29
|
}
|
30
30
|
|
@@ -2,11 +2,11 @@ final class MatrixCoordinate {
|
|
2
2
|
|
3
3
|
private final int row;
|
4
4
|
|
5
|
-
private final int
|
5
|
+
private final int col;
|
6
6
|
|
7
|
-
MatrixCoordinate(final int row, final int
|
7
|
+
MatrixCoordinate(final int row, final int col) {
|
8
8
|
this.row = row;
|
9
|
-
this.
|
9
|
+
this.col = col;
|
10
10
|
}
|
11
11
|
|
12
12
|
// Generated equals and hashcode.
|
@@ -18,13 +18,13 @@ final class MatrixCoordinate {
|
|
18
18
|
|
19
19
|
final MatrixCoordinate that = (MatrixCoordinate) o;
|
20
20
|
|
21
|
-
return row == that.row &&
|
21
|
+
return row == that.row && col == that.col;
|
22
22
|
}
|
23
23
|
|
24
24
|
@Override
|
25
25
|
public int hashCode() {
|
26
26
|
int result = row;
|
27
|
-
result = 31 * result +
|
27
|
+
result = 31 * result + col;
|
28
28
|
return result;
|
29
29
|
}
|
30
30
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import org.junit.Ignore;
|
2
2
|
import org.junit.Test;
|
3
3
|
|
4
|
-
import java.util
|
5
|
-
import java.util.Arrays;
|
6
|
-
import java.util.Collections;
|
7
|
-
import java.util.List;
|
4
|
+
import java.util.*;
|
8
5
|
|
9
6
|
import static org.junit.Assert.assertEquals;
|
10
7
|
|
8
|
+
/*
|
9
|
+
* version: 1.0.0
|
10
|
+
*/
|
11
11
|
public class MatrixTest {
|
12
12
|
|
13
13
|
@Test
|
@@ -18,7 +18,7 @@ public class MatrixTest {
|
|
18
18
|
Arrays.asList(6, 6, 7)
|
19
19
|
));
|
20
20
|
|
21
|
-
|
21
|
+
Set<MatrixCoordinate> expectedSaddlePoints = Collections.singleton(new MatrixCoordinate(1, 0));
|
22
22
|
|
23
23
|
assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
24
24
|
}
|
@@ -28,7 +28,7 @@ public class MatrixTest {
|
|
28
28
|
public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() {
|
29
29
|
Matrix matrix = new Matrix(new ArrayList<>());
|
30
30
|
|
31
|
-
|
31
|
+
Set<MatrixCoordinate> expectedSaddlePoints = Collections.emptySet();
|
32
32
|
|
33
33
|
assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
34
34
|
}
|
@@ -42,7 +42,7 @@ public class MatrixTest {
|
|
42
42
|
Arrays.asList(2, 3, 1)
|
43
43
|
));
|
44
44
|
|
45
|
-
|
45
|
+
Set<MatrixCoordinate> expectedSaddlePoints = Collections.emptySet();
|
46
46
|
|
47
47
|
assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
48
48
|
}
|
@@ -56,11 +56,11 @@ public class MatrixTest {
|
|
56
56
|
Arrays.asList(1, 5, 4)
|
57
57
|
));
|
58
58
|
|
59
|
-
|
59
|
+
Set<MatrixCoordinate> expectedSaddlePoints = new HashSet<>(Arrays.asList(
|
60
60
|
new MatrixCoordinate(0, 1),
|
61
61
|
new MatrixCoordinate(1, 1),
|
62
62
|
new MatrixCoordinate(2, 1)
|
63
|
-
);
|
63
|
+
));
|
64
64
|
|
65
65
|
assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
66
66
|
}
|
@@ -74,7 +74,7 @@ public class MatrixTest {
|
|
74
74
|
Arrays.asList(3, 2, 5)
|
75
75
|
));
|
76
76
|
|
77
|
-
|
77
|
+
Set<MatrixCoordinate> expectedSaddlePoints = Collections.singleton(new MatrixCoordinate(2, 2));
|
78
78
|
|
79
79
|
assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
80
80
|
}
|