trackler 2.0.5.0 → 2.0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/crystal/exercises/largest-series-product/spec/largest_series_product_spec.cr +32 -16
  4. data/tracks/fsharp/exercises/grep/GrepTest.fs +2 -1
  5. data/tracks/fsharp/exercises/linked-list/Example.fs +24 -17
  6. data/tracks/fsharp/exercises/linked-list/HINTS.md +14 -0
  7. data/tracks/fsharp/exercises/linked-list/LinkedListTest.fs +73 -80
  8. data/tracks/lua/config.json +8 -0
  9. data/tracks/lua/exercises/meetup/example.lua +61 -0
  10. data/tracks/lua/exercises/meetup/meetup_spec.lua +858 -0
  11. data/tracks/purescript/.travis.yml +4 -0
  12. data/tracks/purescript/config.json +7 -0
  13. data/tracks/purescript/exercises/bob/bower.json +17 -0
  14. data/tracks/purescript/exercises/bob/examples/src/Bob.purs +49 -0
  15. data/tracks/purescript/exercises/bob/src/Bob.purs +3 -0
  16. data/tracks/purescript/exercises/bob/test/Main.purs +82 -0
  17. data/tracks/ruby/.gitignore +1 -0
  18. data/tracks/ruby/Gemfile +2 -0
  19. data/tracks/ruby/Rakefile +6 -0
  20. data/tracks/ruby/bin/executable-tests-check +1 -1
  21. data/tracks/ruby/config.json +2 -1
  22. data/tracks/ruby/lib/generator.rb +8 -3
  23. data/tracks/ruby/test/generator_test.rb +21 -0
  24. data/tracks/ruby/test/test_helper.rb +16 -0
  25. data/tracks/scala/config.json +17 -0
  26. data/tracks/scala/exercises/allergies/example.scala +1 -5
  27. data/tracks/scala/exercises/allergies/src/main/scala/Allergies.scala +11 -0
  28. data/tracks/scala/exercises/allergies/src/test/scala/AllergiesTest.scala +14 -14
  29. data/tracks/scala/exercises/atbash-cipher/example.scala +4 -4
  30. data/tracks/scala/exercises/atbash-cipher/src/main/scala/Atbash.scala +3 -0
  31. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +9 -9
  32. data/tracks/scala/exercises/crypto-square/example.scala +1 -1
  33. data/tracks/scala/exercises/crypto-square/src/main/scala/CryptoSquare.scala +11 -0
  34. data/tracks/scala/exercises/crypto-square/src/test/scala/CryptoSquareTest.scala +17 -17
  35. data/tracks/scala/exercises/queen-attack/example.scala +2 -1
  36. data/tracks/scala/exercises/queen-attack/src/main/scala/Queens.scala +8 -0
  37. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +9 -9
  38. data/tracks/scala/exercises/raindrops/example.scala +1 -5
  39. data/tracks/scala/exercises/raindrops/src/main/scala/Raindrops.scala +4 -0
  40. data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +16 -16
  41. data/tracks/swift/README.md +16 -16
  42. metadata +16 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a547beacb50c81feb42130ca6f08bf659a9f25d6
4
- data.tar.gz: 404df6144bbbc9c11973c8148cbdb29bb489faef
3
+ metadata.gz: d08f22cd9cd8ad91c9bd2789324bc7e368e547c8
4
+ data.tar.gz: 1f551cc425ba3ee5e263c1f6dcdd3a8716627764
5
5
  SHA512:
6
- metadata.gz: 258a478b5aaa4681af90b72fce55382234fa86e62313d5fbdb7380693d4c49fe388ac4c10d89f238813db163a996da6dbce4f91039ed389ddb422264ffd5bfca
7
- data.tar.gz: 5c129cd1186b2cc4180ec503de3a3f156d0baf4583cc8cb5644d26f69ea6bd2ff196b19568b591d4b861e45445d148f58a0258755e15599a85bba2cfcd86deaa
6
+ metadata.gz: 0b19b0c48ffe4addf76f7208a016a38f465ba69ce4e49d592399ee0162943b8c016e7eaccc87e9f1af631fa495a2a7b5852c5977033db463f77ac59775dae49f
7
+ data.tar.gz: 725afee0fbc6423574cc17e67ff2992ca01464d2a441612be381161ae78f6f5e5a2b4dc5abafa95c9563c0886051e148eb3c3920b0c9c2512170d2ad1af0506b
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.5.0"
2
+ VERSION = "2.0.5.1"
3
3
  end
