trackler 2.0.5.13 → 2.0.5.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/common/.travis.yml +1 -0
  3. data/common/bin/check_required_files_present +55 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dpr +60 -0
  6. data/tracks/pascal/exercises/Hello-World/TestHelloWorld.dproj +176 -0
  7. data/tracks/pascal/exercises/Hello-World/uHelloWorldExample.pas +24 -0
  8. data/tracks/pascal/exercises/Hello-World/uTestHelloWorld.pas +65 -0
  9. data/tracks/pascal/exercises/allergies/AllergyTests.dpr +60 -0
  10. data/tracks/pascal/exercises/allergies/AllergyTests.dproj +176 -0
  11. data/tracks/pascal/exercises/allergies/uAllergiesExample.pas +67 -0
  12. data/tracks/pascal/exercises/allergies/uAllergyTests.pas +177 -0
  13. data/tracks/pascal/exercises/bank-account/BankAccountTests.dpr +60 -0
  14. data/tracks/pascal/exercises/bank-account/BankAccountTests.dproj +176 -0
  15. data/tracks/pascal/exercises/bank-account/uBankAccountExample.pas +96 -0
  16. data/tracks/pascal/exercises/bank-account/uBankAccountTests.pas +140 -0
  17. data/tracks/pascal/exercises/beer-song/BeerSongTests.dpr +60 -0
  18. data/tracks/pascal/exercises/beer-song/BeerSongTests.dproj +176 -0
  19. data/tracks/pascal/exercises/beer-song/uBeerSongExample.pas +45 -0
  20. data/tracks/pascal/exercises/beer-song/uBeerSongTests.pas +84 -0
  21. data/tracks/pascal/exercises/binary-search/BinarySearchTest.dpr +60 -0
  22. data/tracks/pascal/exercises/binary-search/BinarySearchTest.dproj +176 -0
  23. data/tracks/pascal/exercises/binary-search/uBinarySearchExample.pas +40 -0
  24. data/tracks/pascal/exercises/binary-search/uBinarySearchTest.pas +132 -0
  25. data/tracks/pascal/exercises/bob/BobTests.dpr +60 -0
  26. data/tracks/pascal/exercises/bob/BobTests.dproj +176 -0
  27. data/tracks/pascal/exercises/bob/uBobExample.pas +47 -0
  28. data/tracks/pascal/exercises/bob/uBobTests.pas +180 -0
  29. data/tracks/pascal/exercises/book-store/BookStoreTests.dpr +60 -0
  30. data/tracks/pascal/exercises/book-store/BookStoreTests.dproj +176 -0
  31. data/tracks/pascal/exercises/book-store/uBookStoreExample.pas +144 -0
  32. data/tracks/pascal/exercises/book-store/uBookStoreTests.pas +56 -0
  33. data/tracks/pascal/exercises/bowling/BowlingTests.dpr +60 -0
  34. data/tracks/pascal/exercises/bowling/BowlingTests.dproj +176 -0
  35. data/tracks/pascal/exercises/bowling/uBowlingExample.pas +105 -0
  36. data/tracks/pascal/exercises/bowling/uBowlingTests.pas +101 -0
  37. data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dpr +60 -0
  38. data/tracks/pascal/exercises/circular-buffer/CircularBufferTests.dproj +176 -0
  39. data/tracks/pascal/exercises/circular-buffer/uCircularBufferExample.pas +72 -0
  40. data/tracks/pascal/exercises/circular-buffer/uCircularBufferTests.pas +249 -0
  41. data/tracks/pascal/exercises/clock/ClockTest.dpr +60 -0
  42. data/tracks/pascal/exercises/clock/ClockTest.dproj +176 -0
  43. data/tracks/pascal/exercises/clock/uClockExample.pas +54 -0
  44. data/tracks/pascal/exercises/clock/uClockTest.pas +157 -0
  45. data/tracks/pascal/exercises/etl/ETLtests.dpr +60 -0
  46. data/tracks/pascal/exercises/etl/ETLtests.dproj +176 -0
  47. data/tracks/pascal/exercises/etl/uETLexample.pas +25 -0
  48. data/tracks/pascal/exercises/etl/uETLtests.pas +191 -0
  49. data/tracks/pascal/exercises/hamming/Hamming.dpr +60 -0
  50. data/tracks/pascal/exercises/hamming/Hamming.dproj +176 -0
  51. data/tracks/pascal/exercises/hamming/uHammingExample.pas +24 -0
  52. data/tracks/pascal/exercises/hamming/uHammingTests.pas +165 -0
  53. data/tracks/pascal/exercises/leap/LeapTest.dpr +60 -0
  54. data/tracks/pascal/exercises/leap/LeapTest.dproj +176 -0
  55. data/tracks/pascal/exercises/leap/uLeapExample.pas +17 -0
  56. data/tracks/pascal/exercises/leap/uLeapTests.pas +81 -0
  57. data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dpr +60 -0
  58. data/tracks/pascal/exercises/nucleotide-count/NucleotideCountTest.dproj +176 -0
  59. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountExample.pas +72 -0
  60. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountTest.pas +190 -0
  61. data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dpr +60 -0
  62. data/tracks/pascal/exercises/perfect-numbers/PerfectNumbersTest.dproj +176 -0
  63. data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersExample.pas +34 -0
  64. data/tracks/pascal/exercises/perfect-numbers/uPerfectNumbersTest.pas +48 -0
  65. data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dpr +60 -0
  66. data/tracks/pascal/exercises/phone-number/PhoneNumberTests.dproj +176 -0
  67. data/tracks/pascal/exercises/phone-number/uPhoneNumberExample.pas +102 -0
  68. data/tracks/pascal/exercises/phone-number/uPhoneNumberTests.pas +138 -0
  69. data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +1 -1
  70. data/tracks/ruby/Gemfile +0 -1
  71. data/tracks/ruby/Makefile +2 -1
  72. data/tracks/ruby/Rakefile +3 -0
  73. data/tracks/ruby/exercises/simple-linked-list/.meta/.version +1 -0
  74. data/tracks/ruby/exercises/simple-linked-list/example.rb +39 -48
  75. data/tracks/ruby/exercises/simple-linked-list/simple_linked_list_test.rb +99 -125
  76. data/tracks/ruby/exercises/wordy/.meta/.version +1 -0
  77. data/tracks/ruby/exercises/wordy/example.rb +4 -0
  78. data/tracks/ruby/exercises/wordy/example.tt +17 -0
  79. data/tracks/ruby/exercises/wordy/wordy_test.rb +66 -35
  80. data/tracks/ruby/lib/wordy_cases.rb +67 -0
  81. data/tracks/ruby/test/wordy_cases_test.rb +102 -0
  82. data/tracks/scala/config.json +7 -1
  83. data/tracks/scala/exercises/connect/{README.md → HINTS.md} +1 -12
  84. data/tracks/scala/exercises/connect/build.sbt +2 -2
  85. metadata +73 -3
