trackler 2.1.0.22 → 2.1.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/elm/exercises/accumulate/Tests.elm +1 -1
  4. data/tracks/elm/exercises/pangram/Tests.elm +4 -0
  5. data/tracks/kotlin/bin/journey-test.sh +2 -0
  6. data/tracks/kotlin/config.json +19 -0
  7. data/tracks/kotlin/exercises/all-your-base/build.gradle +28 -0
  8. data/tracks/kotlin/exercises/all-your-base/src/example/kotlin/BaseConverter.kt +59 -0
  9. data/tracks/kotlin/exercises/all-your-base/src/main/kotlin/.keep +0 -0
  10. data/tracks/kotlin/exercises/all-your-base/src/test/kotlin/BaseConverterTest.kt +250 -0
  11. data/tracks/kotlin/exercises/clock/build.gradle +28 -0
  12. data/tracks/kotlin/exercises/clock/src/example/kotlin/Clock.kt +40 -0
  13. data/tracks/kotlin/exercises/clock/src/main/kotlin/.keep +0 -0
  14. data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockAddTest.kt +138 -0
  15. data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockCreationTest.kt +123 -0
  16. data/tracks/kotlin/exercises/clock/src/test/kotlin/ClockEqualTest.kt +101 -0
  17. data/tracks/kotlin/exercises/settings.gradle +3 -0
  18. data/tracks/kotlin/exercises/sum-of-multiples/build.gradle +29 -0
  19. data/tracks/kotlin/exercises/sum-of-multiples/src/example/kotlin/SumOfMultiples.kt +7 -0
  20. data/tracks/kotlin/exercises/sum-of-multiples/src/main/kotlin/.keep +0 -0
  21. data/tracks/kotlin/exercises/sum-of-multiples/src/test/kotlin/SumOfMultiplesTest.kt +84 -0
  22. data/tracks/python/exercises/grade-school/grade_school_test.py +2 -2
  23. data/tracks/vimscript/config.json +1 -1
  24. metadata +16 -3
  25. data/tracks/java/.github/stale.yml +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbced8992b854c512c715f27a6bc9901d2970782
4
- data.tar.gz: ce15baa96319c1f0824907c901ad918fa8927a4f
3
+ metadata.gz: a5a1f4bc1094d7cab6ba4f22a20e28874665bbb9
4
+ data.tar.gz: 66cd048370d77f78ffdfef48b573fe302129e99a
5
5
  SHA512:
6
- metadata.gz: d477788c1072990660270c29a37920b0eabafb79b08cdefc7e514ad5e24e42e56e84f4bc6e87864ee27b8617244553fdac941a17337a2cafb7c2c8fd3136f6a9
7
- data.tar.gz: 934f4fa9ed27cddbf3077ee3b6ccfc18a65f322ccd1cce7656aeb94a07f9def5c3d96533e2189c8153f2d9763b2f07654dd7f2272c7bd800eacfc844112e68e2
6
+ metadata.gz: d0632cd9d571b3d6f1a604b748380d1b6ba4b3f6501970f4bac7c84361a0ef0ede21d9e0b118968e9daa04dde82fd11619a6edf9cee61e18f0234ea691b9935e
7
+ data.tar.gz: 3cd5cc5489046c92b192e7955f0c0a18be47eecf3b3c88735a5ba483fc2675027d52f2fca726f51253cdec7fe3c30951e6a10e63baadb47c0d11caef7117db45
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.1.0.22"
2
+ VERSION = "2.1.0.23"
3
3
  end
@@ -16,7 +16,7 @@ square x =
16
16
  tests : Test
17
17
  tests =
18
18
  describe "Accumulate"