@@ -6,52 +6,68 @@ describe "Series" do
6
6
  it "can find the largest product of 2 with numbers in order" do
7
7
  Series.new("0123456789").largest_product(2).should eq 72
8
8
  end
9
- it "can find the largest product of 2" do
9
+
10
+ pending "can find the largest product of 2" do
10
11
  Series.new("576802143").largest_product(2).should eq 48
11
12
  end
12
- it "finds the largest product if span equals length" do
13
+
14
+ pending "finds the largest product if span equals length" do
13
15
  Series.new("29").largest_product(2).should eq 18
14
16
  end
15
- it "can find the largest product of 3 with numbers in order" do
17
+
18
+ pending "can find the largest product of 3 with numbers in order" do
16
19
  Series.new("0123456789").largest_product(3).should eq 504
17
20
  end
18
- it "can find the largest product of 3" do
21
+
22
+ pending "can find the largest product of 3" do
19
23
  Series.new("1027839564").largest_product(3).should eq 270
20
24
  end
21
- it "can find the largest product of 5 with numbers in order" do
25
+
26
+ pending "can find the largest product of 5 with numbers in order" do
22
27
  Series.new("0123456789").largest_product(5).should eq 15120
23
28
  end
24
- it "can get the largest product of a big number" do
29
+
30
+ pending "can get the largest product of a big number" do
25
31
  Series.new("73167176531330624919225119674426574742355349194934").largest_product(6).should eq 23520
26
32
  end
27
- it "can get the largest product of a big number II" do
33
+
34
+ pending "can get the largest product of a big number II" do
28
35
  Series.new("52677741234314237566414902593461595376319419139427").largest_product(6).should eq 28350
29
36
  end
30
- it "can get the largest product of a big number (Project Euler)" do
37
+
38
+ pending "can get the largest product of a big number (Project Euler)" do
31
39
  Series.new("7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450").largest_product(13).should eq 23514624000
32
40
  end
33
- it "reports zero if the only digits are zero" do
41
+
42
+ pending "reports zero if the only digits are zero" do
34
43
  Series.new("0000").largest_product(2).should eq 0
35
44
  end
36
- it "reports zero if all spans include zero" do
45
+
46
+ pending "reports zero if all spans include zero" do
37
47
  Series.new("99099").largest_product(3).should eq 0
38
48
  end
39
- it "rejects span longer than string length" do
49
+
50
+ pending "rejects span longer than string length" do
40
51
  expect_raises(ArgumentError) { Series.new("123").largest_product(4) }
41
52
  end
42
- it "reports 1 for empty string and empty product (0 span)" do
53
+
54
+ pending "reports 1 for empty string and empty product (0 span)" do
43
55
  Series.new("").largest_product(0).should eq 1
44
56
  end
45
- it "reports 1 for nonempty string and empty product (0 span)" do
57
+
58
+ pending "reports 1 for nonempty string and empty product (0 span)" do
46
59
  Series.new("123").largest_product(0).should eq 1
47
60
  end
48
- it "rejects empty string and nonzero span" do
61
+
62
+ pending "rejects empty string and nonzero span" do
49
63
  expect_raises(ArgumentError) { Series.new("").largest_product(1) }
50
64
  end
51
- it "rejects invalid character in digits" do
65
+
66
+ pending "rejects invalid character in digits" do
52
67
  expect_raises(ArgumentError) { Series.new("1234a5").largest_product(2).should eq -1 }
53
68
  end
54
- it "rejects negative span" do
69
+
70
+ pending "rejects negative span" do
55
71
  expect_raises(ArgumentError) { Series.new("12345").largest_product(-1) }
56
72
  end
57
73
  end
@@ -44,6 +44,7 @@ That Shepherd, who first taught the chosen Seed
44
44
 
45
45
  [<OneTimeSetUp>]
46
46
  let setUp () =
47
+ Directory.SetCurrentDirectory(Path.GetTempPath());
47
48
  File.WriteAllText(iliadFileName, iliadContents)
48
49
  File.WriteAllText(midsummerNightFileName, midsummerNightContents)
49
50
  File.WriteAllText(paradiseLostFileName, paradiseLostContents)
@@ -329,4 +330,4 @@ let ``Multiple files, no matches, various flags`` (flags) =
329
330
 
330
331
  let expected = ""
331
332
 
332
- Assert.That(grep pattern flags files, Is.EqualTo(expected))
333
+ Assert.That(grep pattern flags files, Is.EqualTo(expected))
@@ -1,36 +1,43 @@
1
1
  module LinkedList