@@ -122,7 +122,7 @@ class VariableLengthQuantityTest extends PHPUnit_Framework_TestCase
122
122
 
123
123
  $this->setExpectedException(OverflowException::class);
124
124
 
125
- vlq_decode([0xff, 0xff, 0xff, 0xff, 0xff]);
125
+ vlq_decode([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f]);
126
126
  }
127
127
 
128
128
  public function testChainedDecodeEncodeGivesOriginalBytes()
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'minitest'
4
- gem 'rainbow', '>= 2.1.0', '< 2.2.0'
5
4
  gem 'rubocop', '0.36.0'
6
5
  gem 'simplecov'
7
6
  gem 'rake'
@@ -1,3 +1,5 @@
1
+ .PHONY: test
2
+
1
3
  # assignments
2
4
  ASSIGNMENT ?= ""
3
5
  IGNOREDIRS := "^(\.git|bin|docs|lib|exercises)$$"
@@ -33,4 +35,3 @@ test:
33
35
  @for assignment in $(ASSIGNMENTS); do \
34
36
  ASSIGNMENT=$$assignment $(MAKE) -s test-assignment || exit 1;\
35
37
  done
36
-
@@ -1,6 +1,9 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
 
4
+ desc 'rake with no argument will run "rake test"'
5
+ task default: :test
6
+
4
7
  Rake::TestTask.new do |task|
5
8
  task.pattern = 'test/*_test.rb'
6
9
  end
