trackler 2.0.6.12 → 2.0.6.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/c/docs/ABOUT.md +5 -0
  4. data/tracks/c/docs/INSTALLATION.md +5 -6
  5. data/tracks/c/docs/LEARNING.md +34 -0
  6. data/tracks/c/docs/RESOURCES.md +3 -0
  7. data/tracks/csharp/config.json +9 -0
  8. data/tracks/csharp/exercises/pov/Example.cs +125 -0
  9. data/tracks/csharp/exercises/pov/PovTest.cs +160 -0
  10. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiplesTest.cs +12 -6
  11. data/tracks/go/exercises/meetup/cases_test.go +0 -0
  12. data/tracks/go/exercises/raindrops/cases_test.go +0 -0
  13. data/tracks/go/exercises/rna-transcription/cases_test.go +0 -0
  14. data/tracks/go/exercises/roman-numerals/cases_test.go +0 -0
  15. data/tracks/go/exercises/word-count/cases_test.go +0 -0
  16. data/tracks/go/gen/gen.go +1 -1
  17. data/tracks/java/docs/MAINTAINING.md +11 -6
  18. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +91 -91
  19. data/tracks/java/exercises/settings.gradle +1 -0
  20. data/tracks/kotlin/config.json +2 -1
  21. data/tracks/kotlin/exercises/_template/build.gradle +1 -1
  22. data/tracks/kotlin/exercises/accumulate/build.gradle +1 -1
  23. data/tracks/kotlin/exercises/acronym/build.gradle +1 -1
  24. data/tracks/kotlin/exercises/allergies/build.gradle +1 -1
  25. data/tracks/kotlin/exercises/anagram/build.gradle +1 -1
  26. data/tracks/kotlin/exercises/atbash-cipher/build.gradle +1 -1
  27. data/tracks/kotlin/exercises/beer-song/build.gradle +1 -1
  28. data/tracks/kotlin/exercises/binary-search/build.gradle +1 -1
  29. data/tracks/kotlin/exercises/binary/build.gradle +1 -1
  30. data/tracks/kotlin/exercises/bob/build.gradle +1 -1
  31. data/tracks/kotlin/exercises/bracket-push/build.gradle +1 -1
  32. data/tracks/kotlin/exercises/change/build.gradle +1 -1
  33. data/tracks/kotlin/exercises/difference-of-squares/build.gradle +1 -1
  34. data/tracks/kotlin/exercises/etl/build.gradle +1 -1
  35. data/tracks/kotlin/exercises/flatten-array/build.gradle +1 -1
  36. data/tracks/kotlin/exercises/gigasecond/build.gradle +1 -1
  37. data/tracks/kotlin/exercises/grade-school/build.gradle +1 -1
  38. data/tracks/kotlin/exercises/hamming/build.gradle +1 -1
  39. data/tracks/kotlin/exercises/hello-world/build.gradle +1 -1
  40. data/tracks/kotlin/exercises/hexadecimal/build.gradle +1 -1
  41. data/tracks/kotlin/exercises/isogram/build.gradle +1 -1
  42. data/tracks/kotlin/exercises/largest-series-product/build.gradle +1 -1
  43. data/tracks/kotlin/exercises/leap/build.gradle +1 -1
  44. data/tracks/kotlin/exercises/linked-list/build.gradle +1 -1
  45. data/tracks/kotlin/exercises/luhn/build.gradle +1 -1
  46. data/tracks/kotlin/exercises/nth-prime/build.gradle +1 -1
  47. data/tracks/kotlin/exercises/nucleotide-count/build.gradle +1 -1
  48. data/tracks/kotlin/exercises/pangram/build.gradle +1 -1
  49. data/tracks/kotlin/exercises/pascals-triangle/build.gradle +1 -1
  50. data/tracks/kotlin/exercises/phone-number/build.gradle +1 -1
  51. data/tracks/kotlin/exercises/pig-latin/build.gradle +1 -1
  52. data/tracks/kotlin/exercises/raindrops/build.gradle +1 -1
  53. data/tracks/kotlin/exercises/rna-transcription/build.gradle +1 -1
  54. data/tracks/kotlin/exercises/rna-transcription/src/example/kotlin/RnaTranscription.kt +9 -12
  55. data/tracks/kotlin/exercises/rna-transcription/src/main/kotlin/RnaTranscription.kt +9 -0
  56. data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +6 -6
  57. data/tracks/kotlin/exercises/robot-name/build.gradle +1 -1
  58. data/tracks/kotlin/exercises/roman-numerals/build.gradle +1 -1
  59. data/tracks/kotlin/exercises/scrabble-score/build.gradle +1 -1
  60. data/tracks/kotlin/exercises/series/build.gradle +1 -1
  61. data/tracks/kotlin/exercises/sieve/build.gradle +1 -1
  62. data/tracks/kotlin/exercises/simple-cipher/build.gradle +1 -1
  63. data/tracks/kotlin/exercises/space-age/build.gradle +1 -1
  64. data/tracks/kotlin/exercises/strain/build.gradle +1 -1
  65. data/tracks/kotlin/exercises/word-count/build.gradle +1 -1
  66. data/tracks/lua/exercises/circular-buffer/circular-buffer_spec.lua +1 -1
  67. data/tracks/pascal/docs/INSTALLATION.md +7 -5
  68. data/tracks/pascal/docs/TESTS.md +4 -0
  69. data/tracks/php/config.json +9 -0
  70. data/tracks/php/exercises/ocr-numbers/example.php +113 -0
  71. data/tracks/php/exercises/ocr-numbers/ocr-numbers_test.php +222 -0
  72. metadata +10 -3
  73. data/tracks/kotlin/exercises/rna-transcription/src/main/kotlin/.keep +0 -0