2
2
 
3
3
  type Element<'a> = { value: 'a; mutable prev: Element<'a> option; mutable next: Element<'a> option }
4
- type LinkedList<'a> = { first: Element<'a> option; last: Element<'a> option }
4
+ type LinkedList<'a> = { mutable first: Element<'a> option; mutable last: Element<'a> option }
5
5
 
6
- let mkLinkedList = { first = None; last = None }
6
+ let mkLinkedList () = { first = None; last = None }
7
7
 
8
- let addToEmpty newValue linkedList =
8
+ let addToEmpty newValue linkedList =
9
9
  let newElement = { value = newValue; prev = None; next = None }
10
- { linkedList with first = Some newElement; last = Some newElement }
10
+ linkedList.first <- Some newElement
11
+ linkedList.last <- Some newElement
11
12
 
12
13
  let pop linkedList =
13
14
  match linkedList.last with
14
15
  | None -> failwith "Cannot pop from empty list"
15
- | Some(x) -> x.value, { linkedList with last = x.prev }
16
+ | Some oldLast ->
17
+ linkedList.last <- oldLast.prev
18
+ linkedList.last |> Option.iter (fun el -> el.next <- None)
19
+ oldLast.value
16
20
 
17
21
  let shift linkedList =
18
22
  match linkedList.first with
19
23
  | None -> failwith "Cannot shift from empty list"
20
- | Some(x) -> x.value, { linkedList with first = x.next }
21
-
22
- let push newValue linkedList =
24
+ | Some oldFirst ->
25
+ linkedList.first <- oldFirst.next
26
+ linkedList.first |> Option.iter (fun el -> el.prev <- None)
27
+ oldFirst.value
28
+
29
+ let push newValue linkedList =
23
30
  match linkedList.last with
24
31
  | None -> addToEmpty newValue linkedList
25
- | Some(x) ->
26
- let last = Some { value = newValue; prev = linkedList.last; next = x.next }
27
- x.next <- last
28
- { linkedList with last = last }
32
+ | Some oldLast ->
33
+ let newLast = Some { value = newValue; prev = linkedList.last; next = None }
34
+ oldLast.next <- newLast
35
+ linkedList.last <- newLast
29
36
 
30
- let unshift newValue linkedList =
37
+ let unshift newValue linkedList =
31
38
  match linkedList.first with
32
39
  | None -> addToEmpty newValue linkedList