@@ -1,68 +1,59 @@
1
1
  class Element
2
- attr_reader :datum
2
+ attr_reader :datum
3
3
  attr_accessor :next
4
-
5
- def initialize(datum, next_element=nil)
6
- @datum = datum
7
- @next = next_element
8
- end
9
-
10
- def tail?
11
- @next.nil?
4
+ def initialize(value)
5
+ @datum = value
6
+ @next = nil
12
7
  end
13
8
  end
14
9
 
15
10
  class SimpleLinkedList
16
- attr_reader :size
17
- attr_reader :head
18
-
19
- def initialize
20
- @head = nil
21
- @size = 0
11
+ def initialize(array = [])
12
+ create_from_array(array)
22
13
  end
23
14
 
24
- def push(datum)
25
- e = Element.new(datum, @head)
26
- @head = e
27
- @size += 1
28
- end
29
-
30
- def empty?
31
- @size.zero?
15
+ def to_a
16
+ result = []
17
+ pointer = @head
18
+ while pointer
19
+ result << pointer.datum
20
+ pointer = pointer.next
21
+ end
22
+ result
32
23
  end
33
24
 
34
- def peek
35
- @head.nil? ? nil : @head.datum
25
+ def push(element)
26
+ element.next = @head unless @head.nil?
27
+ @head = element
28
+ self
36
29
  end
37
30
 
38
31
  def pop
39
- e, @head = @head, @head.next
40
- @size -= 1
41
- return e.datum
42
- end
43
-
44
- def each
45
- return enum_for(:each) unless block_given?
46
- current = head
47
- until current.nil?
48
- yield current.datum
49
- current = current.next
32
+ element = @head
33
+ @head = element.next if element
34
+ element
35
+ end
36
+
37
+ def reverse!
38
+ previous = nil
39
+ pointer = @head
40
+ while pointer
41
+ temp = pointer.next
42
+ pointer.next = previous
43
+ previous = pointer
44
+ pointer = temp
50
45
  end
46
+ @head = previous
47
+ self
51
48
  end
52
49
 
53
- def to_a
54
- each.to_a
55
- end
50
+ private
56
51
 
57
- def reverse
58
- each.with_object(SimpleLinkedList.new) { |datum, list| list.push(datum) }
52
+ def create_from_array(array)
53
+ array.each { |value| push(Element.new(value)) }
59
54
  end
55
+ end
60
56
 
61
- def self.from_a(a)
62
- new.tap do |list|
63
- a.to_a.reverse_each do |item|
64
- list.push(item)
65
- end
66
- end
67
- end
57
+ module BookKeeping
58
+ VERSION = 1
68
59
  end
@@ -1,189 +1,163 @@
1
- #!/usr/bin/env ruby
2
- gem 'minitest', '>= 5.0.0'
3
1
  require 'minitest/autorun'
4
-
5
2
  require_relative 'simple_linked_list'
6
3
 
7
4
  class LinkedListTest < Minitest::Test
8
- def test_element_datum
9
- e = Element.new(1)
10
- assert_equal 1, e.datum
11
- end
12
-
13
- def test_element_tail
14
- skip
15
- e = Element.new(1)
16
- assert e.tail?
5
+ def test_element
6
+ element = Element.new(1)
7
+ assert_equal 1, element.datum
17
8
  end
18
9
 
19
- def test_element_next_default
10
+ def test_element_can_hold_a_different_value
20
11
  skip
21
- e = Element.new(1)
22
- assert_nil e.next
12
+ element = Element.new(10)
13
+ assert_equal 10, element.datum
23
14
  end
24
15
 
25
- def test_element_next_initialization
16
+ def test_element_next
26
17
  skip
27
- e1 = Element.new(1)
28
- e2 = Element.new(2, e1)
29
- assert_equal e1, e2.next
18
+ element = Element.new(1)
19
+ assert_nil element.next
30
20
  end
31
21
 
32
- def test_empty_list_size
22
+ def test_element_next_can_be_assigned_to
33
23
  skip
34
- l = SimpleLinkedList.new
35
- assert_equal 0, l.size
24
+ first = Element.new(1)
25
+ second = Element.new(2)
26
+ first.next = second
27
+ assert_equal second, first.next
36
28
  end
37
29
 