@@ -1,18 +1,20 @@
1
1
  # Installing Delphi and DUnitX Testing Framework #
2
2
  ### Windows ###
3
3
 
4
- 30 day free trial of Embarcadero's RAD Studio or Delphi may be downloaded from [here](https://www.embarcadero.com/products?utm_source=google&utm_medium=cpc&utm_campaign=brand&utm_content=brand&utm_embarcadero&gclid=CjwKEAiAp97CBRDr2Oyl-faxqRMSJABx4kh9V8bOEuG0CznQ9AGToIyuKeTzvevljmHTboYXk4n6OxoC4Frw_wcB). Follow installation instructions included with the product.
4
+ A 30 day free trial of Embarcadero's RAD Studio or Delphi may be downloaded from [here](https://www.embarcadero.com/products?utm_source=google&utm_medium=cpc&utm_campaign=brand&utm_content=brand&utm_embarcadero&gclid=CjwKEAiAp97CBRDr2Oyl-faxqRMSJABx4kh9V8bOEuG0CznQ9AGToIyuKeTzvevljmHTboYXk4n6OxoC4Frw_wcB). Alternatively, a free [Starter Edition](https://www.embarcadero.com/products/delphi/starter/promotional-download) version is also available. Follow installation instructions included with the product.
5
5
 
6
6
  ### Non-Windows based Operating Systems ###
7
7
 
8
- Sorry, Delphi does not run natively on any other operating systems. However it should be possible to install Delphi into a virtual machine which is running Windows.
9
-
8
+ Delphi will not run in a non-Windows based operating system. However, it is possible to run Delphi within a virtual machine that is hosting Windows.
10
9
 
11
10
  ### Installing DUnitX Test Framework ###
12
- With Delphi successfully installed and working correctly please follow these steps for retrieving and installing DUnitX.
11
+ DUnitX comes installed in Delphi version XE8 and up with an exception for the Starter Edition of Delphi.
12
+
13
+ With Delphi successfully installed, and working correctly, please follow these steps for retrieving and installing DUnitX if you find that your installation of Delphi is lacking the DUnitX framework.
13
14
 
