trackler 2.0.6.34 → 2.0.6.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/change/canonical-data.json +6 -0
  3. data/common/exercises/luhn/canonical-data.json +35 -0
  4. data/common/exercises/rotational-cipher/cannonical-data.json +70 -0
  5. data/common/exercises/rotational-cipher/description.md +30 -0
  6. data/common/exercises/rotational-cipher/metadata.yml +4 -0
  7. data/common/exercises/run-length-encoding/description.md +7 -1
  8. data/lib/trackler/version.rb +1 -1
  9. data/tracks/elixir/exercises/run-length-encoding/example.exs +15 -4
  10. data/tracks/elixir/exercises/run-length-encoding/rle.exs +2 -2
  11. data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +28 -11
  12. data/tracks/go/exercises/bob/bob_test.go +4 -1
  13. data/tracks/go/exercises/bracket-push/bracket_push_test.go +5 -2
  14. data/tracks/go/exercises/circular-buffer/circular_buffer_test.go +6 -6
  15. data/tracks/go/exercises/clock/clock_test.go +4 -1
  16. data/tracks/go/exercises/connect/connect_test.go +4 -1
  17. data/tracks/go/exercises/crypto-square/crypto_square_test.go +5 -2
  18. data/tracks/go/exercises/luhn/luhn_test.go +1 -1
  19. data/tracks/javascript/exercises/leap/leap.js +1 -1
  20. data/tracks/julia/.travis.yml +0 -2
  21. data/tracks/julia/config.json +41 -0
  22. data/tracks/julia/exercises/custom-set/HINTS.md +1 -0
  23. data/tracks/julia/exercises/custom-set/custom-set.jl +0 -0
  24. data/tracks/julia/exercises/custom-set/example.jl +51 -0
  25. data/tracks/julia/exercises/custom-set/runtests.jl +200 -0
  26. data/tracks/julia/exercises/isogram/example.jl +11 -0
  27. data/tracks/julia/exercises/isogram/isogram.jl +3 -0
  28. data/tracks/julia/exercises/isogram/runtests.jl +35 -0
  29. data/tracks/julia/exercises/luhn/example.jl +16 -0
  30. data/tracks/julia/exercises/luhn/luhn.jl +0 -0
  31. data/tracks/julia/exercises/luhn/runtests.jl +31 -0
  32. data/tracks/julia/exercises/nucleotide-count/example.jl +8 -0
  33. data/tracks/julia/exercises/nucleotide-count/nucleotide-count.jl +3 -0
  34. data/tracks/julia/exercises/nucleotide-count/runtests.jl +19 -0
  35. data/tracks/kotlin/.travis.yml +9 -1
  36. data/tracks/kotlin/README.md +117 -11
  37. data/tracks/kotlin/bin/journey-test.sh +279 -0
  38. data/tracks/kotlin/docs/INSTALLATION.md +193 -97
  39. data/tracks/kotlin/docs/TESTS.md +72 -137
  40. data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +50 -0
  41. data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +693 -0
  42. data/tracks/kotlin/exercises/hello-world/src/example/kotlin/HelloWorld.kt +2 -30
  43. data/tracks/kotlin/exercises/hello-world/src/main/kotlin/HelloWorld.kt +2 -30
  44. data/tracks/kotlin/exercises/hello-world/src/test/kotlin/HelloWorldTest.kt +11 -19
  45. data/tracks/objective-c/circle.yml +1 -1
  46. data/tracks/perl6/exercises/atbash-cipher/{cipher.t → atbash-cipher.t} +0 -0
  47. data/tracks/perl6/exercises/linked-list/linked-list.t +0 -0
  48. data/tracks/perl6/exercises/phone-number/{phone.t → phone-number.t} +0 -0
  49. data/tracks/perl6/exercises/rna-transcription/{rna_transcription.t → rna-transcription.t} +0 -0
  50. data/tracks/perl6/exercises/robot-name/{robot.t → robot-name.t} +0 -0
  51. data/tracks/perl6/exercises/scrabble-score/{scrabble_score.t → scrabble-score.t} +0 -0
  52. data/tracks/perl6/exercises/word-count/{word_count.t → word-count.t} +0 -0
  53. data/tracks/pony/config.json +9 -0
  54. data/tracks/pony/exercises/pascals-triangle/example.pony +18 -0
  55. data/tracks/pony/exercises/pascals-triangle/test.pony +31 -0
  56. data/tracks/r/config.json +20 -0
  57. data/tracks/r/exercises/grains/example.R +16 -0
  58. data/tracks/r/exercises/grains/grains.R +7 -0
  59. data/tracks/r/exercises/grains/test_grains.R +49 -0
  60. data/tracks/r/exercises/phone-number/example.R +30 -0
  61. data/tracks/r/exercises/phone-number/phone-number.R +3 -0
  62. data/tracks/r/exercises/phone-number/test_phone-number.R +44 -0
  63. data/tracks/r/exercises/secret-handshake/example.R +26 -0
  64. data/tracks/r/exercises/secret-handshake/secret-handshake.R +3 -0
  65. data/tracks/r/exercises/secret-handshake/test_secret-handshake.R +52 -0
  66. data/tracks/r/exercises/sieve/example.R +16 -0
  67. data/tracks/r/exercises/sieve/sieve.R +3 -0
  68. data/tracks/r/exercises/sieve/test_sieve.R +37 -0
  69. data/tracks/rust/config.json +11 -0
  70. data/tracks/rust/exercises/rotational-cipher/Cargo.lock +4 -0
  71. data/tracks/rust/exercises/rotational-cipher/Cargo.toml +4 -0
  72. data/tracks/rust/exercises/rotational-cipher/example.rs +16 -0
  73. data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +61 -0
  74. data/tracks/swift/circle.yml +6 -0
  75. metadata +46 -8