38
- def test_empty_list_empty
30
+ def test_list_push
39
31
  skip
40
- l = SimpleLinkedList.new
41
- assert l.empty?
32
+ list = SimpleLinkedList.new
33
+ element = Element.new(1)
34
+ assert_equal list, list.push(element)
42
35
  end
43
36
 
44
- def test_pushing_element_on_list
37
+ def test_list_pop
45
38
  skip
46
- l = SimpleLinkedList.new
47
- l.push(1)
48
- assert_equal 1, l.size
39
+ list = SimpleLinkedList.new
40
+ element = Element.new(1)
41
+ list.push(element)
42
+ assert_equal element, list.pop
49
43
  end
50
44
 
51
- def test_empty_list_1_element
45
+ def test_list_pop_empty
52
46
  skip
53
- l = SimpleLinkedList.new
54
- l.push(1)
55
- refute l.empty?
47
+ list = SimpleLinkedList.new
48
+ assert_nil list.pop
56
49
  end
57
50
 
58
- def test_peeking_at_list
51
+ def test_list_pop_is_last_in_first_out
59
52
  skip
60
- l = SimpleLinkedList.new
61
- l.push(1)
62
- assert_equal 1, l.size
63
- assert_equal 1, l.peek
53
+ list = SimpleLinkedList.new
54
+ first = Element.new(1)
55
+ second = Element.new(2)
56
+ list.push(first).push(second)
57
+ assert_equal second, list.pop
64
58
  end
65
59
 
66
- def test_peeking_at_empty_list
60
+ def test_list_empty_to_array
67
61
  skip
68
- l = SimpleLinkedList.new
69
- assert_nil l.peek
62
+ list = SimpleLinkedList.new
63
+ assert_equal [], list.to_a
70
64
  end
71
65
 
72
- def test_access_head_element
66
+ def test_list_single_to_array
73
67
  skip
74
- l = SimpleLinkedList.new
75
- l.push(1)
76
- assert_instance_of Element, l.head
77
- assert_equal 1, l.head.datum
78
- assert l.head.tail?
68
+ list = SimpleLinkedList.new
69
+ first = Element.new(1)
70
+ list.push(first)
71
+ assert_equal [1], list.to_a
79
72
  end
80
73
 
81
- def test_items_are_stacked
74
+ def test_list_multiple_to_array
82
75
  skip
83
- l = SimpleLinkedList.new
84
- l.push(1)
85
- l.push(2)
86
- assert_equal 2, l.size
87
- assert_equal 2, l.head.datum
88
- assert_equal 1, l.head.next.datum
76
+ list = SimpleLinkedList.new
77
+ first = Element.new(1)
78
+ second = Element.new(2)
79
+ third = Element.new(3)
80
+ list.push(first).push(second).push(third)
81
+ assert_equal [3,2,1], list.to_a
89
82
  end
90
83
 
91
- def test_push_10_items
84
+ def test_list_create_from_array
92
85
  skip
93
- l = SimpleLinkedList.new
94
- (1..10).each do |datum|
95
- l.push(datum)
96
- end
97
- assert_equal 10, l.size
98
- assert_equal 10, l.peek
86
+ array = [1,2,3]
87
+ list = SimpleLinkedList.new(array)
88
+ assert_equal [3,2,1], list.to_a
99
89
  end
100
90
 
101
- def test_pop_1_item
91
+ def test_list_created_from_array_still_made_up_of_elements
102
92
  skip
103
- l = SimpleLinkedList.new
104
- l.push(1)
105
- assert_equal 1, l.pop
106
- assert_equal 0, l.size
93
+ array = [1,2,3]
94
+ list = SimpleLinkedList.new(array)
95
+ assert_equal Element, list.pop.class
107
96
  end
108
97
 
109
- def test_popping_frenzy
98
+ def test_list_from_array_still_acts_as_lifo
110
99
  skip
111
- l = SimpleLinkedList.new
112
- (1..10).each do |datum|
113
- l.push(datum)
114
- end
115
- 6.times { l.pop }
116
- assert_equal 4, l.size
117
- assert_equal 4, l.peek
100
+ array = [1,2,3]
101
+ list = SimpleLinkedList.new(array)
102
+ element = list.pop
103
+ assert_equal 3, element.datum
118
104
  end
