trackler 2.2.1.15 → 2.2.1.16
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/TOPICS.txt +8 -1
- data/tracks/c/docs/SNIPPET.txt +11 -0
- data/tracks/ceylon/docs/SNIPPET.txt +3 -0
- data/tracks/clojure/docs/SNIPPET.txt +5 -0
- data/tracks/csharp/build.cake +23 -16
- data/tracks/csharp/build.ps1 +1 -1
- data/tracks/csharp/build.sh +1 -1
- data/tracks/csharp/exercises/pangram/PangramTest.cs +9 -18
- data/tracks/csharp/generators/.gitignore +2 -1
- data/tracks/csharp/generators/Exercise.cs +11 -12
- data/tracks/csharp/generators/Exercises/AllYourBase.cs +2 -2
- data/tracks/csharp/generators/Exercises/Allergies.cs +1 -1
- data/tracks/csharp/generators/Exercises/Alphametics.cs +1 -1
- data/tracks/csharp/generators/Exercises/Anagram.cs +1 -1
- data/tracks/csharp/generators/Exercises/BeerSong.cs +1 -1
- data/tracks/csharp/generators/Exercises/BinarySearch.cs +1 -1
- data/tracks/csharp/generators/Exercises/BookStore.cs +1 -1
- data/tracks/csharp/generators/Exercises/BracketPush.cs +1 -1
- data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +2 -2
- data/tracks/csharp/generators/Exercises/CryptoSquare.cs +1 -1
- data/tracks/csharp/generators/Exercises/FoodChain.cs +1 -1
- data/tracks/csharp/generators/Exercises/Gigasecond.cs +1 -1
- data/tracks/csharp/generators/Exercises/Hamming.cs +1 -1
- data/tracks/csharp/generators/Exercises/House.cs +1 -1
- data/tracks/csharp/generators/Exercises/Leap.cs +1 -1
- data/tracks/csharp/generators/Exercises/Luhn.cs +1 -1
- data/tracks/csharp/generators/Exercises/NthPrime.cs +1 -1
- data/tracks/csharp/generators/Exercises/Pangram.cs +1 -11
- data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +1 -1
- data/tracks/csharp/generators/Exercises/PhoneNumber.cs +1 -1
- data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +1 -1
- data/tracks/csharp/generators/Exercises/RnaTranscription.cs +1 -1
- data/tracks/csharp/generators/Exercises/RomanNumerals.cs +1 -1
- data/tracks/csharp/generators/Exercises/RunLengthEncoding.cs +1 -1
- data/tracks/csharp/generators/Exercises/Say.cs +2 -7
- data/tracks/csharp/generators/Exercises/SecretHandshake.cs +1 -1
- data/tracks/csharp/generators/Exercises/Sieve.cs +1 -1
- data/tracks/csharp/generators/Exercises/SpaceAge.cs +1 -1
- data/tracks/csharp/generators/Exercises/SumOfMultiples.cs +1 -1
- data/tracks/csharp/generators/Exercises/Transpose.cs +1 -1
- data/tracks/csharp/generators/Exercises/WordCount.cs +1 -1
- data/tracks/csharp/generators/Exercises/Wordy.cs +1 -1
- data/tracks/csharp/generators/Output/FormattingExtensions.cs +4 -2
- data/tracks/csharp/generators/Output/ValueFormatter.cs +1 -1
- data/tracks/delphi/docs/SNIPPET.txt +6 -13
- data/tracks/ecmascript/docs/SNIPPET.txt +7 -0
- data/tracks/elisp/docs/SNIPPET.txt +13 -0
- data/tracks/elixir/config.json +2 -2
- data/tracks/elixir/docs/SNIPPET.txt +10 -0
- data/tracks/erlang/docs/SNIPPET.txt +8 -0
- data/tracks/fsharp/docs/SNIPPET.txt +3 -0
- data/tracks/go/config.json +174 -174
- data/tracks/go/config/maintainers.json +6 -9
- data/tracks/go/docs/SNIPPET.txt +6 -0
- data/tracks/groovy/config.json +4 -4
- data/tracks/groovy/docs/SNIPPET.txt +12 -0
- data/tracks/haskell/config.json +2 -0
- data/tracks/haskell/docs/SNIPPET.txt +4 -0
- data/tracks/java/docs/SNIPPET.txt +7 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +21 -16
- data/tracks/java/exercises/robot-simulator/src/test/java/RobotTest.java +24 -24
- data/tracks/javascript/docs/SNIPPET.txt +10 -0
- data/tracks/kotlin/docs/SNIPPET.txt +3 -0
- data/tracks/kotlin/exercises/change/src/example/kotlin/ChangeCalculator.kt +35 -0
- data/tracks/kotlin/exercises/change/src/test/kotlin/ChangeCalculatorTest.kt +105 -0
- data/tracks/lfe/docs/SNIPPET.txt +12 -0
- data/tracks/lua/docs/SNIPPET.txt +7 -0
- data/tracks/mips/docs/SNIPPET.txt +23 -0
- data/tracks/ocaml/docs/SNIPPET.txt +1 -0
- data/tracks/purescript/config.json +1 -1
- data/tracks/purescript/docs/SNIPPET.txt +8 -0
- data/tracks/python/exercises/saddle-points/README.md +1 -1
- data/tracks/racket/docs/SNIPPET.txt +6 -0
- data/tracks/ruby/docs/SNIPPET.txt +5 -0
- data/tracks/rust/docs/SNIPPET.txt +3 -0
- data/tracks/scala/docs/SNIPPET.txt +4 -0
- data/tracks/scala/exercises/ocr-numbers/example.scala +17 -11
- data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrNumbersTest.scala +153 -0
- data/tracks/scala/exercises/pig-latin/example.scala +11 -6
- data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +80 -10
- data/tracks/scala/testgen/src/main/scala/OcrNumbersTestGenerator.scala +34 -0
- data/tracks/scala/testgen/src/main/scala/PigLatinTestGenerator.scala +16 -0
- data/tracks/scheme/docs/SNIPPET.txt +7 -0
- data/tracks/sml/bin/generate +277 -0
- data/tracks/sml/config.json +30 -0
- data/tracks/sml/docs/ABOUT.md +32 -0
- data/tracks/sml/docs/LEARNING.md +37 -0
- data/tracks/sml/docs/SNIPPET.txt +3 -0
- data/tracks/sml/exercises/bob/README.md +48 -0
- data/tracks/sml/exercises/bob/bob.sml +2 -0
- data/tracks/sml/exercises/bob/example.sml +22 -0
- data/tracks/sml/exercises/bob/test.sml +87 -0
- data/tracks/sml/exercises/bob/testlib.sml +159 -0
- data/tracks/sml/exercises/difference-of-squares/README.md +49 -0
- data/tracks/sml/exercises/difference-of-squares/difference-of-squares.sml +8 -0
- data/tracks/sml/exercises/difference-of-squares/example.sml +11 -0
- data/tracks/sml/exercises/difference-of-squares/test.sml +45 -0
- data/tracks/sml/exercises/difference-of-squares/testlib.sml +159 -0
- data/tracks/sml/exercises/hello-world/README.md +51 -0
- data/tracks/sml/exercises/hello-world/example.sml +1 -0
- data/tracks/sml/exercises/hello-world/hello-world.sml +2 -0
- data/tracks/sml/exercises/hello-world/test.sml +15 -0
- data/tracks/sml/exercises/hello-world/testlib.sml +159 -0
- data/tracks/sml/lib/testlib.sml +159 -0
- data/tracks/swift/docs/SNIPPET.txt +9 -0
- data/tracks/typescript/docs/SNIPPET.txt +8 -0
- metadata +53 -6
- data/tracks/csharp/generators/Generators.csproj.user +0 -6
- data/tracks/kotlin/exercises/change/src/example/kotlin/Change.kt +0 -70
- data/tracks/kotlin/exercises/change/src/test/kotlin/ChangeTest.kt +0 -55
- data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +0 -138
@@ -15,17 +15,14 @@
|
|
15
15
|
"alumnus": true,
|
16
16
|
"bio": "I love Go for its simplicity and consistency. I also appreciate how hard the Go project is working to make the ecosystem welcoming to newcomers. I no longer maintain the Go track, but still maintain the Go tooling on Exercism.",
|
17
17
|
"github_username": "kytrinyx",
|
18
|
-
"name": "Katrina Owen"
|
18
|
+
"name": "Katrina Owen",
|
19
|
+
"show_on_website": true
|
19
20
|
},
|
20
21
|
{
|
21
|
-
"alumnus":
|
22
|
-
"
|
23
|
-
"bio": null,
|
22
|
+
"alumnus": true,
|
23
|
+
"bio": "I write a lot of Go for my day job, building platforms for other software engineers to use. The Exercism Go track was the first open-source project I joined; I'm grateful for all I've learned through this experience.",
|
24
24
|
"github_username": "petertseng",
|
25
|
-
"
|
26
|
-
"link_url": null,
|
27
|
-
"name": null,
|
28
|
-
"show_on_website": false
|
25
|
+
"show_on_website": true
|
29
26
|
},
|
30
27
|
{
|
31
28
|
"alumnus": false,
|
@@ -75,4 +72,4 @@
|
|
75
72
|
"show_on_website": true
|
76
73
|
}
|
77
74
|
]
|
78
|
-
}
|
75
|
+
}
|
data/tracks/groovy/config.json
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
"unlocked_by": null,
|
45
45
|
"difficulty": 3,
|
46
46
|
"topics": [
|
47
|
-
"
|
47
|
+
"mathematics",
|
48
48
|
"strings"
|
49
49
|
]
|
50
50
|
},
|
@@ -65,7 +65,7 @@
|
|
65
65
|
"unlocked_by": null,
|
66
66
|
"difficulty": 2,
|
67
67
|
"topics": [
|
68
|
-
"
|
68
|
+
"mathematics"
|
69
69
|
]
|
70
70
|
},
|
71
71
|
{
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"unlocked_by": null,
|
97
97
|
"difficulty": 4,
|
98
98
|
"topics": [
|
99
|
-
"
|
99
|
+
"mathematics"
|
100
100
|
]
|
101
101
|
},
|
102
102
|
{
|
@@ -127,7 +127,7 @@
|
|
127
127
|
"unlocked_by": null,
|
128
128
|
"difficulty": 2,
|
129
129
|
"topics": [
|
130
|
-
"
|
130
|
+
"mathematics"
|
131
131
|
]
|
132
132
|
},
|
133
133
|
{
|
data/tracks/haskell/config.json
CHANGED
@@ -9,21 +9,26 @@ final class GridPosition {
|
|
9
9
|
this.y = y;
|
10
10
|
}
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
12
|
+
@Override
|
13
|
+
public int hashCode() {
|
14
|
+
final int prime = 31;
|
15
|
+
int result = 1;
|
16
|
+
result = prime * result + x;
|
17
|
+
result = prime * result + y;
|
18
|
+
return result;
|
19
|
+
}
|
20
|
+
|
21
|
+
@Override
|
22
|
+
public boolean equals(Object obj) {
|
23
|
+
if (this == obj) {
|
24
|
+
return true;
|
25
|
+
} else if (obj == null || getClass() != obj.getClass()) {
|
26
|
+
return false;
|
27
|
+
} else if (x != ((GridPosition) obj).x || y != ((GridPosition)obj).y) {
|
28
|
+
return false;
|
29
|
+
} else {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
}
|
28
33
|
|
29
34
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import org.junit.Ignore;
|
2
2
|
import org.junit.Test;
|
3
3
|
|
4
|
-
import static org.junit.Assert.
|
4
|
+
import static org.junit.Assert.assertEquals;
|
5
5
|
|
6
6
|
public class RobotTest {
|
7
7
|
|
@@ -10,7 +10,7 @@ public class RobotTest {
|
|
10
10
|
final GridPosition initialGridPosition = new GridPosition(0, 0);
|
11
11
|
final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
12
12
|
|
13
|
-
|
13
|
+
assertEquals(robot.getGridPosition(), initialGridPosition);
|
14
14
|
}
|
15
15
|
|
16
16
|
@Ignore("Remove to run test")
|
@@ -19,7 +19,7 @@ public class RobotTest {
|
|
19
19
|
final Orientation initialOrientation = Orientation.NORTH;
|
20
20
|
final Robot robot = new Robot(new GridPosition(0, 0), initialOrientation);
|
21
21
|
|
22
|
-
|
22
|
+
assertEquals(robot.getOrientation(), initialOrientation);
|
23
23
|
}
|
24
24
|
|
25
25
|
@Ignore("Remove to run test")
|
@@ -30,7 +30,7 @@ public class RobotTest {
|
|
30
30
|
|
31
31
|
robot.turnRight();
|
32
32
|
|
33
|
-
|
33
|
+
assertEquals(robot.getGridPosition(), initialGridPosition);
|
34
34
|
}
|
35
35
|
|
36
36
|
@Ignore("Remove to run test")
|
@@ -42,7 +42,7 @@ public class RobotTest {
|
|
42
42
|
|
43
43
|
final Orientation expectedOrientation = Orientation.EAST;
|
44
44
|
|
45
|
-
|
45
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
46
46
|
}
|
47
47
|
|
48
48
|
@Ignore("Remove to run test")
|
@@ -54,7 +54,7 @@ public class RobotTest {
|
|
54
54
|
|
55
55
|
final Orientation expectedOrientation = Orientation.SOUTH;
|
56
56
|
|
57
|
-
|
57
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
58
58
|
}
|
59
59
|
|
60
60
|
@Ignore("Remove to run test")
|
@@ -66,7 +66,7 @@ public class RobotTest {
|
|
66
66
|
|
67
67
|
final Orientation expectedOrientation = Orientation.WEST;
|
68
68
|
|
69
|
-
|
69
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
70
70
|
}
|
71
71
|
|
72
72
|
@Ignore("Remove to run test")
|
@@ -78,7 +78,7 @@ public class RobotTest {
|
|
78
78
|
|
79
79
|
final Orientation expectedOrientation = Orientation.NORTH;
|
80
80
|
|
81
|
-
|
81
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
82
82
|
}
|
83
83
|
|
84
84
|
@Ignore("Remove to run test")
|
@@ -89,7 +89,7 @@ public class RobotTest {
|
|
89
89
|
|
90
90
|
robot.turnLeft();
|
91
91
|
|
92
|
-
|
92
|
+
assertEquals(robot.getGridPosition(), initialGridPosition);
|
93
93
|
}
|
94
94
|
|
95
95
|
@Ignore("Remove to run test")
|
@@ -101,7 +101,7 @@ public class RobotTest {
|
|
101
101
|
|
102
102
|
final Orientation expectedOrientation = Orientation.WEST;
|
103
103
|
|
104
|
-
|
104
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
105
105
|
}
|
106
106
|
|
107
107
|
@Ignore("Remove to run test")
|
@@ -113,7 +113,7 @@ public class RobotTest {
|
|
113
113
|
|
114
114
|
final Orientation expectedOrientation = Orientation.SOUTH;
|
115
115
|
|
116
|
-
|
116
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
117
117
|
}
|
118
118
|
|
119
119
|
@Ignore("Remove to run test")
|
@@ -125,7 +125,7 @@ public class RobotTest {
|
|
125
125
|
|
126
126
|
final Orientation expectedOrientation = Orientation.EAST;
|
127
127
|
|
128
|
-
|
128
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
129
129
|
}
|
130
130
|
|
131
131
|
@Ignore("Remove to run test")
|
@@ -137,7 +137,7 @@ public class RobotTest {
|
|
137
137
|
|
138
138
|
final Orientation expectedOrientation = Orientation.NORTH;
|
139
139
|
|
140
|
-
|
140
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
141
141
|
}
|
142
142
|
|
143
143
|
@Ignore("Remove to run test")
|
@@ -148,7 +148,7 @@ public class RobotTest {
|
|
148
148
|
|
149
149
|
robot.advance();
|
150
150
|
|
151
|
-
|
151
|
+
assertEquals(robot.getOrientation(), initialOrientation);
|
152
152
|
}
|
153
153
|
|
154
154
|
@Ignore("Remove to run test")
|
@@ -160,7 +160,7 @@ public class RobotTest {
|
|
160
160
|
|
161
161
|
final GridPosition expectedGridPosition = new GridPosition(0, 1);
|
162
162
|
|
163
|
-
|
163
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
164
164
|
}
|
165
165
|
|
166
166
|
@Ignore("Remove to run test")
|
@@ -172,7 +172,7 @@ public class RobotTest {
|
|
172
172
|
|
173
173
|
final GridPosition expectedGridPosition = new GridPosition(0, -1);
|
174
174
|
|
175
|
-
|
175
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
176
176
|
}
|
177
177
|
|
178
178
|
@Ignore("Remove to run test")
|
@@ -184,7 +184,7 @@ public class RobotTest {
|
|
184
184
|
|
185
185
|
final GridPosition expectedGridPosition = new GridPosition(1, 0);
|
186
186
|
|
187
|
-
|
187
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
188
188
|
}
|
189
189
|
|
190
190
|
@Ignore("Remove to run test")
|
@@ -196,7 +196,7 @@ public class RobotTest {
|
|
196
196
|
|
197
197
|
final GridPosition expectedGridPosition = new GridPosition(-1, 0);
|
198
198
|
|
199
|
-
|
199
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
200
200
|
}
|
201
201
|
|
202
202
|
@Ignore("Remove to run test")
|
@@ -209,8 +209,8 @@ public class RobotTest {
|
|
209
209
|
final GridPosition expectedGridPosition = new GridPosition(-4, 1);
|
210
210
|
final Orientation expectedOrientation = Orientation.WEST;
|
211
211
|
|
212
|
-
|
213
|
-
|
212
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
213
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
214
214
|
}
|
215
215
|
|
216
216
|
@Ignore("Remove to run test")
|
@@ -223,8 +223,8 @@ public class RobotTest {
|
|
223
223
|
final GridPosition expectedGridPosition = new GridPosition(-3, -8);
|
224
224
|
final Orientation expectedOrientation = Orientation.SOUTH;
|
225
225
|
|
226
|
-
|
227
|
-
|
226
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
227
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
228
228
|
}
|
229
229
|
|
230
230
|
@Ignore("Remove to run test")
|
@@ -237,8 +237,8 @@ public class RobotTest {
|
|
237
237
|
final GridPosition expectedGridPosition = new GridPosition(11, 5);
|
238
238
|
final Orientation expectedOrientation = Orientation.NORTH;
|
239
239
|
|
240
|
-
|
241
|
-
|
240
|
+
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
241
|
+
assertEquals(robot.getOrientation(), expectedOrientation);
|
242
242
|
}
|
243
243
|
|
244
244
|
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class ChangeCalculator(coins: List<Int>) {
|
2
|
+
|
3
|
+
private val sortedCoins = coins.sorted()
|
4
|
+
|
5
|
+
fun computeMostEfficientChange(grandTotal: Int): List<Int> {
|
6
|
+
require(grandTotal >= 0) { "Negative totals are not allowed." }
|
7
|
+
|
8
|
+
val minimalCoinsMap = mutableMapOf<Int, List<Int>?>()
|
9
|
+
minimalCoinsMap.put(0, ArrayList())
|
10
|
+
|
11
|
+
for (total in 1..grandTotal) {
|
12
|
+
val minimalCoins = sortedCoins
|
13
|
+
.filter { it <= total }
|
14
|
+
.mapNotNull { coin ->
|
15
|
+
val minimalRemainderCoins = minimalCoinsMap[total - coin]
|
16
|
+
if (minimalRemainderCoins != null) prepend(coin, minimalRemainderCoins) else null
|
17
|
+
}
|
18
|
+
.sortedBy { it.size }
|
19
|
+
.firstOrNull()
|
20
|
+
|
21
|
+
minimalCoinsMap.put(total, minimalCoins)
|
22
|
+
}
|
23
|
+
|
24
|
+
return minimalCoinsMap[grandTotal] ?: throw IllegalArgumentException(
|
25
|
+
"The total $grandTotal cannot be represented in the given currency.")
|
26
|
+
}
|
27
|
+
|
28
|
+
private fun prepend(integer: Int, integers: List<Int>): List<Int> {
|
29
|
+
val result = mutableListOf<Int>()
|
30
|
+
result.add(integer)
|
31
|
+
result.addAll(integers)
|
32
|
+
return result
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import org.assertj.core.api.Assertions.assertThat
|
2
|
+
import org.junit.Ignore
|
3
|
+
import org.junit.Rule
|
4
|
+
import org.junit.Test
|
5
|
+
import org.junit.rules.ExpectedException
|
6
|
+
|
7
|
+
/*
|
8
|
+
* version: 1.1.0
|
9
|
+
*/
|
10
|
+
class ChangeCalculatorTest {
|
11
|
+
|
12
|
+
@Rule
|
13
|
+
@JvmField
|
14
|
+
var expectedException: ExpectedException = ExpectedException.none()
|
15
|
+
|
16
|
+
@Test
|
17
|
+
fun singleCoinChange() {
|
18
|
+
val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(25)
|
19
|
+
assertThat(computedChange).containsExactly(25)
|
20
|
+
}
|
21
|
+
|
22
|
+
@Ignore
|
23
|
+
@Test
|
24
|
+
fun multipleCoinChange() {
|
25
|
+
val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(15)
|
26
|
+
assertThat(computedChange).containsExactly(5, 10)
|
27
|
+
}
|
28
|
+
|
29
|
+
@Ignore
|
30
|
+
@Test
|
31
|
+
fun changeWithLilliputianCoins() {
|
32
|
+
val computedChange = ChangeCalculator(listOf(1, 4, 15, 20, 50)).computeMostEfficientChange(23)
|
33
|
+
assertThat(computedChange).containsExactly(4, 4, 15)
|
34
|
+
}
|
35
|
+
|
36
|
+
@Ignore
|
37
|
+
@Test
|
38
|
+
fun changeWithLowerElboniaCoins() {
|
39
|
+
val computedChange = ChangeCalculator(listOf(1, 5, 10, 21, 25)).computeMostEfficientChange(63)
|
40
|
+
assertThat(computedChange).containsExactly(21, 21, 21)
|
41
|
+
}
|
42
|
+
|
43
|
+
@Ignore
|
44
|
+
@Test
|
45
|
+
fun largeTargetValues() {
|
46
|
+
val computedChange = ChangeCalculator(listOf(1, 2, 5, 10, 20, 50, 100)).computeMostEfficientChange(999)
|
47
|
+
assertThat(computedChange)
|
48
|
+
.containsExactly(2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100)
|
49
|
+
}
|
50
|
+
|
51
|
+
@Ignore
|
52
|
+
@Test
|
53
|
+
fun possibleChangeWithoutUnitCoinsAvailable() {
|
54
|
+
val computedChange = ChangeCalculator(listOf(2, 5, 10, 20, 50)).computeMostEfficientChange(21)
|
55
|
+
assertThat(computedChange).containsExactly(2, 2, 2, 5, 10)
|
56
|
+
}
|
57
|
+
|
58
|
+
@Ignore
|
59
|
+
@Test
|
60
|
+
fun anotherPossibleChangeWithoutUnitCoinsAvailable() {
|
61
|
+
val computedChange = ChangeCalculator(listOf(4, 5)).computeMostEfficientChange(27)
|
62
|
+
assertThat(computedChange).containsExactly(4, 4, 4, 5, 5, 5)
|
63
|
+
}
|
64
|
+
|
65
|
+
@Ignore
|
66
|
+
@Test
|
67
|
+
fun noCoinsMake0Change() {
|
68
|
+
val computedChange = ChangeCalculator(listOf(1, 5, 10, 21, 25)).computeMostEfficientChange(0)
|
69
|
+
assertThat(computedChange).isEmpty()
|
70
|
+
}
|
71
|
+
|
72
|
+
@Ignore
|
73
|
+
@Test
|
74
|
+
fun errorTestingForChangeSmallerThanTheSmallestCoin() {
|
75
|
+
val changeCalculator = ChangeCalculator(listOf(5, 10))
|
76
|
+
|
77
|
+
expectedException.expect(IllegalArgumentException::class.java)
|
78
|
+
expectedException.expectMessage("The total 3 cannot be represented in the given currency.")
|
79
|
+
|
80
|
+
changeCalculator.computeMostEfficientChange(3)
|
81
|
+
}
|
82
|
+
|
83
|
+
@Ignore
|
84
|
+
@Test
|
85
|
+
fun errorIfNoCombinationCanAddUpToTarget() {
|
86
|
+
val changeCalculator = ChangeCalculator(listOf(5, 10))
|
87
|
+
|
88
|
+
expectedException.expect(IllegalArgumentException::class.java)
|
89
|
+
expectedException.expectMessage("The total 94 cannot be represented in the given currency.")
|
90
|
+
|
91
|
+
changeCalculator.computeMostEfficientChange(94)
|
92
|
+
}
|
93
|
+
|
94
|
+
@Ignore
|
95
|
+
@Test
|
96
|
+
fun cannotFindNegativeChangeValues() {
|
97
|
+
val changeCalculator = ChangeCalculator(listOf(1, 2, 5))
|
98
|
+
|
99
|
+
expectedException.expect(IllegalArgumentException::class.java)
|
100
|
+
expectedException.expectMessage("Negative totals are not allowed.")
|
101
|
+
|
102
|
+
changeCalculator.computeMostEfficientChange(-5)
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|