33
- | Some(x) ->
34
- let first = Some { value = newValue; prev = x.prev; next = linkedList.first }
35
- x.prev <- first
36
- { linkedList with first = first }
40
+ | Some oldFirst ->
41
+ let newFirst = Some { value = newValue; prev = None; next = linkedList.first }
42
+ oldFirst.prev <- newFirst
43
+ linkedList.first <- newFirst
@@ -0,0 +1,14 @@
1
+ ## Hints
2
+
3
+ A [doubly linked list](https://en.wikipedia.org/wiki/Doubly_linked_list) is a mutable data structure. As F# is a functional-first language, immutability is generally preferred, but there are language features that allow the use of mutation where it is required.
4
+
5
+ * The `mutable` keyword can be placed before `let` bindings and [record](https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/records) fields, allowing you to assign new values to them.
6
+
7
+ * [Class](https://fsharpforfunandprofit.com/posts/classes) properties can be made mutable by specifying a property setter with the `set` keyword.
8
+
9
+ Mutable bindings must be re-assigned with `<-`
10
+
11
+ ```fsharp
12
+ let mutable x = "initial value"
13
+ x <- "new value"
14
+ ```
@@ -5,117 +5,110 @@ open LinkedList
5
5
 
6
6
  [<Test>]
7
7
  let ``Push and pop are first in last out order`` () =
8
- let linkedList =
9
- mkLinkedList
10
- |> push 10
11
- |> push 20
8
+ let linkedList = mkLinkedList ()
9
+ linkedList |> push 10
10
+ linkedList |> push 20
12
11
 
13
- let (val', linkedList') = pop linkedList
14
- let (val'', _) = pop linkedList'
12
+ let val1 = pop linkedList
13
+ let val2 = pop linkedList
15
14
 
16
- Assert.That(val', Is.EqualTo(20))
17
- Assert.That(val'', Is.EqualTo(10))
15
+ Assert.That(val1, Is.EqualTo(20))
16
+ Assert.That(val2, Is.EqualTo(10))
18
17
 
19
- [<Test>]
20
- [<Ignore("Remove to run test")>]
18
+ [<Test>]
19
+ [<Ignore("Remove to run test")>]
21
20
  let ``Push and shift are first in first out order`` () =
22
- let linkedList =
23
- mkLinkedList
24
- |> push 10
25
- |> push 20
21
+ let linkedList = mkLinkedList ()
22
+ linkedList |> push 10
23
+ linkedList |> push 20
26
24
 
27
- let (val', linkedList') = shift linkedList
28
- let (val'', _) = shift linkedList'
25
+ let val1 = shift linkedList
26
+ let val2 = shift linkedList
29
27
 
30
- Assert.That(val', Is.EqualTo(10))
31
- Assert.That(val'', Is.EqualTo(20))
28
+ Assert.That(val1, Is.EqualTo(10))
29
+ Assert.That(val2, Is.EqualTo(20))
32
30
 
33
- [<Test>]
34
- [<Ignore("Remove to run test")>]
31
+ [<Test>]
32
+ [<Ignore("Remove to run test")>]
35
33
  let ``Unshift and shift are last in first out order`` () =
36
- let linkedList =
37
- mkLinkedList
38
- |> unshift 10
39
- |> unshift 20
34
+ let linkedList = mkLinkedList ()
35
+ linkedList |> unshift 10
36
+ linkedList |> unshift 20
40
37
 
41
- let (val', linkedList') = shift linkedList
42
- let (val'', _) = shift linkedList'
38
+ let val1 = shift linkedList
39
+ let val2 = shift linkedList
43
40
 
44
- Assert.That(val', Is.EqualTo(20))
45
- Assert.That(val'', Is.EqualTo(10))
41
+ Assert.That(val1, Is.EqualTo(20))
42
+ Assert.That(val2, Is.EqualTo(10))
46
43
 
47
- [<Test>]
44
+ [<Test>]
48
45
  [<Ignore("Remove to run test")>]
49
46
  let ``Unshift and pop are last in last out order`` () =
50
- let linkedList =
51
- mkLinkedList
52
- |> unshift 10
53
- |> unshift 20
47
+ let linkedList = mkLinkedList ()
48
+ linkedList |> unshift 10
49
+ linkedList |> unshift 20
54
50
 
55
- let (val', linkedList') = pop linkedList
56
- let (val'', _) = pop linkedList'
51
+ let val1 = pop linkedList
52
+ let val2 = pop linkedList
57
53
 
58
- Assert.That(val', Is.EqualTo(10))
59
- Assert.That(val'', Is.EqualTo(20))
54
+ Assert.That(val1, Is.EqualTo(10))
55
+ Assert.That(val2, Is.EqualTo(20))
60
56
 
61
- [<Test>]
57
+ [<Test>]
62
58
  [<Ignore("Remove to run test")>]
63
59
  let ``Push and pop can handle multiple values`` () =
64
- let linkedList =
65
- mkLinkedList
66
- |> push 10
67
- |> push 20
68
- |> push 30
60
+ let linkedList = mkLinkedList ()
61
+ linkedList |> push 10
62
+ linkedList |> push 20
63
+ linkedList |> push 30
69
64
 
70
- let (val', linkedList') = pop linkedList
71
- let (val'', linkedList'') = pop linkedList'
72
- let (val''', _) = pop linkedList''
65
+ let val1 = pop linkedList
66
+ let val2 = pop linkedList
67
+ let val3 = pop linkedList
73
68
 
74
- Assert.That(val', Is.EqualTo(30))
75
- Assert.That(val'', Is.EqualTo(20))
76
- Assert.That(val''', Is.EqualTo(10))
69
+ Assert.That(val1, Is.EqualTo(30))
70
+ Assert.That(val2, Is.EqualTo(20))
71
+ Assert.That(val3, Is.EqualTo(10))
77
72
 
78
- [<Test>]
73
+ [<Test>]
79
74
  [<Ignore("Remove to run test")>]
80
75
  let ``Unshift and shift can handle multiple values`` () =
81
- let linkedList =
82
- mkLinkedList
83
- |> unshift 10
84
- |> unshift 20
85
- |> unshift 30
76
+ let linkedList = mkLinkedList ()
77
+ linkedList |> unshift 10
78
+ linkedList |> unshift 20
79
+ linkedList |> unshift 30
86
80
 
87
- let (val', linkedList') = shift linkedList
88
- let (val'', linkedList'') = shift linkedList'
89
- let (val''', _) = shift linkedList''
81
+ let val1 = shift linkedList
82
+ let val2 = shift linkedList
83
+ let val3 = shift linkedList
90
84
 
91
- Assert.That(val', Is.EqualTo(30))
92
- Assert.That(val'', Is.EqualTo(20))
93
- Assert.That(val''', Is.EqualTo(10))
85
+ Assert.That(val1, Is.EqualTo(30))
86
+ Assert.That(val2, Is.EqualTo(20))
87
+ Assert.That(val3, Is.EqualTo(10))
94
88
 
95
- [<Test>]
89
+ [<Test>]
96
90
  [<Ignore("Remove to run test")>]
97
91
  let ``All methods of manipulating the linkedList can be used together`` () =
98
- let linkedList =
99
- mkLinkedList
100
- |> push 10
101
- |> push 20
92
+ let linkedList = mkLinkedList ()
93
+ linkedList |> push 10
94
+ linkedList |> push 20
95
+
96
+ let val1 = pop linkedList
102
97
 
103
- let (val', linkedList') = pop linkedList
98
+ Assert.That(val1, Is.EqualTo(20))
104
99
 
105
- Assert.That(val', Is.EqualTo(20))
100
+ linkedList |> push 30
101
+ let val2 = shift linkedList
106
102
 
107
- let linkedList'' = push 30 linkedList'
108
- let (val''', linkedList''') = shift linkedList''
103
+ Assert.That(val2, Is.EqualTo(10))
109
104
 
110
- Assert.That(val''', Is.EqualTo(10))
105
+ linkedList |> unshift 40
106
+ linkedList |> push 50
111
107
 
112
- let linkedList'''' = unshift 40 linkedList'''
113
- let linkedList''''' = push 50 linkedList''''
108
+ let val3 = shift linkedList
109
+ let val4 = pop linkedList
110
+ let val5 = shift linkedList
114
111
 
115
- let (val'''''', linkedList'''''') = shift linkedList'''''
116
- let (val''''''', linkedList''''''') = pop linkedList''''''
117
- let (val'''''''', _) = shift linkedList'''''''
118
-
119
- Assert.That(val'''''', Is.EqualTo(40))
120
- Assert.That(val''''''', Is.EqualTo(50))
121
- Assert.That(val'''''''', Is.EqualTo(30))
112
+ Assert.That(val3, Is.EqualTo(40))
113
+ Assert.That(val4, Is.EqualTo(50))
114
+ Assert.That(val5, Is.EqualTo(30))
@@ -433,6 +433,14 @@
433
433
  "filtering",
434
434
  "control-flow (loops)"
435
435
  ]
436
+ }, {
437
+ "slug": "meetup",
438
+ "difficulty": 6,
439
+ "topics": [
440
+ "time",
441
+ "control-flow (if-statements)",
442
+ "control-flow (loops)"
443
+ ]
436
444
  }, {
437
445
  "slug": "atbash-cipher",
438
446
  "difficulty": 3,
@@ -0,0 +1,61 @@
1
+ local day_name_to_number = {
2
+ Sunday = 1,
3
+ Monday = 2,
4
+ Tuesday = 3,
5
+ Wednesday = 4,
6
+ Thursday = 5,
7
+ Friday = 6,
8
+ Saturday = 7
9
+ }
10
+
11
+ local function matching_days(config)
12
+ local meetup_day = day_name_to_number[config.day]
13
+ local days = {}
14
+
15
+ for day = 1, math.huge do
16
+ local date = os.date('*t', os.time({
17
+ year = config.year,
18
+ month = config.month,
19
+ day = day
20
+ }))
21
+
22
+ if date.month ~= config.month then break end
23
+
24
+ if date.wday == meetup_day then
25
+ table.insert(days, day)
26
+ end
27
+ end
28
+
29
+ return days
30
+ end
31
+
32
+ local function first_teenth(t)
33
+ for _, v in ipairs(t) do
34
+ if v > 12 then return v end
35
+ end
36
+ end
37
+
38
+ local function last(t)
39
+ return t[#t]
40
+ end
41
+
42
+ local function ordinal(t, which)
43
+ return t[({
44
+ first = 1,
45
+ second = 2,
46
+ third = 3,
47
+ fourth = 4
48
+ })[which]]
49
+ end
50
+
51
+ return function(config)
52
+ local days = matching_days(config)
53
+
54
+ if config.week == 'teenth' then
55
+ return first_teenth(days)
56
+ elseif config.week == 'last' then
57
+ return last(days)
58
+ else
59
+ return ordinal(days, config.week)
60
+ end
61
+ end