119
105
 
120
- def test_from_a_empty_array
106
+ def test_list_in_place_reverse!
121
107
  skip
122
- l = SimpleLinkedList.from_a([])
123
- assert_equal 0, l.size
124
- assert_nil l.peek
125
- end
126
-
127
- def test_from_a_nil
128
- skip
129
- l = SimpleLinkedList.from_a(nil)
130
- assert_equal 0, l.size
131
- assert_nil l.peek
132
- end
108
+ first = Element.new(1)
109
+ second = Element.new(2)
110
+ third = Element.new(3)
111
+ list = SimpleLinkedList.new
112
+ list.push(first).push(second).push(third)
133
113
 
134
- def test_from_a_2_element_array
135
- skip
136
- l = SimpleLinkedList.from_a([1, 2])
137
- assert_equal 2, l.size
138
- assert_equal 1, l.peek
139
- assert_equal 2, l.head.next.datum
114
+ assert_equal [1,2,3], list.reverse!.to_a
140
115
  end
141
116
 
142
- def test_from_a_10_items
117
+ def test_list_in_place_reverse_are_the_same_elements
143
118
  skip
144
- l = SimpleLinkedList.from_a((1..10).to_a)
145
- assert_equal 10, l.size
146
- assert_equal 1, l.peek
147
- assert_equal 10, l.head.next.next.next.next.next.next.next.next.next.datum
148
- end
119
+ first = Element.new(1)
120
+ second = Element.new(2)
121
+ list = SimpleLinkedList.new
122
+ list.push(first).push(second)
149
123
 
150
- def test_to_a_empty_list
151
- skip
152
- l = SimpleLinkedList.new
153
- assert_equal [], l.to_a
154
- end
124
+ list.reverse!
155
125
 
156
- def test_to_a_of_1_element_list
157
- skip
158
- assert_equal [1], SimpleLinkedList.from_a([1]).to_a
126
+ assert_equal first, list.pop
127
+ assert_equal second, list.pop
159
128
  end
160
129
 
161
- def test_to_a_of_2_element_list
130
+ def test_list_reverse_empty_list
162
131
  skip
163
- assert_equal [1, 2], SimpleLinkedList.from_a([1, 2]).to_a
132
+ list = SimpleLinkedList.new
133
+ assert_equal list, list.reverse!
164
134
  end
165
135
 
166
- def test_reverse_2_element_list
136
+ def test_works_for_1_through_10
167
137
  skip
168
- list = SimpleLinkedList.from_a([1, 2])
169
- # list_r and list need not be the same object
170
- list_r = list.reverse
171
-
172
- assert_equal 2, list_r.peek
173
- assert_equal 1, list_r.head.next.datum
174
- assert list_r.head.next.tail?
138
+ list = SimpleLinkedList.new(1..10)
139
+ expected = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
140
+ assert_equal expected, list.to_a
175
141
  end
176
142
 
177
- def test_reverse_10_element_list
178
- skip
179
- data = (1..10).to_a
180
- list = SimpleLinkedList.from_a(data)
181
- assert_equal data.reverse, list.reverse.to_a
182
- end
143
+ # Problems in exercism evolve over time, as we find better ways to ask
144
+ # questions.
145
+ # The version number refers to the version of the problem you solved,
146
+ # not your solution.
147
+ #
148
+ # Define a constant named VERSION inside of the top level BookKeeping
149
+ # module.
150
+ # In your file, it will look like this:
151
+ #
152
+ # module BookKeeping
153
+ # VERSION = 1 # Where the version number matches the one in the test.
154
+ # end
155
+ #
156
+ # If you are curious, read more about constants on RubyDoc:
157
+ # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
183
158
 
184
- def test_roundtrip_10_element_array
159
+ def test_bookkeeping
185
160
  skip
186
- data = (1..10).to_a
187
- assert_equal data, SimpleLinkedList.from_a(data).to_a
161
+ assert_equal 1, BookKeeping::VERSION
188
162
  end
189
163
  end
@@ -1,3 +1,7 @@
1
+ module BookKeeping
2
+ VERSION = 1
3
+ end
4
+
1
5
  class WordProblem
2
6
  attr_reader :question
3
7
  def initialize(question)