trackler 2.0.6.34 → 2.0.6.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/common/exercises/change/canonical-data.json +6 -0
- data/common/exercises/luhn/canonical-data.json +35 -0
- data/common/exercises/rotational-cipher/cannonical-data.json +70 -0
- data/common/exercises/rotational-cipher/description.md +30 -0
- data/common/exercises/rotational-cipher/metadata.yml +4 -0
- data/common/exercises/run-length-encoding/description.md +7 -1
- data/lib/trackler/version.rb +1 -1
- data/tracks/elixir/exercises/run-length-encoding/example.exs +15 -4
- data/tracks/elixir/exercises/run-length-encoding/rle.exs +2 -2
- data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +28 -11
- data/tracks/go/exercises/bob/bob_test.go +4 -1
- data/tracks/go/exercises/bracket-push/bracket_push_test.go +5 -2
- data/tracks/go/exercises/circular-buffer/circular_buffer_test.go +6 -6
- data/tracks/go/exercises/clock/clock_test.go +4 -1
- data/tracks/go/exercises/connect/connect_test.go +4 -1
- data/tracks/go/exercises/crypto-square/crypto_square_test.go +5 -2
- data/tracks/go/exercises/luhn/luhn_test.go +1 -1
- data/tracks/javascript/exercises/leap/leap.js +1 -1
- data/tracks/julia/.travis.yml +0 -2
- data/tracks/julia/config.json +41 -0
- data/tracks/julia/exercises/custom-set/HINTS.md +1 -0
- data/tracks/julia/exercises/custom-set/custom-set.jl +0 -0
- data/tracks/julia/exercises/custom-set/example.jl +51 -0
- data/tracks/julia/exercises/custom-set/runtests.jl +200 -0
- data/tracks/julia/exercises/isogram/example.jl +11 -0
- data/tracks/julia/exercises/isogram/isogram.jl +3 -0
- data/tracks/julia/exercises/isogram/runtests.jl +35 -0
- data/tracks/julia/exercises/luhn/example.jl +16 -0
- data/tracks/julia/exercises/luhn/luhn.jl +0 -0
- data/tracks/julia/exercises/luhn/runtests.jl +31 -0
- data/tracks/julia/exercises/nucleotide-count/example.jl +8 -0
- data/tracks/julia/exercises/nucleotide-count/nucleotide-count.jl +3 -0
- data/tracks/julia/exercises/nucleotide-count/runtests.jl +19 -0
- data/tracks/kotlin/.travis.yml +9 -1
- data/tracks/kotlin/README.md +117 -11
- data/tracks/kotlin/bin/journey-test.sh +279 -0
- data/tracks/kotlin/docs/INSTALLATION.md +193 -97
- data/tracks/kotlin/docs/TESTS.md +72 -137
- data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +50 -0
- data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +693 -0
- data/tracks/kotlin/exercises/hello-world/src/example/kotlin/HelloWorld.kt +2 -30
- data/tracks/kotlin/exercises/hello-world/src/main/kotlin/HelloWorld.kt +2 -30
- data/tracks/kotlin/exercises/hello-world/src/test/kotlin/HelloWorldTest.kt +11 -19
- data/tracks/objective-c/circle.yml +1 -1
- data/tracks/perl6/exercises/atbash-cipher/{cipher.t → atbash-cipher.t} +0 -0
- data/tracks/perl6/exercises/linked-list/linked-list.t +0 -0
- data/tracks/perl6/exercises/phone-number/{phone.t → phone-number.t} +0 -0
- data/tracks/perl6/exercises/rna-transcription/{rna_transcription.t → rna-transcription.t} +0 -0
- data/tracks/perl6/exercises/robot-name/{robot.t → robot-name.t} +0 -0
- data/tracks/perl6/exercises/scrabble-score/{scrabble_score.t → scrabble-score.t} +0 -0
- data/tracks/perl6/exercises/word-count/{word_count.t → word-count.t} +0 -0
- data/tracks/pony/config.json +9 -0
- data/tracks/pony/exercises/pascals-triangle/example.pony +18 -0
- data/tracks/pony/exercises/pascals-triangle/test.pony +31 -0
- data/tracks/r/config.json +20 -0
- data/tracks/r/exercises/grains/example.R +16 -0
- data/tracks/r/exercises/grains/grains.R +7 -0
- data/tracks/r/exercises/grains/test_grains.R +49 -0
- data/tracks/r/exercises/phone-number/example.R +30 -0
- data/tracks/r/exercises/phone-number/phone-number.R +3 -0
- data/tracks/r/exercises/phone-number/test_phone-number.R +44 -0
- data/tracks/r/exercises/secret-handshake/example.R +26 -0
- data/tracks/r/exercises/secret-handshake/secret-handshake.R +3 -0
- data/tracks/r/exercises/secret-handshake/test_secret-handshake.R +52 -0
- data/tracks/r/exercises/sieve/example.R +16 -0
- data/tracks/r/exercises/sieve/sieve.R +3 -0
- data/tracks/r/exercises/sieve/test_sieve.R +37 -0
- data/tracks/rust/config.json +11 -0
- data/tracks/rust/exercises/rotational-cipher/Cargo.lock +4 -0
- data/tracks/rust/exercises/rotational-cipher/Cargo.toml +4 -0
- data/tracks/rust/exercises/rotational-cipher/example.rs +16 -0
- data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +61 -0
- data/tracks/swift/circle.yml +6 -0
- metadata +46 -8
@@ -1,31 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* See: https://kotlinlang.org/docs/reference/object-declarations.html#object-declarations
|
4
|
-
*
|
5
|
-
* As an alternative one could create a class such as:
|
6
|
-
* ```
|
7
|
-
* class HelloWorld(name: String? = "Default Value") {
|
8
|
-
* fun hello(): String {
|
9
|
-
*
|
10
|
-
* }
|
11
|
-
* }
|
12
|
-
* ```
|
13
|
-
* Resulting in a call such as: `HelloWorld("Bob").hello()`
|
14
|
-
* See: https://kotlinlang.org/docs/reference/classes.html#constructors
|
15
|
-
*
|
16
|
-
* In Kotlin we make objects defined as nullable via the trailing `?`, if you try
|
17
|
-
* to assign a null value to any value that isn't nullable a compilation error is thrown.
|
18
|
-
* Kotlin makes sure you are accessing nullable values safely and provides null safe calls
|
19
|
-
* and the use of the elvis operator. See: https://kotlinlang.org/docs/reference/null-safety.html
|
20
|
-
*
|
21
|
-
* You may provide default values on methods, so if an argument is omitted the default is used.
|
22
|
-
* See: https://kotlinlang.org/docs/reference/functions.html#default-arguments
|
23
|
-
*
|
24
|
-
* Kotlin provides String interpolation to make String formatting simple.
|
25
|
-
* See: https://kotlinlang.org/docs/reference/idioms.html#string-interpolation
|
26
|
-
*/
|
27
|
-
object HelloWorld {
|
28
|
-
fun hello(name: String? = null): String {
|
29
|
-
return "Hello, ${if (name.isNullOrBlank()) "World" else name}!"
|
30
|
-
}
|
1
|
+
fun hello(name: String = "World"): String {
|
2
|
+
return "Hello, ${if (name.isBlank()) "World" else name}!"
|
31
3
|
}
|
@@ -1,31 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* See: https://kotlinlang.org/docs/reference/object-declarations.html#object-declarations
|
4
|
-
*
|
5
|
-
* As an alternative one could create a class such as:
|
6
|
-
* ```
|
7
|
-
* class HelloWorld(name: String? = "Default Value") {
|
8
|
-
* fun hello(): String {
|
9
|
-
*
|
10
|
-
* }
|
11
|
-
* }
|
12
|
-
* ```
|
13
|
-
* Resulting in a call such as: `HelloWorld("Bob").hello()`
|
14
|
-
* See: https://kotlinlang.org/docs/reference/classes.html#constructors
|
15
|
-
*
|
16
|
-
* In Kotlin we make objects defined as nullable via the trailing `?`, if you try
|
17
|
-
* to assign a null value to any value that isn't nullable a compilation error is thrown.
|
18
|
-
* Kotlin makes sure you are accessing nullable values safely and provides null safe calls
|
19
|
-
* and the use of the elvis operator. See: https://kotlinlang.org/docs/reference/null-safety.html
|
20
|
-
*
|
21
|
-
* You may provide default values on methods, so if an argument is omitted the default is used.
|
22
|
-
* See: https://kotlinlang.org/docs/reference/functions.html#default-arguments
|
23
|
-
*
|
24
|
-
* Kotlin provides String interpolation to make String formatting simple.
|
25
|
-
* See: https://kotlinlang.org/docs/reference/idioms.html#string-interpolation
|
26
|
-
*/
|
27
|
-
object HelloWorld {
|
28
|
-
fun hello(name: String? = "Default Argument"): String {
|
29
|
-
|
30
|
-
}
|
1
|
+
fun hello(name: String = ""): String {
|
2
|
+
return ""
|
31
3
|
}
|
@@ -1,38 +1,30 @@
|
|
1
|
-
import kotlin.test.assertEquals
|
2
|
-
import org.junit.Test
|
3
1
|
import org.junit.Ignore
|
2
|
+
import org.junit.Test
|
3
|
+
import org.junit.Assert.assertEquals
|
4
4
|
|
5
|
-
class HelloWorldTest {
|
6
5
|
|
6
|
+
class HelloWorldTest {
|
7
7
|
|
8
8
|
@Test
|
9
9
|
fun helloNoName() {
|
10
|
-
assertEquals("Hello, World!",
|
10
|
+
assertEquals("Hello, World!", hello())
|
11
11
|
}
|
12
12
|
|
13
|
-
@Ignore
|
14
13
|
@Test
|
15
|
-
fun helloBlankName() {
|
16
|
-
assertEquals("Hello, World!", HelloWorld.hello(""))
|
17
|
-
assertEquals("Hello, World!", HelloWorld.hello(" "))
|
18
|
-
}
|
19
|
-
|
20
14
|
@Ignore
|
21
|
-
|
22
|
-
|
23
|
-
//This isn't advised in Kotlin but demonstrates the null safety in Kotlin
|
24
|
-
assertEquals("Hello, World!", HelloWorld.hello(null))
|
15
|
+
fun helloSampleName() {
|
16
|
+
assertEquals("Hello, Alice!", hello("Alice"))
|
25
17
|
}
|
26
18
|
|
27
|
-
@Ignore
|
28
19
|
@Test
|
29
|
-
|
30
|
-
|
20
|
+
@Ignore
|
21
|
+
fun helloBlankName() {
|
22
|
+
assertEquals("Hello, World!", hello(" "))
|
31
23
|
}
|
32
24
|
|
33
|
-
@Ignore
|
34
25
|
@Test
|
26
|
+
@Ignore
|
35
27
|
fun helloAnotherSampleName() {
|
36
|
-
assertEquals("Hello, Bob!",
|
28
|
+
assertEquals("Hello, Bob!", hello("Bob"))
|
37
29
|
}
|
38
30
|
}
|
@@ -3,4 +3,4 @@ machine:
|
|
3
3
|
version: "8.2"
|
4
4
|
test:
|
5
5
|
override:
|
6
|
-
-
|
6
|
+
- xcodebuild test -project 'xcodeProject/ObjectiveC.xcodeproj' -scheme 'xobjectivecTest' -sdk macosx10.12
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/tracks/pony/config.json
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
use "collections"
|
2
|
+
use "itertools"
|
3
|
+
|
4
|
+
primitive PascalsTriangle
|
5
|
+
fun rows(count: USize): Array[Array[USize]] =>
|
6
|
+
Iter[USize](Range(0, count))
|
7
|
+
.map[Array[USize]]({(n: USize): Array[USize] => PascalsTriangle.row(n)})
|
8
|
+
.collect(Array[Array[USize]](count))
|
9
|
+
|
10
|
+
fun row(n: USize): Array[USize] =>
|
11
|
+
let r = Array[USize](n).>push(1)
|
12
|
+
for i in Range(1, n + 1) do
|
13
|
+
try
|
14
|
+
let last = r(i - 1)
|
15
|
+
r.push((last * ((n + 1) - i)) / i)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
r
|
@@ -0,0 +1,31 @@
|
|
1
|
+
use "collections"
|
2
|
+
use "ponytest"
|
3
|
+
|
4
|
+
actor Main is TestList
|
5
|
+
new create(env: Env) =>
|
6
|
+
PonyTest(env, this)
|
7
|
+
|
8
|
+
fun tag tests(test: PonyTest) =>
|
9
|
+
test(_TestPascalsTriangle)
|
10
|
+
|
11
|
+
class iso _TestPascalsTriangle is UnitTest
|
12
|
+
fun name(): String => "pascals-triangle"
|
13
|
+
|
14
|
+
fun apply(h: TestHelper) ? =>
|
15
|
+
assert_rows_eq(h, 0, Array[Array[USize]])
|
16
|
+
assert_rows_eq(h, 1, [[1]])
|
17
|
+
assert_rows_eq(h, 2, [[1], [1, 1]])
|
18
|
+
assert_rows_eq(h, 3, [[1], [1, 1], [1, 2, 1]])
|
19
|
+
assert_rows_eq(h, 4, [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]])
|
20
|
+
|
21
|
+
fun assert_rows_eq(
|
22
|
+
h: TestHelper,
|
23
|
+
count: USize,
|
24
|
+
expected: Array[Array[USize]],
|
25
|
+
loc: SourceLoc = __loc)
|
26
|
+
? =>
|
27
|
+
let t = PascalsTriangle.rows(count)
|
28
|
+
h.assert_eq[USize](t.size(), expected.size())
|
29
|
+
for i in Range(0, expected.size()) do
|
30
|
+
h.assert_array_eq[USize](expected(i), t(i))
|
31
|
+
end
|
data/tracks/r/config.json
CHANGED
@@ -69,6 +69,26 @@
|
|
69
69
|
"difficulty": 1,
|
70
70
|
"slug": "sum-of-multiples",
|
71
71
|
"topics": []
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"difficulty": 1,
|
75
|
+
"slug": "grains",
|
76
|
+
"topics": []
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"difficulty": 1,
|
80
|
+
"slug": "secret-handshake",
|
81
|
+
"topics": []
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"difficulty": 1,
|
85
|
+
"slug": "phone-number",
|
86
|
+
"topics": []
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"difficulty": 1,
|
90
|
+
"slug": "sieve",
|
91
|
+
"topics": []
|
72
92
|
}
|
73
93
|
]
|
74
94
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
source('./square.R')
|
2
|
+
suppressPackageStartupMessages({ require(testthat) })
|
3
|
+
|
4
|
+
test_that("Case 1", {
|
5
|
+
expect_equal(square(1), 1)
|
6
|
+
})
|
7
|
+
|
8
|
+
test_that("Case 2", {
|
9
|
+
expect_equal(square(2), 2)
|
10
|
+
})
|
11
|
+
|
12
|
+
test_that("Case 3", {
|
13
|
+
expect_equal(square(3), 4)
|
14
|
+
})
|
15
|
+
|
16
|
+
test_that("Case 4", {
|
17
|
+
expect_equal(square(4), 8)
|
18
|
+
})
|
19
|
+
|
20
|
+
test_that("Case 16", {
|
21
|
+
expect_equal(square(16), 32768)
|
22
|
+
})
|
23
|
+
|
24
|
+
test_that("Case 32", {
|
25
|
+
expect_equal(square(32), 2147483648)
|
26
|
+
})
|
27
|
+
|
28
|
+
test_that("Case 1", {
|
29
|
+
expect_equal(square(64), 9223372036854775808)
|
30
|
+
})
|
31
|
+
|
32
|
+
test_that("square 0 raises an exception", {
|
33
|
+
expect_error(square(0))
|
34
|
+
})
|
35
|
+
|
36
|
+
test_that("negative square raises an exception", {
|
37
|
+
expect_error(square(-1))
|
38
|
+
})
|
39
|
+
|
40
|
+
test_that("square greater than 64 raises an exception", {
|
41
|
+
expect_error(square(65))
|
42
|
+
})
|
43
|
+
|
44
|
+
test_that("returns the total number of square on the board", {
|
45
|
+
expect_equal(total(), 18446744073709551615)
|
46
|
+
})
|
47
|
+
|
48
|
+
|
49
|
+
print("All tests passed!")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
parsePhoneNumber <- function(numberString) {
|
2
|
+
|
3
|
+
# If the phone number is less than 10 digits assume that it is bad number
|
4
|
+
# If the phone number is 10 digits assume that it is good
|
5
|
+
# If the phone number is 11 digits and the first number is 1, trim the 1 and use the last 10 digits
|
6
|
+
# If the phone number is 11 digits and the first number is not 1, then it is a bad number
|
7
|
+
# If the phone number is more than 11 digits assume that it is a bad number
|
8
|
+
|
9
|
+
# Check for letters
|
10
|
+
if (grepl("[A-z]", numberString)) {
|
11
|
+
return (NULL)
|
12
|
+
}
|
13
|
+
|
14
|
+
# Remove non-digit characters from number string
|
15
|
+
cleaned <- gsub("[^0-9]", "", numberString)
|
16
|
+
|
17
|
+
if (nchar(cleaned) < 10) {
|
18
|
+
NULL
|
19
|
+
}
|
20
|
+
else if (nchar(cleaned) == 10) {
|
21
|
+
cleaned
|
22
|
+
}
|
23
|
+
else if (nchar(cleaned) == 11 & substr(cleaned, 1, 1) == "1") {
|
24
|
+
substr(cleaned, 2, 11)
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
NULL
|
28
|
+
}
|
29
|
+
|
30
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
source('./phone-number.R')
|
2
|
+
suppressPackageStartupMessages({ require(testthat) })
|
3
|
+
|
4
|
+
test_that("cleans the number", {
|
5
|
+
expect_equal(parsePhoneNumber("(123) 456-7890"), "1234567890")
|
6
|
+
})
|
7
|
+
|
8
|
+
test_that("cleans numbers with dots", {
|
9
|
+
expect_equal(parsePhoneNumber("123.456.7890"), "1234567890")
|
10
|
+
})
|
11
|
+
|
12
|
+
test_that("cleans numbers with multiple spaces", {
|
13
|
+
expect_equal(parsePhoneNumber("123 456 7890 "), "1234567890")
|
14
|
+
})
|
15
|
+
|
16
|
+
test_that("invalid when 9 digits", {
|
17
|
+
expect_equal(parsePhoneNumber("123456789"), NULL)
|
18
|
+
})
|
19
|
+
|
20
|
+
test_that("invalid when 11 digits", {
|
21
|
+
expect_equal(parsePhoneNumber("21234567890"), NULL)
|
22
|
+
})
|
23
|
+
|
24
|
+
test_that("valid when 11 digits and starting with 1", {
|
25
|
+
expect_equal(parsePhoneNumber("11234567890"), "1234567890")
|
26
|
+
})
|
27
|
+
|
28
|
+
test_that("invalid when 12 digits", {
|
29
|
+
expect_equal(parsePhoneNumber("321234567890"), NULL)
|
30
|
+
})
|
31
|
+
|
32
|
+
test_that("invalid with letters", {
|
33
|
+
expect_equal(parsePhoneNumber("123-abc-7890"), NULL)
|
34
|
+
})
|
35
|
+
|
36
|
+
test_that("invalid with punctuations", {
|
37
|
+
expect_equal(parsePhoneNumber("123-@:!-7890"), NULL)
|
38
|
+
})
|
39
|
+
|
40
|
+
test_that("invalid with right number of digits but letters mixed in", {
|
41
|
+
expect_equal(parsePhoneNumber("1a2b3c4d5e6f7g8h9i0j"), NULL)
|
42
|
+
})
|
43
|
+
|
44
|
+
print("All tests passed!")
|
@@ -0,0 +1,26 @@
|
|
1
|
+
handshake <- function(n) {
|
2
|
+
|
3
|
+
# 1 = wink
|
4
|
+
# 10 = double blink
|
5
|
+
# 100 = close your eyes
|
6
|
+
# 1000 = jump
|
7
|
+
# 10000 = reverse
|
8
|
+
actions = c("wink", "double blink", "close your eyes", "jump")
|
9
|
+
|
10
|
+
bin = intToBits(n)
|
11
|
+
|
12
|
+
events = c()
|
13
|
+
|
14
|
+
for (i in 1:4){
|
15
|
+
if (bin[i] > 0) {
|
16
|
+
events = c(events, actions[i])
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
if (bin[5] > 0) {
|
21
|
+
events = rev(events)
|
22
|
+
}
|
23
|
+
|
24
|
+
events
|
25
|
+
|
26
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
source('./secret-handshake.R')
|
2
|
+
suppressPackageStartupMessages({ require(testthat) })
|
3
|
+
|
4
|
+
test_that("wink for 1", {
|
5
|
+
expect_equal(handshake(1), c("wink"))
|
6
|
+
})
|
7
|
+
|
8
|
+
test_that("double blink for 10", {
|
9
|
+
expect_equal(handshake(2), c("double blink"))
|
10
|
+
})
|
11
|
+
|
12
|
+
test_that("close your eyes for 100", {
|
13
|
+
expect_equal(handshake(4), c("close your eyes"))
|
14
|
+
})
|
15
|
+
|
16
|
+
test_that("jump for 1000", {
|
17
|
+
expect_equal(handshake(8), c("jump"))
|
18
|
+
})
|
19
|
+
|
20
|
+
test_that("combine two actions", {
|
21
|
+
expect_equal(handshake(3), c("wink", "double blink"))
|
22
|
+
})
|
23
|
+
|
24
|
+
test_that("reverse two actions", {
|
25
|
+
expect_equal(handshake(19), c("double blink", "wink"))
|
26
|
+
})
|
27
|
+
|
28
|
+
test_that("reversing one action gives the same action", {
|
29
|
+
expect_equal(handshake(24), c("jump"))
|
30
|
+
})
|
31
|
+
|
32
|
+
test_that("reversing no actions still gives no actions", {
|
33
|
+
expect_equal(handshake(16), c())
|
34
|
+
})
|
35
|
+
|
36
|
+
test_that("all possible actions", {
|
37
|
+
expect_equal(handshake(15), c("wink", "double blink", "close your eyes", "jump"))
|
38
|
+
})
|
39
|
+
|
40
|
+
test_that("reverse all possible actions", {
|
41
|
+
expect_equal(handshake(31), c("jump", "close your eyes", "double blink", "wink"))
|
42
|
+
})
|
43
|
+
|
44
|
+
test_that("do nothing for zero", {
|
45
|
+
expect_equal(handshake(0), c())
|
46
|
+
})
|
47
|
+
|
48
|
+
test_that("do nothing if lower 5 bits not set", {
|
49
|
+
expect_equal(handshake(32), c())
|
50
|
+
})
|
51
|
+
|
52
|
+
print("All tests passed!")
|