19
- [ test "[]] Accumulate" <|
19
+ [ test "[] Accumulate" <|
20
20
  \() -> Expect.equal [] (accumulate square [])
21
21
  , test "square Accumulate" <|
22
22
  \() -> Expect.equal [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ])
@@ -22,6 +22,10 @@ tests =
22
22
  \() ->
23
23
  Expect.equal False
24
24
  (isPangram "a quick movement of the enemy will jeopardize five gunboats")
25
+ , test "missing character 'z'" <|
26
+ \() ->
27
+ Expect.equal False
28
+ (isPangram "a quick movement of the enemy will jeopardixe five gunboats")
25
29
  , test "another missing character 'x'" <|
26
30
  \() ->
27
31
  Expect.equal False
@@ -214,6 +214,8 @@ solve_all_exercises() {
214
214
  cp -R -H ${track_root}/exercises/${exercise}/src/example/${TRACK}/* ${exercism_exercises_dir}/${TRACK}/${exercise}/src/main/${TRACK}/
215
215
 
216
216
  pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
217
+ # Check that tests compile before we strip @Ignore annotations
218
+ gradle compileTestJava
217
219
  # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
218
220
  for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
219
221
  sed 's/@Ignore//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
@@ -228,11 +228,30 @@
228
228
  "slug": "change",
229
229
  "topics": []
230
230
  },
231
+ {
232
+ "difficulty": 1,
233
+ "slug": "clock",
234
+ "topics": []
235
+ },
231
236
  {
232
237
  "difficulty": 1,
233
238
  "slug": "triangle",
234
239
  "topics": []
235
240
  },
241
+ {
242
+ "difficulty": 1,
243
+ "slug": "sum-of-multiples",
244
+ "topics": [
245
+ "Ranges",
246
+ "Collections",
247
+ "Lambdas"
248
+ ]
249
+ },
250
+ {
251
+ "difficulty": 1,
252
+ "slug": "all-your-base",
253
+ "topics": []
254
+ },
236
255
  {
237
256
  "difficulty": 2,
238
257
  "slug": "bank-account",
@@ -0,0 +1,28 @@
1
+ buildscript {
2
+ ext.kotlin_version = '1.1.1'
3
+ repositories {
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
8
+ }
9
+ }
10
+
11
+ apply plugin: 'kotlin'
12
+
13
+ repositories {
14
+ mavenCentral()
15
+ }
16
+
17
+ dependencies {
18
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
19
+
20
+ testCompile 'junit:junit:4.12'
21
+ testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
+ }
23
+ test {
24
+ testLogging {
25
+ exceptionFormat = 'full'
26
+ events = ["passed", "failed", "skipped"]
27
+ }
28
+ }
@@ -0,0 +1,59 @@
1
+ class BaseConverter(originalBase: Int, originalDigits: IntArray) {
2
+
3
+ companion object {
4
+ private val MINIMUM_VALID_BASE = 2
5
+ private val INVALID_BASE_ERROR_MESSAGE = "Bases must be at least 2."
6
+ }
7
+
8
+ private val numeral: Int
9
+
10
+ init {
11
+ require(originalBase >= MINIMUM_VALID_BASE) { INVALID_BASE_ERROR_MESSAGE }
12
+ require(originalDigits.isNotEmpty()) { "You must supply at least one digit." }
13
+ require(originalDigits.size == 1 || originalDigits[0] != 0) { "Digits may not contain leading zeros." }
14
+ require(originalDigits.min()!! >= 0) { "Digits may not be negative." }
15
+ require(originalDigits.max()!! < originalBase) { "All digits must be strictly less than the base." }
16
+
17
+ this.numeral = computeNumeral(originalBase, originalDigits)
18
+ }
19
+
20
+ fun convertToBase(newBase: Int): IntArray {
21
+ require(newBase >= MINIMUM_VALID_BASE) { INVALID_BASE_ERROR_MESSAGE }
22
+
23
+ val largestExponent = computeLargestExponentForBase(newBase)
24
+ val result = IntArray(largestExponent + 1)
25
+ var remainder = numeral
26
+
27
+ for (currentExponent in largestExponent downTo 0) {
28
+ val coefficient = Math.floor(remainder / Math.pow(newBase.toDouble(), currentExponent.toDouble())).toInt()
29
+
30
+ result[largestExponent - currentExponent] = coefficient
31
+
32
+ remainder -= (coefficient * Math.pow(newBase.toDouble(), currentExponent.toDouble())).toInt()
33
+ }
34
+
35
+ return result
36
+ }
37
+
38
+ private fun computeNumeral(originalBase: Int, originalDigits: IntArray): Int {
39
+ val largestExponent = originalDigits.size - 1
40
+
41
+ val result = (largestExponent downTo 0).sumBy { exponent ->
42
+ (originalDigits[largestExponent - exponent]
43
+ * Math.pow(originalBase.toDouble(), exponent.toDouble())).toInt()
44
+ }
45
+
46
+ return result
47
+ }
48
+
49
+ private fun computeLargestExponentForBase(newBase: Int): Int {
50
+ var result = 0
51
+
52
+ while (Math.pow(newBase.toDouble(), (result + 1).toDouble()) < numeral) {
53
+ result += 1
54
+ }
55
+
56
+ return result
57
+ }
58
+
59
+ }
@@ -0,0 +1,250 @@
1
+ import org.junit.Assert.assertArrayEquals
2
+ import org.junit.Ignore
3
+ import org.junit.Rule
4
+ import org.junit.Test
5
+ import org.junit.rules.ExpectedException
6
+ import java.util.*
7
+
8
+ /*
9
+ * version: 1.0.0
10
+ */
11
+ class BaseConverterTest {
12
+
13
+ /*
14
+ * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
15
+ * ExpectedExceptions in particular.
16
+ */
17
+ @Rule @JvmField
18
+ var expectedException: ExpectedException = ExpectedException.none()
19
+
20
+ @Test
21
+ fun testSingleBitOneToDecimal() {
22
+ val baseConverter = BaseConverter(2, intArrayOf(1))
23
+
24
+ val expectedDigits = intArrayOf(1)
25
+ val actualDigits = baseConverter.convertToBase(10)
26
+
27
+ assertArrayEquals(
28
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
29
+ expectedDigits,
30
+ actualDigits)
31
+ }
32
+
33
+ @Ignore
34
+ @Test
35
+ fun testBinaryToSingleDecimal() {
36
+ val baseConverter = BaseConverter(2, intArrayOf(1, 0, 1))
37
+
38
+ val expectedDigits = intArrayOf(5)
39
+ val actualDigits = baseConverter.convertToBase(10)
40
+
41
+ assertArrayEquals(
42
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
43
+ expectedDigits,
44
+ actualDigits)
45
+ }
46
+
47
+ @Ignore
48
+ @Test
49
+ fun testSingleDecimalToBinary() {
50
+ val baseConverter = BaseConverter(10, intArrayOf(5))
51
+
52
+ val expectedDigits = intArrayOf(1, 0, 1)
53
+ val actualDigits = baseConverter.convertToBase(2)
54
+
55
+ assertArrayEquals(
56
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
57
+ expectedDigits,
58
+ actualDigits)
59
+ }
60
+
61
+ @Ignore
62
+ @Test
63
+ fun testBinaryToMultipleDecimal() {
64
+ val baseConverter = BaseConverter(2, intArrayOf(1, 0, 1, 0, 1, 0))
65
+
66
+ val expectedDigits = intArrayOf(4, 2)
67
+ val actualDigits = baseConverter.convertToBase(10)
68
+
69
+ assertArrayEquals(
70
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
71
+ expectedDigits,
72
+ actualDigits)
73
+ }
74
+
75
+ @Ignore
76
+ @Test
77
+ fun testDecimalToBinary() {
78
+ val baseConverter = BaseConverter(10, intArrayOf(4, 2))
79
+
80
+ val expectedDigits = intArrayOf(1, 0, 1, 0, 1, 0)
81
+ val actualDigits = baseConverter.convertToBase(2)
82
+
83
+ assertArrayEquals(
84
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
85
+ expectedDigits,
86
+ actualDigits)
87
+ }
88
+
89
+ @Ignore
90
+ @Test
91
+ fun testTrinaryToHexadecimal() {
92
+ val baseConverter = BaseConverter(3, intArrayOf(1, 1, 2, 0))
93
+
94
+ val expectedDigits = intArrayOf(2, 10)
95
+ val actualDigits = baseConverter.convertToBase(16)
96
+
97
+ assertArrayEquals(
98
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
99
+ expectedDigits,
100
+ actualDigits)
101
+ }
102
+
103
+ @Ignore
104
+ @Test
105
+ fun testHexadecimalToTrinary() {
106
+ val baseConverter = BaseConverter(16, intArrayOf(2, 10))
107
+
108
+ val expectedDigits = intArrayOf(1, 1, 2, 0)
109
+ val actualDigits = baseConverter.convertToBase(3)
110
+
111
+ assertArrayEquals(
112
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
113
+ expectedDigits,
114
+ actualDigits)
115
+ }
116
+
117
+ @Ignore
118
+ @Test
119
+ fun test15BitInteger() {
120
+ val baseConverter = BaseConverter(97, intArrayOf(3, 46, 60))
121
+
122
+ val expectedDigits = intArrayOf(6, 10, 45)
123
+ val actualDigits = baseConverter.convertToBase(73)
124
+
125
+ assertArrayEquals(
126
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
127
+ expectedDigits,
128
+ actualDigits)
129
+ }
130
+
131
+ @Ignore
132
+ @Test
133
+ fun testEmptyDigits() {
134
+ expectedException.expect(IllegalArgumentException::class.java)
135
+ expectedException.expectMessage("You must supply at least one digit.")
136
+
137
+ BaseConverter(2, intArrayOf())
138
+ }
139
+
140
+ @Ignore
141
+ @Test
142
+ fun testSingleZero() {
143
+ val baseConverter = BaseConverter(10, intArrayOf(0))
144
+
145
+ val expectedDigits = intArrayOf(0)
146
+ val actualDigits = baseConverter.convertToBase(2)
147
+
148
+ assertArrayEquals(
149
+ "Expected digits: ${Arrays.toString(expectedDigits)} but found digits: ${Arrays.toString(actualDigits)}",
150
+ expectedDigits,
151
+ actualDigits)
152
+ }
153
+
154
+ @Ignore
155
+ @Test
156
+ fun testMultipleZeros() {
157
+ expectedException.expect(IllegalArgumentException::class.java)
158
+ expectedException.expectMessage("Digits may not contain leading zeros.")
159
+
160
+ BaseConverter(10, intArrayOf(0, 0, 0))
161
+ }
162
+
163
+ @Ignore
164
+ @Test
165
+ fun testLeadingZeros() {
166
+ expectedException.expect(IllegalArgumentException::class.java)
167
+ expectedException.expectMessage("Digits may not contain leading zeros.")
168
+
169
+ BaseConverter(7, intArrayOf(0, 6, 0))
170
+ }
171
+
172
+ @Ignore
173
+ @Test
174
+ fun testNegativeDigit() {
175
+ expectedException.expect(IllegalArgumentException::class.java)
176
+ expectedException.expectMessage("Digits may not be negative.")
177
+
178
+ BaseConverter(2, intArrayOf(1, -1, 1, 0, 1, 0))
179
+ }
180
+
181
+ @Ignore
182
+ @Test
183
+ fun testInvalidPositiveDigit() {
184
+ expectedException.expect(IllegalArgumentException::class.java)
185
+ expectedException.expectMessage("All digits must be strictly less than the base.")
186
+
187
+ BaseConverter(2, intArrayOf(1, 2, 1, 0, 1, 0))
188
+ }
189
+
190
+ @Ignore
191
+ @Test
192
+ fun testFirstBaseIsOne() {
193
+ expectedException.expect(IllegalArgumentException::class.java)
194
+ expectedException.expectMessage("Bases must be at least 2.")
195
+
196
+ BaseConverter(1, intArrayOf())
197
+ }
198
+
199
+ @Ignore
200
+ @Test
201
+ fun testSecondBaseIsOne() {
202
+ val baseConverter = BaseConverter(2, intArrayOf(1, 0, 1, 0, 1, 0))
203
+
204
+ expectedException.expect(IllegalArgumentException::class.java)
205
+ expectedException.expectMessage("Bases must be at least 2.")
206
+
207
+ baseConverter.convertToBase(1)
208
+ }
209
+
210
+ @Ignore
211
+ @Test
212
+ fun testFirstBaseIsZero() {
213
+ expectedException.expect(IllegalArgumentException::class.java)
214
+ expectedException.expectMessage("Bases must be at least 2.")
215
+
216
+ BaseConverter(0, intArrayOf())
217
+ }
218
+
219
+ @Ignore
220
+ @Test
221
+ fun testSecondBaseIsZero() {
222
+ val baseConverter = BaseConverter(2, intArrayOf(1, 0, 1, 0, 1, 0))
223
+
224
+ expectedException.expect(IllegalArgumentException::class.java)
225
+ expectedException.expectMessage("Bases must be at least 2.")
226
+
227
+ baseConverter.convertToBase(0)
228
+ }
229
+
230
+ @Ignore
231
+ @Test
232
+ fun testFirstBaseIsNegative() {
233
+ expectedException.expect(IllegalArgumentException::class.java)
234
+ expectedException.expectMessage("Bases must be at least 2.")
235
+
236
+ BaseConverter(-2, intArrayOf())
237
+ }
238
+
239
+ @Ignore
240
+ @Test
241
+ fun testSecondBaseIsNegative() {
242
+ val baseConverter = BaseConverter(2, intArrayOf(1))
243
+
244
+ expectedException.expect(IllegalArgumentException::class.java)
245
+ expectedException.expectMessage("Bases must be at least 2.")
246
+
247
+ baseConverter.convertToBase(-7)
248
+ }
249
+
250
+ }
@@ -0,0 +1,28 @@
1
+ buildscript {
2
+ ext.kotlin_version = '1.1.1'
3
+ repositories {
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
8
+ }
9
+ }
10
+
11
+ apply plugin: 'kotlin'
12
+
13
+ repositories {
14
+ mavenCentral()
15
+ }
16
+
17
+ dependencies {
18
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
19
+
20
+ testCompile 'junit:junit:4.12'
21
+ testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
+ }
23
+ test {
24
+ testLogging {
25
+ exceptionFormat = 'full'
26
+ events = ["passed", "failed", "skipped"]
27
+ }
28
+ }
@@ -0,0 +1,40 @@
1
+ data class Clock(private var hours: Int, private var minutes: Int) {
2
+
3
+ companion object {
4
+ private val MINUTES_IN_AN_HOUR = 60
5
+ private val HOURS_IN_A_DAY = 24
6
+ }
7
+
8
+ init {
9
+ sanitiseTime()
10
+ }
11
+
12
+ override fun toString(): String {
13
+ return "${hours.toTimeString()}:${minutes.toTimeString()}"
14
+ }
15
+
16
+ fun add(minutes: Int) {
17
+ this.minutes += minutes
18
+ sanitiseTime()
19
+ }
20
+
21
+ private fun sanitiseTime() {
22
+ while (minutes < 0) {
23
+ minutes += MINUTES_IN_AN_HOUR
24
+ hours--
25
+ }
26
+
27
+ while (hours < 0) {
28
+ hours += HOURS_IN_A_DAY
29
+ }
30
+
31
+ val minutesOverflow = minutes / MINUTES_IN_AN_HOUR
32
+ minutes %= MINUTES_IN_AN_HOUR
33
+ hours = (hours + minutesOverflow) % HOURS_IN_A_DAY
34
+ }
35
+
36
+ }
37
+
38
+ private fun Int.toTimeString(): String {
39
+ return toString().padStart(length = 2, padChar = '0')
40
+ }
@@ -0,0 +1,138 @@
1
+ import org.junit.Ignore
2
+ import org.junit.Test
3
+ import kotlin.test.assertEquals
4
+
5
+ /*
6
+ * version: 1.0.1
7
+ */
8
+ class ClockAddTest {
9
+
10
+ @Ignore
11
+ @Test
12
+ fun addMinutes() {
13
+ val clock = Clock(10, 0)
14
+ clock.add(3)
15
+ assertEquals("10:03", clock.toString())
16
+ }
17
+
18
+ @Ignore
19
+ @Test
20
+ fun addNoMinutes() {
21
+ val clock = Clock(6, 41)
22
+ clock.add(0)
23
+ assertEquals("06:41", clock.toString())
24
+ }
25
+
26
+ @Ignore
27
+ @Test
28
+ fun addToNextHour() {
29
+ val clock = Clock(0, 45)
30
+ clock.add(40)
31
+ assertEquals("01:25", clock.toString())
32
+ }
33
+
34
+ @Ignore
35
+ @Test
36
+ fun addMoreThanOneHour() {
37
+ val clock = Clock(10, 0)
38
+ clock.add(61)
39
+ assertEquals("11:01", clock.toString())
40
+ }
41
+
42
+ @Ignore
43
+ @Test
44
+ fun addMoreThanTwoHoursWithCarry() {
45
+ val clock = Clock(0, 45)
46
+ clock.add(160)
47
+ assertEquals("03:25", clock.toString())
48
+ }
49
+
50
+ @Ignore
51
+ @Test
52
+ fun addAcrossMidnight() {
53
+ val clock = Clock(23, 59)
54
+ clock.add(2)
55
+ assertEquals("00:01", clock.toString())
56
+ }
57
+
58
+ @Ignore
59
+ @Test
60
+ fun addMoreThanOneDay() {
61
+ val clock = Clock(5, 32)
62
+ clock.add(1500)
63
+ assertEquals("06:32", clock.toString())
64
+ }
65
+
66
+ @Ignore
67
+ @Test
68
+ fun addMoreThanTwoDays() {
69
+ val clock = Clock(1, 1)
70
+ clock.add(3500)
71
+ assertEquals("11:21", clock.toString())
72
+ }
73
+
74
+ @Ignore
75
+ @Test
76
+ fun subtractMinutes() {
77
+ val clock = Clock(10, 3)
78
+ clock.add(-3)
79
+ assertEquals("10:00", clock.toString())
80
+ }
81
+
82
+ @Ignore
83
+ @Test
84
+ fun subtractToPreviousHour() {
85
+ val clock = Clock(10, 3)
86
+ clock.add(-30)
87
+ assertEquals("09:33", clock.toString())
88
+ }
89
+
90
+ @Ignore
91
+ @Test
92
+ fun subtractMoreThanAnHour() {
93
+ val clock = Clock(10, 3)
94
+ clock.add(-70)
95
+ assertEquals("08:53", clock.toString())
96
+ }
97
+
98
+ @Ignore
99
+ @Test
100
+ fun subtractAcrossMidnight() {
101
+ val clock = Clock(0, 3)
102
+ clock.add(-4)
103
+ assertEquals("23:59", clock.toString())
104
+ }
105
+
106
+ @Ignore
107
+ @Test
108
+ fun subtractMoreThanTwoHours() {
109
+ val clock = Clock(0, 0)
110
+ clock.add(-160)
111
+ assertEquals("21:20", clock.toString())
112
+ }
113
+
114
+ @Ignore
115
+ @Test
116
+ fun subtractMoreThanTwoHoursWithBorrow() {
117
+ val clock = Clock(6, 15)
118
+ clock.add(-160)
119
+ assertEquals("03:35", clock.toString())
120
+ }
121
+
122
+ @Ignore
123
+ @Test
124
+ fun subtractMoreThanOneDay() {
125
+ val clock = Clock(5, 32)
126
+ clock.add(-1500)
127
+ assertEquals("04:32", clock.toString())
128
+ }
129
+
130
+ @Ignore
131
+ @Test
132
+ fun subtractMoreThanTwoDays() {
133
+ val clock = Clock(2, 20)
134
+ clock.add(-3000)
135
+ assertEquals("00:20", clock.toString())
136
+ }
137
+
138
+ }
@@ -0,0 +1,123 @@
1
+ import org.junit.Ignore
2
+ import org.junit.Test
3
+ import kotlin.test.assertEquals
4
+
5
+ /*
6
+ * version: 1.0.1
7
+ */
8
+ class ClockCreationTest {
9
+
10
+ @Test
11
+ fun canPrintTimeOnTheHour() {
12
+ assertEquals("08:00", Clock(8, 0).toString())
13
+ }
14
+
15
+ @Ignore
16
+ @Test
17
+ fun canPrintTimeWithMinutes() {
18
+ assertEquals("11:09", Clock(11, 9).toString())
19
+ }
20
+
21
+ @Ignore
22
+ @Test
23
+ fun midnightPrintsAsZero() {
24
+ assertEquals("00:00", Clock(24, 0).toString())
25
+ }
26
+
27
+ @Ignore
28
+ @Test
29
+ fun hourRollsOver() {
30
+ assertEquals("01:00", Clock(25, 0).toString())
31
+ }
32
+
33
+ @Ignore
34
+ @Test
35
+ fun hourRollsOverContinuously() {
36
+ assertEquals("04:00", Clock(100, 0).toString())
37
+ }
38
+
39
+ @Ignore
40
+ @Test
41
+ fun sixtyMinutesIsNextHour() {
42
+ assertEquals("02:00", Clock(1, 60).toString())
43
+ }
44
+
45
+ @Ignore
46
+ @Test
47
+ fun minutesRollOver() {
48
+ assertEquals("02:40", Clock(0, 160).toString())
49
+ }
50
+
51
+ @Ignore
52
+ @Test
53
+ fun minutesRollOverContinuously() {
54
+ assertEquals("04:43", Clock(0, 1723).toString())
55
+ }
56
+
57
+ @Ignore
58
+ @Test
59
+ fun hourAndMinutesRollOver() {
60
+ assertEquals("03:40", Clock(25, 160).toString())
61
+ }
62
+
63
+ @Ignore
64
+ @Test
65
+ fun hourAndMinutesRollOverContinuously() {
66
+ assertEquals("11:01", Clock(201, 3001).toString())
67
+ }
68
+
69
+ @Ignore
70
+ @Test
71
+ fun hourAndMinutesRollOverToExactlyMidnight() {
72
+ assertEquals("00:00", Clock(72, 8640).toString())
73
+ }
74
+
75
+ @Ignore
76
+ @Test
77
+ fun negativeHour() {
78
+ assertEquals("23:15", Clock(-1, 15).toString())
79
+ }
80
+
81
+ @Ignore
82
+ @Test
83
+ fun negativeHourRollsOver() {
84
+ assertEquals("23:00", Clock(-25, 0).toString())
85
+ }
86
+
87
+ @Ignore
88
+ @Test
89
+ fun negativeHourRollsOverContinuously() {
90
+ assertEquals("05:00", Clock(-91, 0).toString())
91
+ }
92
+
93
+ @Ignore
94
+ @Test
95
+ fun negativeMinutes() {
96
+ assertEquals("00:20", Clock(1, -40).toString())
97
+ }
98
+
99
+ @Ignore
100
+ @Test
101
+ fun negativeMinutesRollOver() {
102
+ assertEquals("22:20", Clock(1, -160).toString())
103
+ }
104
+
105
+ @Ignore
106
+ @Test
107
+ fun negativeMinutesRollOverContinuously() {
108
+ assertEquals("16:40", Clock(1, -4820).toString())
109
+ }
110
+
111
+ @Ignore
112
+ @Test
113
+ fun negativeHourAndMinutesBothRollOver() {
114
+ assertEquals("20:20", Clock(-25, -160).toString())
115
+ }
116
+
117
+ @Ignore
118
+ @Test
119
+ fun negativeHourAndMinutesBothRollOverContinuously() {
120
+ assertEquals("22:10", Clock(-121, -5810).toString())
121
+ }
122
+
123
+ }
@@ -0,0 +1,101 @@
1
+ import org.junit.Ignore
2
+ import org.junit.Test
3
+ import kotlin.test.assertNotEquals
4
+ import kotlin.test.assertEquals
5
+
6
+ /*
7
+ * version: 1.0.1
8
+ */
9
+ class ClockEqualTest {
10
+
11
+ @Ignore
12
+ @Test
13
+ fun clocksWithSameTimeAreEqual() {
14
+ assertEquals(Clock(15, 37), Clock(15, 37))
15
+ }
16
+
17
+ @Ignore
18
+ @Test
19
+ fun clocksAMinuteApartAreNotEqual() {
20
+ assertNotEquals(Clock(15, 36), Clock(15, 37))
21
+ }
22
+
23
+ @Ignore
24
+ @Test
25
+ fun clocksAnHourApartAreNotEqual() {
26
+ assertNotEquals(Clock(14, 37), Clock(15, 37))
27
+ }
28
+
29
+ @Ignore
30
+ @Test
31
+ fun clocksWithHourOverflow() {
32
+ assertEquals(Clock(10, 37), Clock(34, 37))
33
+ }
34
+
35
+ @Ignore
36
+ @Test
37
+ fun clocksWithHourOverflowBySeveralDays() {
38
+ assertEquals(Clock(3, 11), Clock(99, 11))
39
+ }
40
+
41
+ @Ignore
42
+ @Test
43
+ fun clocksWithNegateHour() {
44
+ assertEquals(Clock(22, 40), Clock(-2, 40))
45
+ }
46
+
47
+ @Ignore
48
+ @Test
49
+ fun clocksWithNegativeHourThatWraps() {
50
+ assertEquals(Clock(17, 3), Clock(-31, 3))
51
+ }
52
+
53
+ @Ignore
54
+ @Test
55
+ fun clocksWithNegativeHourThatWrapsMultipleTimes() {
56
+ assertEquals(Clock(13, 49), Clock(-83, 49))
57
+ }
58
+
59
+ @Ignore
60
+ @Test
61
+ fun clocksWithMinuteOverflow() {
62
+ assertEquals(Clock(0, 1), Clock(0, 1441))
63
+ }
64
+
65
+ @Ignore
66
+ @Test
67
+ fun clocksWithMinuteOverflowBySeveralDays() {
68
+ assertEquals(Clock(2, 2), Clock(2, 4322))
69
+ }
70
+
71
+ @Ignore
72
+ @Test
73
+ fun clocksWithNegativeMinutes() {
74
+ assertEquals(Clock(2, 40), Clock(3, -20))
75
+ }
76
+
77
+ @Ignore
78
+ @Test
79
+ fun clocksWithNegativeMinutesThatWraps() {
80
+ assertEquals(Clock(4, 10), Clock(5, -1490))
81
+ }
82
+
83
+ @Ignore
84
+ @Test
85
+ fun clocksWithNegativeMinutesThatWrapsMultipleTimes() {
86
+ assertEquals(Clock(6, 15), Clock(6, -4305))
87
+ }
88
+
89
+ @Ignore
90
+ @Test
91
+ fun clocksWithNegativeHoursAndMinutes() {
92
+ assertEquals(Clock(7, 32), Clock(-12, -268))
93
+ }
94
+
95
+ @Ignore
96
+ @Test
97
+ fun clocksWithNegativeHoursAndMinutesThatWrap() {
98
+ assertEquals(Clock(18, 7), Clock(-54, -11513))
99
+ }
100
+
101
+ }
@@ -2,11 +2,13 @@ include 'hello-world'
2
2
  include 'accumulate'
3
3
  include 'acronym'
4
4
  include 'allergies'
5
+ include 'all-your-base'
5
6
  include 'anagram'
6
7
  include 'atbash-cipher'
7
8
  include 'beer-song'
8
9
  include 'binary'
9
10
  include 'bob'
11
+ include 'clock'
10
12
  include 'difference-of-squares'
11
13
  include 'etl'
12
14
  include 'flatten-array'
@@ -43,3 +45,4 @@ include 'change'
43
45
  include 'binary-search'
44
46
  include 'triangle'
45
47
  include 'bank-account'
48
+ include 'sum-of-multiples'
@@ -0,0 +1,29 @@
1
+ buildscript {
2
+ ext.kotlin_version = '1.1.1'
3
+ repositories {
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
8
+ }
9
+ }
10
+
11
+ apply plugin: 'kotlin'
12
+
13
+ repositories {
14
+ mavenCentral()
15
+ }
16
+
17
+ dependencies {
18
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
19
+
20
+ testCompile 'junit:junit:4.12'
21
+ testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
22
+ }
23
+
24
+ test {
25
+ testLogging {
26
+ exceptionFormat = 'full'
27
+ events = ["passed", "failed", "skipped"]
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ object SumOfMultiples {
2
+
3
+ fun sum(factors: Set<Int>, limit: Int): Int =
4
+ (1 until limit).filter { x -> factors.any { y -> x.isMultipleOf(y) } }.sum()
5
+ }
6
+
7
+ fun Int.isMultipleOf(y: Int) = this % y == 0
@@ -0,0 +1,84 @@
1
+ import org.junit.Ignore
2
+ import org.junit.Test
3
+ import kotlin.test.assertEquals
4
+
5
+ class SumOfMultiplesTest {
6
+
7
+ @Test
8
+ fun `multiples of 3 or 5 up to 1`() {
9
+ assertEquals(0, SumOfMultiples.sum(setOf(3, 5), 1))
10
+ }
11
+
12
+ @Test
13
+ @Ignore
14
+ fun `multiples of 3 or 5 up to 4`() {
15
+ assertEquals(3, SumOfMultiples.sum(setOf(3, 5), 4))
16
+ }
17
+
18
+ @Test
19
+ @Ignore
20
+ fun `multiples of 3 or 5 up to 10`() {
21
+ assertEquals(23, SumOfMultiples.sum(setOf(3, 5), 10))
22
+ }
23
+
24
+ @Test
25
+ @Ignore
26
+ fun `multiples of 3 or 5 up to 20`() {
27
+ assertEquals(78, SumOfMultiples.sum(setOf(3, 5), 20))
28
+ }
29
+
30
+ @Test
31
+ @Ignore
32
+ fun `multiples of 3 or 5 up to 100`() {
33
+ assertEquals(2318, SumOfMultiples.sum(setOf(3, 5), 100))
34
+ }
35
+
36
+ @Test
37
+ @Ignore
38
+ fun `multiples of 3 or 5 up to 1000`() {
39
+ assertEquals(233_168, SumOfMultiples.sum(setOf(3, 5), 1000))
40
+ }
41
+
42
+ @Test
43
+ @Ignore
44
+ fun `multiples of 7, 13 or 17 up to 20`() {
45
+ assertEquals(51, SumOfMultiples.sum(setOf(7, 13, 17), 20))
46
+ }
47
+
48
+ @Test
49
+ @Ignore
50
+ fun `multiples of 4 or 6 up to 15`() {
51
+ assertEquals(30, SumOfMultiples.sum(setOf(4, 6), 15))
52
+ }
53
+
54
+ @Test
55
+ @Ignore
56
+ fun `multiples of 5, 6 or 8 up to 150`() {
57
+ assertEquals(4419, SumOfMultiples.sum(setOf(5, 6, 8), 150))
58
+ }
59
+
60
+ @Test
61
+ @Ignore
62
+ fun `multiples of 5 or 25 up to 51`() {
63
+ assertEquals(275, SumOfMultiples.sum(setOf(5, 25), 51))
64
+ }
65
+
66
+ @Test
67
+ @Ignore
68
+ fun `multiples of 43 or 47 up to 10000`() {
69
+ assertEquals(2_203_160, SumOfMultiples.sum(setOf(43, 47), 10_000))
70
+ }
71
+
72
+ @Test
73
+ @Ignore
74
+ fun `multiples of 1 up to 100`() {
75
+ assertEquals(4950, SumOfMultiples.sum(setOf(1), 100))
76
+ }
77
+
78
+ @Test
79
+ @Ignore
80
+ fun `multiples of an empty set up to 10000`() {
81
+ assertEquals(0, SumOfMultiples.sum(emptySet(), 10_000))
82
+ }
83
+
84
+ }
@@ -45,8 +45,8 @@ class SchoolTest(unittest.TestCase):
45
45
  students = [(3, ("Kyle", )), (4, ("Christopher", "Jennifer", )),
46
46
  (6, ("Kareem", ))]
47
47
 
48
- for grade, students_in_grade in students:
49
- for student in students_in_grade:
48
+ for grade, students_in_grade in students[::-1]:
49
+ for student in students_in_grade[::-1]:
50
50
  self.school.add(student, grade)
51
51
 
52
52
  result = self.school.sort()
@@ -2,7 +2,7 @@
2
2
  "slug": "vimscript",
3
3
  "language": "Vim script",
4
4
  "repository": "https://github.com/exercism/xvimscript",
5
- "active": false,
5
+ "active": true,
6
6
  "test_pattern": "\\.vader$",
7
7
  "exercises": [
8
8
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.22
4
+ version: 2.1.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-27 00:00:00.000000000 Z
11
+ date: 2017-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -4271,7 +4271,6 @@ files:
4271
4271
  - tracks/java/.git
4272
4272
  - tracks/java/.gitattributes
4273
4273
  - tracks/java/.github/PULL_REQUEST_TEMPLATE.md
4274
- - tracks/java/.github/stale.yml
4275
4274
  - tracks/java/.gitignore
4276
4275
  - tracks/java/.keep
4277
4276
  - tracks/java/.travis.yml
@@ -4921,6 +4920,10 @@ files:
4921
4920
  - tracks/kotlin/exercises/acronym/src/example/kotlin/Acronym.kt
4922
4921
  - tracks/kotlin/exercises/acronym/src/main/kotlin/.keep
4923
4922
  - tracks/kotlin/exercises/acronym/src/test/kotlin/AcronymTest.kt
4923
+ - tracks/kotlin/exercises/all-your-base/build.gradle
4924
+ - tracks/kotlin/exercises/all-your-base/src/example/kotlin/BaseConverter.kt
4925
+ - tracks/kotlin/exercises/all-your-base/src/main/kotlin/.keep
4926
+ - tracks/kotlin/exercises/all-your-base/src/test/kotlin/BaseConverterTest.kt
4924
4927
  - tracks/kotlin/exercises/allergies/build.gradle
4925
4928
  - tracks/kotlin/exercises/allergies/src/example/kotlin/Allergen.kt
4926
4929
  - tracks/kotlin/exercises/allergies/src/example/kotlin/Allergies.kt
@@ -4963,6 +4966,12 @@ files:
4963
4966
  - tracks/kotlin/exercises/change/src/example/kotlin/Change.kt
4964
4967
  - tracks/kotlin/exercises/change/src/main/kotlin/.keep
4965
4968
  - tracks/kotlin/exercises/change/src/test/kotlin/ChangeTest.kt
4969
+ - tracks/kotlin/exercises/clock/build.gradle
4970
+ - tracks/kotlin/exercises/clock/src/example/kotlin/Clock.kt
4971
+ - tracks/kotlin/exercises/clock/src/main/kotlin/.keep
4972
+ - tracks/kotlin/exercises/clock/src/test/kotlin/ClockAddTest.kt
4973
+ - tracks/kotlin/exercises/clock/src/test/kotlin/ClockCreationTest.kt
4974
+ - tracks/kotlin/exercises/clock/src/test/kotlin/ClockEqualTest.kt
4966
4975
  - tracks/kotlin/exercises/difference-of-squares/build.gradle
4967
4976
  - tracks/kotlin/exercises/difference-of-squares/src/example/kotlin/Squares.kt
4968
4977
  - tracks/kotlin/exercises/difference-of-squares/src/main/kotlin/.keep
@@ -5094,6 +5103,10 @@ files:
5094
5103
  - tracks/kotlin/exercises/strain/src/example/kotlin/Strain.kt
5095
5104
  - tracks/kotlin/exercises/strain/src/main/kotlin/.keep
5096
5105
  - tracks/kotlin/exercises/strain/src/test/kotlin/StrainTest.kt
5106
+ - tracks/kotlin/exercises/sum-of-multiples/build.gradle
5107
+ - tracks/kotlin/exercises/sum-of-multiples/src/example/kotlin/SumOfMultiples.kt
5108
+ - tracks/kotlin/exercises/sum-of-multiples/src/main/kotlin/.keep
5109
+ - tracks/kotlin/exercises/sum-of-multiples/src/test/kotlin/SumOfMultiplesTest.kt
5097
5110
  - tracks/kotlin/exercises/triangle/build.gradle
5098
5111
  - tracks/kotlin/exercises/triangle/src/example/kotlin/Triangle.kt
5099
5112
  - tracks/kotlin/exercises/triangle/src/main/kotlin/.keep
@@ -1,8 +0,0 @@
1
- # Issues or Pull Requests with these labels will never be considered stale
2
- exemptLabels:
3
- - "first-timers only"
4
- - "good first patch"
5
- - "policy"
6
-
7
- # Label to use when marking as stale
8
- staleLabel: stale