@@ -1,31 +1,3 @@
1
- /**
2
- * Simple HelloWorld singleton class as defined by the `Kotlin object keyword`.
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
- * Simple HelloWorld singleton class as defined by the `Kotlin object keyword`.
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!", HelloWorld.hello())
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
- @Test
22
- fun helloNullName() {
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
- fun helloSampleName() {
30
- assertEquals("Hello, Alice!", HelloWorld.hello("Alice"))
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!", HelloWorld.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
- -xctool test -project 'xcodeProject/ObjectiveC.xcodeproj' -scheme 'xobjectivecTest' -sdk macosx10.11 -reporter json-compilation-database:compile_commands.json -reporter plain:plain-output.txt -reporter pretty
6
+ - xcodebuild test -project 'xcodeProject/ObjectiveC.xcodeproj' -scheme 'xobjectivecTest' -sdk macosx10.12
File without changes
@@ -87,6 +87,15 @@
87
87
  "strings",
88
88
  "iterators"
89
89
  ]
90
+ },
91
+ {
92
+ "slug": "pascals-triangle",
93
+ "difficulty": 1,
94
+ "topics": [
95
+ "math",
96
+ "iterators",
97
+ "arrays"
98
+ ]
90
99
  }
91
100
  ]
92
101
  }
@@ -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,16 @@
1
+ square <- function(n) {
2
+
3
+ if (n > 0 & n < 65) {
4
+ 2^(n-1)
5
+ }
6
+ else {
7
+ stop("Input value should be between 1 and 64")
8
+ }
9
+
10
+ }
11
+
12
+ total <- function() {
13
+
14
+ sum(2^(0:63))
15
+
16
+ }
@@ -0,0 +1,7 @@
1
+ square <- function(n) {
2
+
3
+ }
4
+
5
+ total <- function() {
6
+
7
+ }
@@ -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,3 @@
1
+ parsePhoneNumber <- function(numberString) {
2
+
3
+ }
@@ -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,3 @@
1
+ handshake <- function(n) {
2
+
3
+ }
@@ -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!")