14
- - DUnitX is an open source project by [VSoftTechnologies](https://www.github.com/VSoftTechnologies). The DUnitX github repo is available [here](https://github.com/VSoftTechnologies/DUnitX).
15
+ - DUnitX is an open source project by [VSoftTechnologies](https://www.github.com/VSoftTechnologies). The DUnitX GitHub repo is available [here](https://github.com/VSoftTechnologies/DUnitX).
15
16
  - It is best to fork the repo and then clone or otherwise download the fork to your local machine.
16
17
  - Step-by-step instructions on how to install DUnitX into Delphi have been posted by Vincent Parrett in a blog post located [here](https://www.finalbuilder.com/resources/blogs/postid/702/dunitx-has-a-wizard).
18
+ - The Starter Edition of Delphi doesn't allow the use of project experts. DUnitX comes with an expert which will aid the student in creating a new DUnitX based project. The expert creates the project's .DPR file. The exercises in this track all include the .DPR file making the expert not necessary. DUnitX otherwise has no issues with projects created in Delphi versions starting with XE all the way up to and including the Starter Edition of Berlin.
17
19
 
18
20
  *Note: It is assumed that Delphi versions XE and higher are being utilized by the student.*
@@ -0,0 +1,4 @@
1
+ All tests have been ignored except the first one for you to work on. To continue, just comment the ```[Ignore]``` attribute on the test to start working on it.
2
+
3
+ Make sure [DUnitX](https://github.com/VSoftTechnologies/DUnitX) is installed, if not already installed from the setup above.
4
+
@@ -322,6 +322,15 @@
322
322
  "topics": [
323
323
  "OOP"
324
324
  ]
325
+ },
326
+ {
327
+ "slug": "ocr-numbers",
328
+ "difficulty": 3,
329
+ "topics": [
330
+ "Strings",
331
+ "Algorithms",
332
+ "Transforming"
333
+ ]
325
334
  }
326
335
  ]
327
336
  }
@@ -0,0 +1,113 @@
1
+ <?php
2
+
3
+ function recognize($ocr)
4
+ {
5
+ return (new OcrBlock($ocr))->recognize();
6
+ }
7
+
8
+ class OcrBlock
9
+ {
10
+ protected $ocr = [];
11
+
12
+
13
+ public function __construct($ocr)
14
+ {
15
+ $this->ocr = $ocr;
16
+ $this->validate();
17
+ }
18
+
19
+
20
+ /**
21
+ * Validate OCR block format: size, proportions
22
+ * @throws InvalidArgumentException
23
+ */
24
+ public function validate()
25
+ {
26
+ $numRows = count($this->ocr);
27
+ $numColumns = strlen($this->ocr[0]);
28
+ if (!$numRows
29
+ || ($numRows % OcrSymbol::NUM_ROWS != 0)
30
+ || !$numColumns
31
+ || ($numColumns % OcrSymbol::NUM_COLUMNS != 0)
32
+ ) {
33
+ throw new InvalidArgumentException('Malformed OCR Input');
34
+ }
35
+ foreach ($this->ocr as $row) {
36
+ if (strlen($row) != $numColumns) {
37
+ throw new InvalidArgumentException('Malformed OCR Input');
38
+ }
39
+ }
40
+ }
41
+
42
+
43
+ /**
44
+ * Recognize OCR block: split it into vertical fragments,
45
+ * explode them into symbols and recognize them.
46
+ * @return string
47
+ */
48
+ public function recognize()
49
+ {
50
+ return implode(',', array_map(function ($x) {
51
+ return implode('', array_map(function ($y) {
52
+ return (new OcrSymbol($y))->getDigit();
53
+ }, $this->explode($x)));
54
+ }, array_chunk($this->ocr, OcrSymbol::NUM_ROWS)));
55
+ }
56
+
57
+
58
+ /**
59
+ * Explode OCR fragment into OCR symbols
60
+ * @param type $ocrFragment
61
+ * @return type
62
+ */
63
+ protected function explode($ocrFragment)
64
+ {
65
+ $exploded = array_map(function ($x) {
66
+ return str_split($x, OcrSymbol::NUM_COLUMNS);
67
+ }, $ocrFragment);
68
+ return array_map(function ($a, $b, $c, $d) {
69
+ return [$a, $b, $c, $d];
70
+ }, $exploded[0], $exploded[1], $exploded[2], $exploded[3]);
71
+ }
72
+ }
73
+
74
+
75
+ class OcrSymbol
76
+ {
77
+ const NUM_ROWS = 4;
78
+ const NUM_COLUMNS = 3;
79
+
80
+ protected $map = [
81
+ 'x_x|x||_|xxx' => '0',
82
+ 'xxxxx|xx|xxx' => '1',
83
+ 'x_xx_||_xxxx' => '2',
84
+ 'x_xx_|x_|xxx' => '3',
85
+ 'xxx|_|xx|xxx' => '4',
86
+ 'x_x|_xx_|xxx' => '5',
87
+ 'x_x|_x|_|xxx' => '6',
88
+ 'x_xxx|xx|xxx' => '7',
89
+ 'x_x|_||_|xxx' => '8',
90
+ 'x_x|_|x_|xxx' => '9',
91
+ ];
92
+
93
+ protected $ocr;
94
+ protected $digit;
95
+
96
+ public function __construct($ocr)
97
+ {
98
+ $this->ocr = $ocr;
99
+ }
100
+
101
+ /**
102
+ * Translate OCR to digit
103
+ * @return string
104
+ */
105
+ public function getDigit()
106
+ {
107
+ if ($this->digit === null) {
108
+ $encoded = str_replace(' ', 'x', implode($this->ocr));
109
+ $this->digit = array_key_exists($encoded, $this->map) ? $this->map[$encoded] : '?';
110
+ }
111
+ return $this->digit;
112
+ }
113
+ }
@@ -0,0 +1,222 @@
1
+ <?php
2
+
3
+ include_once 'ocr-numbers.php';
4
+
5
+ class OcrNumbersTest extends PHPUnit_Framework_TestCase
6
+ {
7
+
8
+ /**
9
+ * Recognition result should be returned as a string
10
+ */
11
+
12
+ public function testRecognizes0()
13
+ {
14
+ $input = [
15
+ " _ ",
16
+ "| |",
17
+ "|_|",
18
+ " ",
19
+ ];
20
+ $this->assertSame('0', recognize($input));
21
+ }
22
+
23
+ public function testRecognizes1()
24
+ {
25
+ $input = [
26
+ " ",
27
+ " |",
28
+ " |",
29
+ " ",
30
+ ];
31
+ $this->assertSame('1', recognize($input));
32
+ }
33
+
34
+ /**
35
+ * Unreadable but correctly sized inputs return ?
36
+ */
37
+ public function testUnreadable()
38
+ {
39
+ $input = [
40
+ " ",
41
+ " _",
42
+ " |",
43
+ " ",
44
+ ];
45
+ $this->assertSame('?', recognize($input));
46
+ }
47
+
48
+ /**
49
+ * Input with a number of lines that is not a multiple of four raises an error
50
+ * @expectedException InvalidArgumentException
51
+ */
52
+ public function testErrorWrongNumberOfLines()
53
+ {
54
+ $input = [
55
+ " _ ",
56
+ "| |",
57
+ " ",
58
+ ];
59
+ recognize($input);
60
+ }
61
+
62
+ /**
63
+ * Input with a number of columns that is not a multiple of three raises an error
64
+ * @expectedException InvalidArgumentException
65
+ */
66
+ public function testErrorWrongNumberOfColumns()
67
+ {
68
+ $input = [
69
+ " ",
70
+ " |",
71
+ " |",
72
+ " ",
73
+ ];
74
+ recognize($input);
75
+ }
76
+
77
+ public function testRecognizes110101100()
78
+ {
79
+ $input = [
80
+ " _ _ _ _ ",
81
+ " | || | || | | || || |",
82
+ " | ||_| ||_| | ||_||_|",
83
+ " ",
84
+ ];
85
+ $this->assertSame('110101100', recognize($input));
86
+ }
87
+
88
+ /**
89
+ * Garbled numbers in a string are replaced with ?
90
+ */
91
+ public function testGarbled()
92
+ {
93
+ $input = [
94
+ " _ _ _ ",
95
+ " | || | || | || || |",
96
+ " | | _| ||_| | ||_||_|",
97
+ " ",
98
+ ];
99
+ $this->assertSame('11?10?1?0', recognize($input));
100
+ }
101
+
102
+ public function testRecognizes2()
103
+ {
104
+ $input = [
105
+ " _ ",
106
+ " _|",
107
+ "|_ ",
108
+ " ",
109
+ ];
110
+ $this->assertSame('2', recognize($input));
111
+ }
112
+
113
+ public function testRecognizes3()
114
+ {
115
+ $input = [
116
+ " _ ",
117
+ " _|",
118
+ " _|",
119
+ " ",
120
+ ];
121
+ $this->assertSame('3', recognize($input));
122
+ }
123
+
124
+ public function testRecognizes4()
125
+ {
126
+ $input = [
127
+ " ",
128
+ "|_|",
129
+ " |",
130
+ " ",
131
+ ];
132
+ $this->assertSame('4', recognize($input));
133
+ }
134
+
135
+ public function testRecognizes5()
136
+ {
137
+ $input = [
138
+ " _ ",
139
+ "|_ ",
140
+ " _|",
141
+ " ",
142
+ ];
143
+ $this->assertSame('5', recognize($input));
144
+ }
145
+
146
+ public function testRecognizes6()
147
+ {
148
+ $input = [
149
+ " _ ",
150
+ "|_ ",
151
+ "|_|",
152
+ " ",
153
+ ];
154
+ $this->assertSame('6', recognize($input));
155
+ }
156
+
157
+ public function testRecognizes7()
158
+ {
159
+ $input = [
160
+ " _ ",
161
+ " |",
162
+ " |",
163
+ " ",
164
+ ];
165
+ $this->assertSame('7', recognize($input));
166
+ }
167
+
168
+ public function testRecognizes8()
169
+ {
170
+ $input = [
171
+ " _ ",
172
+ "|_|",
173
+ "|_|",
174
+ " ",
175
+ ];
176
+ $this->assertSame('8', recognize($input));
177
+ }
178
+
179
+ public function testRecognizes9()
180
+ {
181
+ $input = [
182
+ " _ ",
183
+ "|_|",
184
+ " _|",
185
+ " ",
186
+ ];
187
+ $this->assertSame('9', recognize($input));
188
+ }
189
+
190
+ public function testRecognizesStringOfDecimalNumbers()
191
+ {
192
+ $input = [
193
+ " _ _ _ _ _ _ _ _ ",
194
+ " | _| _||_||_ |_ ||_||_|| |",
195
+ " ||_ _| | _||_| ||_| _||_|",
196
+ " ",
197
+ ];
198
+ $this->assertSame('1234567890', recognize($input));
199
+ }
200
+
201
+ /**
202
+ * Numbers separated by empty lines are recognized. Lines are joined by commas.
203
+ */
204
+ public function testLinesWithCommas()
205
+ {
206
+ $input = [
207
+ " _ _ ",
208
+ " | _| _|",
209
+ " ||_ _|",
210
+ " ",
211
+ " _ _ ",
212
+ "|_||_ |_ ",
213
+ " | _||_|",
214
+ " ",
215
+ " _ _ _ ",
216
+ " ||_||_|",
217
+ " ||_| _|",
218
+ " ",
219
+ ];
220
+ $this->assertSame('123,456,789', recognize($input));
221
+ }
222
+ }
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.0.6.12
4
+ version: 2.0.6.13
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-01-17 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -539,7 +539,10 @@ files:
539
539
  - tracks/c/bin/run-tests
540
540
  - tracks/c/bin/verify-indent
541
541
  - tracks/c/config.json
542
+ - tracks/c/docs/ABOUT.md
542
543
  - tracks/c/docs/INSTALLATION.md
544
+ - tracks/c/docs/LEARNING.md
545
+ - tracks/c/docs/RESOURCES.md
543
546
  - tracks/c/docs/TESTS.md
544
547
  - tracks/c/exercises/allergies/makefile
545
548
  - tracks/c/exercises/allergies/src/allergies.h
@@ -1442,6 +1445,8 @@ files:
1442
1445
  - tracks/csharp/exercises/pig-latin/PigLatinTest.cs
1443
1446
  - tracks/csharp/exercises/poker/Example.cs
1444
1447
  - tracks/csharp/exercises/poker/PokerTest.cs
1448
+ - tracks/csharp/exercises/pov/Example.cs
1449
+ - tracks/csharp/exercises/pov/PovTest.cs
1445
1450
  - tracks/csharp/exercises/prime-factors/Example.cs
1446
1451
  - tracks/csharp/exercises/prime-factors/PrimeFactorsTest.cs
1447
1452
  - tracks/csharp/exercises/protein-translation/Example.cs
@@ -4144,7 +4149,7 @@ files:
4144
4149
  - tracks/kotlin/exercises/raindrops/src/test/kotlin/RaindropsTest.kt
4145
4150
  - tracks/kotlin/exercises/rna-transcription/build.gradle
4146
4151
  - tracks/kotlin/exercises/rna-transcription/src/example/kotlin/RnaTranscription.kt
4147
- - tracks/kotlin/exercises/rna-transcription/src/main/kotlin/.keep
4152
+ - tracks/kotlin/exercises/rna-transcription/src/main/kotlin/RnaTranscription.kt
4148
4153
  - tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt
4149
4154
  - tracks/kotlin/exercises/robot-name/build.gradle
4150
4155
  - tracks/kotlin/exercises/robot-name/src/example/kotlin/Robot.kt
@@ -5479,6 +5484,8 @@ files:
5479
5484
  - tracks/php/exercises/minesweeper/minesweeper_test.php
5480
5485
  - tracks/php/exercises/nucleotide-count/example.php
5481
5486
  - tracks/php/exercises/nucleotide-count/nucleotide-count_test.php
5487
+ - tracks/php/exercises/ocr-numbers/example.php
5488
+ - tracks/php/exercises/ocr-numbers/ocr-numbers_test.php
5482
5489
  - tracks/php/exercises/pangram/example.php
5483
5490
  - tracks/php/exercises/pangram/pangram_test.php
5484
5491
  - tracks/php/exercises/phone-number/example.php