trackler 2.2.1.100 → 2.2.1.101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/kindergarten-garden/canonical-data.json +37 -19
  4. data/problem-specifications/exercises/ocr-numbers/canonical-data.json +144 -110
  5. data/problem-specifications/exercises/palindrome-products/canonical-data.json +49 -25
  6. data/problem-specifications/exercises/poker/canonical-data.json +171 -115
  7. data/problem-specifications/exercises/prime-factors/canonical-data.json +22 -8
  8. data/problem-specifications/exercises/protein-translation/canonical-data.json +70 -24
  9. data/problem-specifications/exercises/proverb/canonical-data.json +24 -12
  10. data/problem-specifications/exercises/queen-attack/canonical-data.json +115 -91
  11. data/problem-specifications/exercises/rail-fence-cipher/canonical-data.json +25 -13
  12. data/problem-specifications/exercises/raindrops/canonical-data.json +55 -19
  13. data/problem-specifications/exercises/rational-numbers/canonical-data.json +374 -0
  14. data/problem-specifications/exercises/rational-numbers/description.md +27 -0
  15. data/problem-specifications/exercises/rational-numbers/metadata.yml +4 -0
  16. data/problem-specifications/exercises/rectangles/canonical-data.json +93 -67
  17. data/problem-specifications/exercises/reverse-string/canonical-data.json +16 -6
  18. data/problem-specifications/exercises/rna-transcription/metadata.yml +3 -3
  19. data/problem-specifications/exercises/roman-numerals/canonical-data.json +10 -2
  20. data/tracks/bash/config.json +11 -11
  21. data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +7 -0
  22. data/tracks/clojure/exercises/armstrong-numbers/README.md +1 -1
  23. data/tracks/delphi/config.json +11 -0
  24. data/tracks/delphi/exercises/clock/uClockExample.pas +6 -1
  25. data/tracks/delphi/exercises/clock/uClockTest.pas +22 -19
  26. data/tracks/delphi/exercises/isbn-verifier/README.md +1 -1
  27. data/tracks/delphi/exercises/reverse-string/README.md +1 -1
  28. data/tracks/delphi/exercises/rna-transcription/README.md +1 -1
  29. data/tracks/delphi/exercises/roman-numerals/uRomanNumeralsTest.pas +14 -0
  30. data/tracks/delphi/exercises/space-age/README.md +45 -0
  31. data/tracks/delphi/exercises/space-age/SpaceAge.dpr +60 -0
  32. data/tracks/delphi/exercises/space-age/uSpaceAgeExample.pas +120 -0
  33. data/tracks/delphi/exercises/space-age/uSpaceAgeTests.pas +135 -0
  34. data/tracks/delphi/exercises/two-fer/README.md +1 -1
  35. data/tracks/elixir/exercises/nth-prime/nth_prime.exs +0 -1
  36. data/tracks/fsharp/exercises/pov/PovTest.fs +66 -53
  37. data/tracks/fsharp/exercises/space-age/Example.fs +11 -11
  38. data/tracks/fsharp/exercises/space-age/SpaceAge.fs +1 -1
  39. data/tracks/fsharp/exercises/space-age/SpaceAgeTest.fs +21 -34
  40. data/tracks/fsharp/exercises/triangle/Example.fs +11 -16
  41. data/tracks/fsharp/exercises/triangle/Triangle.fs +4 -5
  42. data/tracks/fsharp/exercises/triangle/TriangleTest.fs +44 -31
  43. data/tracks/fsharp/generators/Generators.fs +121 -0
  44. data/tracks/go/config.json +12 -0
  45. data/tracks/go/exercises/clock/.meta/gen.go +37 -13
  46. data/tracks/go/exercises/clock/cases_test.go +10 -10
  47. data/tracks/go/exercises/clock/clock_test.go +16 -2
  48. data/tracks/go/exercises/clock/example.go +4 -0
  49. data/tracks/go/exercises/clock/example_clock_test.go +3 -3
  50. data/tracks/go/exercises/parallel-letter-frequency/.meta/hints.md +33 -0
  51. data/tracks/go/exercises/parallel-letter-frequency/README.md +35 -0
  52. data/tracks/go/exercises/raindrops/.meta/hints.md +7 -4
  53. data/tracks/go/exercises/raindrops/README.md +12 -0
  54. data/tracks/go/exercises/roman-numerals/.meta/gen.go +4 -2
  55. data/tracks/go/exercises/roman-numerals/cases_test.go +3 -2
  56. data/tracks/go/exercises/space-age/.meta/hints.md +10 -0
  57. data/tracks/go/exercises/space-age/README.md +14 -1
  58. data/tracks/go/exercises/twelve-days/README.md +2 -5
  59. data/tracks/go/exercises/two-bucket/.meta/gen.go +62 -0
  60. data/tracks/go/exercises/two-bucket/.meta/hints.md +16 -0
  61. data/tracks/go/exercises/two-bucket/README.md +72 -0
  62. data/tracks/go/exercises/two-bucket/cases_test.go +44 -0
  63. data/tracks/go/exercises/two-bucket/example.go +198 -0
  64. data/tracks/go/exercises/two-bucket/two_bucket_test.go +61 -0
  65. data/tracks/idris/.travis.yml +3 -2
  66. data/tracks/idris/bin/fetch-idris-testing.sh +11 -0
  67. data/tracks/idris/bin/solve_exercises.sh +2 -2
  68. data/tracks/idris/config.json +11 -0
  69. data/tracks/idris/config/exercise_readme.go.tmpl +0 -3
  70. data/tracks/idris/docs/INSTALLATION.md +22 -0
  71. data/tracks/idris/docs/TESTS.md +12 -4
  72. data/tracks/idris/exercises/accumulate/src/Accumulate.idr +5 -0
  73. data/tracks/idris/exercises/hamming/Hamming.ipkg +2 -0
  74. data/tracks/idris/exercises/hamming/src/{example.idr → Example.idr} +5 -1
  75. data/tracks/idris/exercises/hamming/src/Hamming.idr +13 -5
  76. data/tracks/idris/exercises/hamming/src/Test/Hamming.idr +31 -58
  77. data/tracks/idris/exercises/hello-world/HelloWorld.ipkg +2 -0
  78. data/tracks/idris/exercises/hello-world/src/Example.idr +9 -0
  79. data/tracks/idris/exercises/hello-world/src/HelloWorld.idr +6 -1
  80. data/tracks/idris/exercises/hello-world/src/Test/HelloWorld.idr +18 -18
  81. data/tracks/idris/exercises/leap/Leap.ipkg +2 -0
  82. data/tracks/idris/exercises/leap/src/{example.idr → Example.idr} +4 -0
  83. data/tracks/idris/exercises/leap/src/Leap.idr +5 -1
  84. data/tracks/idris/exercises/leap/src/Test/Leap.idr +21 -30
  85. data/tracks/idris/exercises/rna-transcription/Makefile +23 -0
  86. data/tracks/idris/exercises/rna-transcription/README.md +27 -0
  87. data/tracks/idris/exercises/rna-transcription/RnaTranscription.ipkg +5 -0
  88. data/tracks/idris/exercises/rna-transcription/src/RnaTranscription.idr +17 -0
  89. data/tracks/idris/exercises/rna-transcription/src/Test/RnaTranscription.idr +27 -0
  90. data/tracks/idris/exercises/rna-transcription/src/example.idr +35 -0
  91. data/tracks/java/exercises/etl/.meta/version +1 -0
  92. data/tracks/java/exercises/gigasecond/.meta/version +1 -0
  93. data/tracks/java/exercises/isbn-verifier/README.md +1 -1
  94. data/tracks/java/exercises/nucleotide-count/.meta/src/reference/java/NucleotideCounter.java +7 -1
  95. data/tracks/java/exercises/nucleotide-count/.meta/version +1 -0
  96. data/tracks/java/exercises/nucleotide-count/src/test/java/NucleotideCounterTest.java +19 -54
  97. data/tracks/java/exercises/proverb/.meta/version +1 -0
  98. data/tracks/java/exercises/reverse-string/README.md +1 -1
  99. data/tracks/java/exercises/rna-transcription/README.md +1 -1
  100. data/tracks/java/exercises/sum-of-multiples/.meta/version +1 -0
  101. data/tracks/java/exercises/sum-of-multiples/src/test/java/SumOfMultiplesTest.java +13 -1
  102. data/tracks/kotlin/config/exercise_readme.go.tmpl +0 -3
  103. data/tracks/kotlin/docs/TESTS.md +1 -1
  104. data/tracks/objective-c/config.json +11 -0
  105. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureExample.h +7 -0
  106. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureExample.m +26 -0
  107. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureTest.m +39 -0
  108. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +31 -1
  109. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/xcshareddata/xcschemes/OCLint.xcscheme +3 -1
  110. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/xcshareddata/xcschemes/xobjectivecTest.xcscheme +3 -1
  111. data/tracks/ocaml/exercises/forth/example.ml +9 -9
  112. data/tracks/ocaml/tools/test-generator/Makefile +3 -9
  113. data/tracks/ocaml/tools/test-generator/src/test_gen.ml +18 -16
  114. data/tracks/perl6/exercises/acronym/.meta/exercise-data.yaml +1 -1
  115. data/tracks/perl6/exercises/acronym/acronym.t +4 -14
  116. data/tracks/perl6/exercises/all-your-base/all-your-base.t +0 -2
  117. data/tracks/perl6/exercises/allergies/allergies.t +0 -2
  118. data/tracks/perl6/exercises/anagram/.meta/exercise-data.yaml +1 -1
  119. data/tracks/perl6/exercises/anagram/anagram.t +2 -40
  120. data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +0 -1
  121. data/tracks/perl6/exercises/bob/bob.t +0 -2
  122. data/tracks/perl6/exercises/clock/.meta/exercise-data.yaml +15 -11
  123. data/tracks/perl6/exercises/clock/.meta/solutions/Clock.pm6 +5 -1
  124. data/tracks/perl6/exercises/clock/Clock.pm6 +1 -1
  125. data/tracks/perl6/exercises/clock/clock.t +314 -217
  126. data/tracks/perl6/exercises/etl/etl.t +0 -2
  127. data/tracks/perl6/exercises/flatten-array/flatten-array.t +0 -2
  128. data/tracks/perl6/exercises/grains/grains.t +0 -2
  129. data/tracks/perl6/exercises/hamming/.meta/exercise-data.yaml +2 -2
  130. data/tracks/perl6/exercises/hamming/hamming.t +63 -35
  131. data/tracks/perl6/exercises/hello-world/hello-world.t +2 -3
  132. data/tracks/perl6/exercises/leap/.meta/exercise-data.yaml +1 -1
  133. data/tracks/perl6/exercises/leap/leap.t +14 -8
  134. data/tracks/perl6/exercises/luhn/luhn.t +0 -2
  135. data/tracks/perl6/exercises/nucleotide-count/.meta/exercise-data.yaml +2 -2
  136. data/tracks/perl6/exercises/nucleotide-count/nucleotide-count.t +18 -10
  137. data/tracks/perl6/exercises/pangram/.meta/exercise-data.yaml +1 -1
  138. data/tracks/perl6/exercises/pangram/pangram.t +32 -14
  139. data/tracks/perl6/exercises/phone-number/.meta/exercise-data.yaml +4 -4
  140. data/tracks/perl6/exercises/phone-number/.meta/solutions/Phone.pm6 +1 -1
  141. data/tracks/perl6/exercises/phone-number/Phone.pm6 +1 -1
  142. data/tracks/perl6/exercises/phone-number/phone-number.t +59 -21
  143. data/tracks/perl6/exercises/raindrops/raindrops.t +0 -2
  144. data/tracks/perl6/exercises/rna-transcription/.meta/exercise-data.yaml +1 -1
  145. data/tracks/perl6/exercises/rna-transcription/README.md +1 -1
  146. data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +17 -9
  147. data/tracks/perl6/exercises/roman-numerals/.meta/exercise-data.yaml +3 -3
  148. data/tracks/perl6/exercises/roman-numerals/.meta/solutions/RomanNumerals.pm6 +1 -1
  149. data/tracks/perl6/exercises/roman-numerals/RomanNumerals.pm6 +1 -1
  150. data/tracks/perl6/exercises/roman-numerals/roman-numerals.t +66 -24
  151. data/tracks/perl6/exercises/scrabble-score/.meta/exercise-data.yaml +1 -1
  152. data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +35 -15
  153. data/tracks/perl6/exercises/space-age/.meta/exercise-data.yaml +1 -1
  154. data/tracks/perl6/exercises/space-age/space-age.t +34 -20
  155. data/tracks/perl6/exercises/two-fer/.meta/exercise-data.yaml +2 -2
  156. data/tracks/perl6/exercises/two-fer/two-fer.t +15 -11
  157. data/tracks/perl6/exercises/word-count/.meta/exercise-data.yaml +1 -1
  158. data/tracks/perl6/exercises/word-count/word-count.t +46 -26
  159. data/tracks/perl6/exercises/wordy/.meta/exercise-data.yaml +2 -2
  160. data/tracks/perl6/exercises/wordy/wordy.t +51 -21
  161. data/tracks/perl6/lib/Exercism/Generator.pm6 +1 -1
  162. data/tracks/perl6/t/generated-tests.t +1 -1
  163. data/tracks/perl6/templates/test.mustache +0 -1
  164. data/tracks/python/config.json +12 -0
  165. data/tracks/python/exercises/forth/example.py +1 -1
  166. data/tracks/python/exercises/forth/forth_test.py +43 -38
  167. data/tracks/python/exercises/spiral-matrix/README.md +42 -0
  168. data/tracks/python/exercises/spiral-matrix/example.py +11 -0
  169. data/tracks/python/exercises/spiral-matrix/spiral_matrix.py +2 -0
  170. data/tracks/python/exercises/spiral-matrix/spiral_matrix_test.py +40 -0
  171. data/tracks/racket/config/exercise_readme.go.tmpl +24 -4
  172. data/tracks/racket/exercises/accumulate/README.md +3 -6
  173. data/tracks/racket/exercises/acronym/README.md +3 -4
  174. data/tracks/racket/exercises/allergies/README.md +3 -4
  175. data/tracks/racket/exercises/anagram/README.md +3 -3
  176. data/tracks/racket/exercises/bob/README.md +5 -3
  177. data/tracks/racket/exercises/collatz-conjecture/README.md +3 -3
  178. data/tracks/racket/exercises/difference-of-squares/README.md +3 -3
  179. data/tracks/racket/exercises/etl/README.md +6 -4
  180. data/tracks/racket/exercises/gigasecond/README.md +3 -3
  181. data/tracks/racket/exercises/grains/README.md +3 -4
  182. data/tracks/racket/exercises/grep/README.md +15 -15
  183. data/tracks/racket/exercises/hamming/README.md +3 -3
  184. data/tracks/racket/exercises/hello-world/README.md +1 -1
  185. data/tracks/racket/exercises/leap/README.md +4 -4
  186. data/tracks/racket/exercises/list-ops/README.md +3 -4
  187. data/tracks/racket/exercises/meetup/README.md +19 -15
  188. data/tracks/racket/exercises/nucleotide-count/README.md +11 -25
  189. data/tracks/racket/exercises/perfect-numbers/README.md +5 -5
  190. data/tracks/racket/exercises/phone-number/README.md +7 -6
  191. data/tracks/racket/exercises/raindrops/README.md +3 -3
  192. data/tracks/racket/exercises/rna-transcription/README.md +4 -4
  193. data/tracks/racket/exercises/roman-numerals/README.md +4 -4
  194. data/tracks/racket/exercises/say/README.md +3 -3
  195. data/tracks/racket/exercises/scrabble-score/README.md +6 -4
  196. data/tracks/racket/exercises/word-count/README.md +4 -5
  197. data/tracks/scheme/config/exercise_readme.go.tmpl +0 -3
  198. data/tracks/scheme/docs/INSTALLATION.md +23 -14
  199. metadata +40 -9
  200. data/tracks/idris/docs/EXERCISE_README_INSERT.md +0 -0
  201. data/tracks/idris/exercises/hello-world/src/example.idr +0 -5
  202. data/tracks/kotlin/config/exercise-readme-insert.md +0 -1
  203. data/tracks/racket/docs/EXERCISE_README_INSERT.md +0 -23
  204. data/tracks/scheme/docs/EXERCISE_README_INSERT.md +0 -0
@@ -12,6 +12,7 @@ type
12
12
  public
13
13
  constructor SetHands(aHours: integer; aMinutes: integer=0);
14
14
  function Add(minutesToAdd: integer): Clock;
15
+ function Subtract(minutesToSubtract: integer): Clock;
15
16
  function ToString: string;
16
17
  function Equal(aClock: Clock): Boolean;
17
18
  End;
@@ -25,6 +26,11 @@ begin
25
26
  minutes := fltMod(aMinutes, 60);
26
27
  end;
27
28
 
29
+ function Clock.Subtract(minutesToSubtract: integer): Clock;
30
+ begin
31
+ result := Clock.SetHands(hours, minutes - minutesToSubtract);
32
+ end;
33
+
28
34
  function Clock.Add(minutesToAdd: Integer): Clock;
29
35
  begin
30
36
  result := Clock.SetHands(hours, minutes + minutesToAdd);
@@ -43,7 +49,6 @@ end;
43
49
  class function Clock.fltMod(x, y: double): integer;
44
50
  var intX, intY: integer;
45
51
  tmpFloat: double;
46
- xDy: double;
47
52
  begin
48
53
  intX := trunc(x);
49
54
  tmpFloat := x - intX;
@@ -4,6 +4,9 @@ interface
4
4
  uses
5
5
  DUnitX.TestFramework;
6
6
 
7
+ const
8
+ CanonicalVersion = '2.2.1';
9
+
7
10
  type
8
11
 
9
12
  [TestFixture('Create a new clock with an initial time')]
@@ -77,6 +80,10 @@ type
77
80
  [Ignore]
78
81
  procedure Negative_minutes_roll_over_continuously;
79
82
 
83
+ [Test]
84
+ [Ignore]
85
+ procedure Negative_hour_and_minutes_both_roll_over;
86
+
80
87
  [Test]
81
88
  [Ignore]
82
89
  procedure Negative_hour_and_minutes_both_roll_over_continuously;
@@ -141,10 +148,6 @@ type
141
148
  [Ignore]
142
149
  procedure Subtract_more_than_two_hours;
143
150
 
144
- [Test]
145
- [Ignore]
146
- procedure Midnight_is_zero_hundred_hours;
147
-
148
151
  [Test]
149
152
  [Ignore]
150
153
  procedure Subtract_more_than_two_hours_with_borrow;
@@ -167,7 +170,7 @@ type
167
170
 
168
171
  [Test]
169
172
  [Ignore]
170
- procedure Clocks_a_minutes_apart;
173
+ procedure Clocks_a_minute_apart;
171
174
 
172
175
  [Test]
173
176
  [Ignore]
@@ -311,6 +314,11 @@ begin
311
314
  Assert.AreEqual('16:40', Clock.SetHands(1, -4820).ToString);
312
315
  end;
313
316
 
317
+ procedure TClockTest.Negative_hour_and_minutes_both_roll_over;
318
+ begin
319
+ Assert.AreEqual('20:20', Clock.SetHands(-25, -160).ToString);
320
+ end;
321
+
314
322
  procedure TClockTest.Negative_hour_and_minutes_both_roll_over_continuously;
315
323
  begin
316
324
  Assert.AreEqual('22:10', Clock.SetHands(-121, -5810).ToString);
@@ -362,47 +370,42 @@ end;
362
370
  {$region 'TSubtractMinutes'}
363
371
  procedure TSubtractMinutes.Subtract_minutes;
364
372
  begin
365
- Assert.AreEqual('10:00', Clock.SetHands(10, 3).Add(-3).ToString);
373
+ Assert.AreEqual('10:00', Clock.SetHands(10, 3).Subtract(3).ToString);
366
374
  end;
367
375
 
368
376
  procedure TSubtractMinutes.Subtract_to_previous_hour;
369
377
  begin
370
- Assert.AreEqual('09:33', Clock.SetHands(10, 3).Add(-30).ToString);
378
+ Assert.AreEqual('09:33', Clock.SetHands(10, 3).Subtract(30).ToString);
371
379
  end;
372
380
 
373
381
  procedure TSubtractMinutes.Subtract_more_than_one_hour;
374
382
  begin
375
- Assert.AreEqual('08:53', Clock.SetHands(10, 3).Add(-70).ToString);
383
+ Assert.AreEqual('08:53', Clock.SetHands(10, 3).Subtract(70).ToString);
376
384
  end;
377
385
 
378
386
  procedure TSubtractMinutes.Subtract_across_midnight;
379
387
  begin
380
- Assert.AreEqual('23:59', Clock.SetHands(0, 3).Add(-4).ToString);
388
+ Assert.AreEqual('23:59', Clock.SetHands(0, 3).Subtract(4).ToString);
381
389
  end;
382
390
 
383
391
  procedure TSubtractMinutes.Subtract_more_than_two_hours;
384
392
  begin
385
- Assert.AreEqual('21:20', Clock.SetHands(0, 0).Add(-160).ToString);
386
- end;
387
-
388
- procedure TSubtractMinutes.Midnight_is_zero_hundred_hours;
389
- begin
390
- Assert.AreEqual('00:00', Clock.SetHands(24).ToString);
393
+ Assert.AreEqual('21:20', Clock.SetHands(0, 0).Subtract(160).ToString);
391
394
  end;
392
395
 
393
396
  procedure TSubtractMinutes.Subtract_more_than_two_hours_with_borrow;
394
397
  begin
395
- Assert.AreEqual('03:35', Clock.SetHands(6, 15).Add(-160).ToString);
398
+ Assert.AreEqual('03:35', Clock.SetHands(6, 15).Subtract(160).ToString);
396
399
  end;
397
400
 
398
401
  procedure TSubtractMinutes.Subtract_more_than_one_day;
399
402
  begin
400
- Assert.AreEqual('04:32', Clock.SetHands(5, 32).Add(-1500).ToString);
403
+ Assert.AreEqual('04:32', Clock.SetHands(5, 32).Subtract(1500).ToString);
401
404
  end;
402
405
 
403
406
  procedure TSubtractMinutes.Subtract_more_than_two_days;
404
407
  begin
405
- Assert.AreEqual('00:20', Clock.SetHands(2, 20).Add(-3000).ToString);
408
+ Assert.AreEqual('00:20', Clock.SetHands(2, 20).Subtract(3000).ToString);
406
409
  end;
407
410
  {$endregion}
408
411
 
@@ -416,7 +419,7 @@ begin
416
419
  Assert.IsTrue(Clock1.Equal(Clock2));
417
420
  end;
418
421
 
419
- procedure TCompareClocks.Clocks_a_minutes_apart;
422
+ procedure TCompareClocks.Clocks_a_minute_apart;
420
423
  var Clock1, Clock2: Clock;
421
424
  begin
422
425
  Clock1 := Clock.SetHands(15, 36);
@@ -1,4 +1,4 @@
1
- # Isbn Verifier
1
+ # ISBN Verifier
2
2
 
3
3
  The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification
4
4
  numbers. These normally contain dashes and look like: `3-598-21508-8`
@@ -1,4 +1,4 @@
1
- # reverse-string
1
+ # Reverse String
2
2
 
3
3
  Reverse a string
4
4
 
@@ -40,7 +40,7 @@ For example, if you're submitting `ubob.pas` for the Bob exercise, the submit co
40
40
 
41
41
  ## Source
42
42
 
43
- Rosalind [http://rosalind.info/problems/rna](http://rosalind.info/problems/rna)
43
+ Hyperphysics [http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html](http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html)
44
44
 
45
45
  ## Submitting Incomplete Solutions
46
46
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -4,6 +4,9 @@ interface
4
4
  uses
5
5
  DUnitX.TestFramework;
6
6
 
7
+ const
8
+ CanonicalVersion = '1.2.0';
9
+
7
10
  type
8
11
 
9
12
  [TestFixture]
@@ -45,6 +48,10 @@ type
45
48
  [Ignore]
46
49
  procedure Fourty_eight_is_not_50_minus_2_but_rather_40_plus_8;
47
50
 
51
+ [Test]
52
+ [Ignore]
53
+ procedure Fourty_nine_is_not_40_plus_5_plus_4_but_rather_50_minus_10_plus_10_minus_1;
54
+
48
55
  [Test]
49
56
  [Ignore]
50
57
  procedure Fifty_is_a_single_L;
@@ -148,6 +155,13 @@ begin
148
155
  Assert.AreEqual('XLVIII', arabicNumeral.ToRoman);
149
156
  end;
150
157
 
158
+ procedure RomanNumeralsTest.Fourty_nine_is_not_40_plus_5_plus_4_but_rather_50_minus_10_plus_10_minus_1;
159
+ var arabicNumeral: integer;
160
+ begin
161
+ arabicNumeral := 49;
162
+ Assert.AreEqual('XLIX',arabicNumeral.ToRoman);
163
+ end;
164
+
151
165
  procedure RomanNumeralsTest.Fifty_is_a_single_L;
152
166
  var arabicNumeral: integer;
153
167
  begin
@@ -0,0 +1,45 @@
1
+ # Space Age
2
+
3
+ Given an age in seconds, calculate how old someone would be on:
4
+
5
+ - Earth: orbital period 365.25 Earth days, or 31557600 seconds
6
+ - Mercury: orbital period 0.2408467 Earth years
7
+ - Venus: orbital period 0.61519726 Earth years
8
+ - Mars: orbital period 1.8808158 Earth years
9
+ - Jupiter: orbital period 11.862615 Earth years
10
+ - Saturn: orbital period 29.447498 Earth years
11
+ - Uranus: orbital period 84.016846 Earth years
12
+ - Neptune: orbital period 164.79132 Earth years
13
+
14
+ So if you were told someone were 1,000,000,000 seconds old, you should
15
+ be able to say that they're 31.69 Earth-years old.
16
+
17
+ If you're wondering why Pluto didn't make the cut, go watch [this
18
+ youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs).
19
+
20
+ ## Testing
21
+
22
+ In order to run the tests for this track, you will need to install
23
+ DUnitX. Please see the [installation](http://www.exercism.io/languages/delphi/installation) instructions for more information.
24
+
25
+ ### Loading Exercises into Delphi
26
+
27
+ If Delphi is properly installed, and `*.dpr` file types have been associated with Delphi, then double clicking the supplied `*.dpr` file will start Delphi and load the exercise/project. `control + F9` is the keyboard shortcut to compile the project or pressing `F9` will compile and run the project.
28
+
29
+ Alternatively you may opt to start Delphi and load your project via. the `File` drop down menu.
30
+
31
+ ### When Questions Come Up
32
+ We monitor the [Pascal-Delphi](https://gitter.im/exercism/Pascal-Delphi) support room on [gitter.im](https://gitter.im) to help you with any questions that might arise.
33
+
34
+ ### Submitting Exercises
35
+
36
+ Note that, when trying to submit an exercise, make sure the exercise file you're submitting is in the `exercism/delphi/<exerciseName>` directory.
37
+
38
+ For example, if you're submitting `ubob.pas` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/delphi/bob/ubob.pas`.
39
+
40
+ ## Source
41
+
42
+ Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=01](http://pine.fm/LearnToProgram/?Chapter=01)
43
+
44
+ ## Submitting Incomplete Solutions
45
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,60 @@
1
+ program SpaceAge;
2
+
3
+ {$IFNDEF TESTINSIGHT}
4
+ {$APPTYPE CONSOLE}
5
+ {$ENDIF}{$STRONGLINKTYPES ON}
6
+ uses
7
+ System.SysUtils,
8
+ {$IFDEF TESTINSIGHT}
9
+ TestInsight.DUnitX,
10
+ {$ENDIF }
11
+ DUnitX.Loggers.Console,
12
+ DUnitX.Loggers.Xml.NUnit,
13
+ DUnitX.TestFramework,
14
+ uSpaceAgeTests in 'uSpaceAgeTests.pas',
15
+ uSpaceAge in 'uSpaceAge.pas';
16
+
17
+ var
18
+ runner : ITestRunner;
19
+ results : IRunResults;
20
+ logger : ITestLogger;
21
+ nunitLogger : ITestLogger;
22
+ begin
23
+ {$IFDEF TESTINSIGHT}
24
+ TestInsight.DUnitX.RunRegisteredTests;
25
+ exit;
26
+ {$ENDIF}
27
+ try
28
+ //Check command line options, will exit if invalid
29
+ TDUnitX.CheckCommandLine;
30
+ //Create the test runner
31
+ runner := TDUnitX.CreateRunner;
32
+ //Tell the runner to use RTTI to find Fixtures
33
+ runner.UseRTTI := True;
34
+ //tell the runner how we will log things
35
+ //Log to the console window
36
+ logger := TDUnitXConsoleLogger.Create(true);
37
+ runner.AddLogger(logger);
38
+ //Generate an NUnit compatible XML File
39
+ nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
40
+ runner.AddLogger(nunitLogger);
41
+ runner.FailsOnNoAsserts := True; //When true, Assertions must be made during tests;
42
+
43
+ //Run tests
44
+ results := runner.Execute;
45
+ if not results.AllPassed then
46
+ System.ExitCode := EXIT_ERRORS;
47
+
48
+ {$IFNDEF CI}
49
+ //We don't want this happening when running under CI.
50
+ if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
51
+ begin
52
+ System.Write('Done.. press <Enter> key to quit.');
53
+ System.Readln;
54
+ end;
55
+ {$ENDIF}
56
+ except
57
+ on E: Exception do
58
+ System.Writeln(E.ClassName, ': ', E.Message);
59
+ end;
60
+ end.
@@ -0,0 +1,120 @@
1
+ unit uSpaceAge;
2
+
3
+ interface
4
+
5
+ type
6
+ ISpaceAge = interface(IInvokable)
7
+ ['{D2226242-6BFC-4C80-A9EB-D5A67FA406FE}']
8
+ function OnEarth: double;
9
+ function OnMercury: double;
10
+ function OnVenus: double;
11
+ function OnMars: double;
12
+ function OnJupiter: double;
13
+ function OnSaturn: double;
14
+ function OnUranus: double;
15
+ function OnNeptune: double;
16
+ end;
17
+
18
+ function NewSpaceAge(Seconds: Int64): ISpaceAge;
19
+
20
+ implementation
21
+ uses System.Generics.Collections, System.Math;
22
+
23
+ { TSpaceAge }
24
+ type
25
+ TSpaceAge = class(TInterfacedObject, ISpaceAge)
26
+ private
27
+ const
28
+ cEarth_Orbit_In_Seconds = 31557600;
29
+ type
30
+ TPlanets = (Earth, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune);
31
+ var
32
+ earthYearToPlanetPeriod: TDictionary<TPlanets, double>;
33
+ fSeconds: Int64;
34
+ function CalculateAge(periodInEarthYears: double): double;
35
+ constructor Create(Seconds: Int64);
36
+ destructor Destroy; override;
37
+ function OnEarth: double;
38
+ function OnMercury: double;
39
+ function OnVenus: double;
40
+ function OnMars: double;
41
+ function OnJupiter: double;
42
+ function OnSaturn: double;
43
+ function OnUranus: double;
44
+ function OnNeptune: double;
45
+ end;
46
+
47
+ function NewSpaceAge(Seconds: Int64): ISpaceAge;
48
+ begin
49
+ result := TSpaceAge.Create(Seconds);
50
+ end;
51
+
52
+ function TSpaceAge.CalculateAge(periodInEarthYears: double): double;
53
+ begin
54
+ result := SimpleRoundTo(fSeconds / (cEarth_Orbit_In_Seconds * periodInEarthYears), -2);
55
+ end;
56
+
57
+ constructor TSpaceAge.Create(Seconds: Int64);
58
+ begin
59
+ fSeconds := Seconds;
60
+ earthYearToPlanetPeriod := TDictionary<TPlanets, double>.Create;
61
+ with earthYearToPlanetPeriod do
62
+ begin
63
+ add(Earth, 1);
64
+ add(Mercury, 0.2408467);
65
+ add(Venus, 0.61519726);
66
+ add(Mars, 1.8808158);
67
+ add(Jupiter, 11.862615);
68
+ add(Saturn, 29.447498);
69
+ add(Uranus, 84.016846);
70
+ add(Neptune, 164.79132);
71
+ end;
72
+ end;
73
+
74
+ destructor TSpaceAge.Destroy;
75
+ begin
76
+ earthYearToPlanetPeriod.DisposeOf;
77
+ inherited;
78
+ end;
79
+
80
+ function TSpaceAge.OnEarth: double;
81
+ begin
82
+ result := CalculateAge(earthYearToPlanetPeriod[Earth]);
83
+ end;
84
+
85
+ function TSpaceAge.OnJupiter: double;
86
+ begin
87
+ result := CalculateAge(earthYearToPlanetPeriod[Jupiter]);
88
+ end;
89
+
90
+ function TSpaceAge.OnMars: double;
91
+ begin
92
+ result := CalculateAge(earthYearToPlanetPeriod[Mars]);
93
+ end;
94
+
95
+ function TSpaceAge.OnMercury: double;
96
+ begin
97
+ result := CalculateAge(earthYearToPlanetPeriod[Mercury]);
98
+ end;
99
+
100
+ function TSpaceAge.OnNeptune: double;
101
+ begin
102
+ result := CalculateAge(earthYearToPlanetPeriod[Neptune]);
103
+ end;
104
+
105
+ function TSpaceAge.OnSaturn: double;
106
+ begin
107
+ result := CalculateAge(earthYearToPlanetPeriod[Saturn]);
108
+ end;
109
+
110
+ function TSpaceAge.OnUranus: double;
111
+ begin
112
+ result := CalculateAge(earthYearToPlanetPeriod[Uranus]);
113
+ end;
114
+
115
+ function TSpaceAge.OnVenus: double;
116
+ begin
117
+ result := CalculateAge(earthYearToPlanetPeriod[Venus]);
118
+ end;
119
+
120
+ end.
@@ -0,0 +1,135 @@
1
+ unit uSpaceAgeTests;
2
+
3
+ interface
4
+ uses
5
+ DUnitX.TestFramework;
6
+
7
+ const
8
+ CanonicalVersion = '1.1.0';
9
+
10
+ type
11
+
12
+ [TestFixture]
13
+ SpaceAgeTests = class(TObject)
14
+ public
15
+ [Test]
16
+ // [Ignore('Comment the "[Ignore]" statement to run the test')]
17
+ procedure Age_on_earth;
18
+
19
+ [Test]
20
+ [Ignore]
21
+ procedure Age_on_mercury;
22
+
23
+ [Test]
24
+ [Ignore]
25
+ procedure Age_on_venus;
26
+
27
+ [Test]
28
+ [Ignore]
29
+ procedure Age_on_mars;
30
+
31
+ [Test]
32
+ [Ignore]
33
+ procedure Age_on_jupiter;
34
+
35
+ [Test]
36
+ [Ignore]
37
+ procedure Age_on_saturn;
38
+
39
+ [Test]
40
+ [Ignore]
41
+ procedure Age_on_uranus;
42
+
43
+ [Test]
44
+ [Ignore]
45
+ procedure Age_on_neptune;
46
+ end;
47
+
48
+ implementation
49
+ uses uSpaceAge;
50
+
51
+ { SpaceAgeTests }
52
+
53
+ procedure SpaceAgeTests.Age_on_earth;
54
+ var
55
+ MyAge: ISpaceAge;
56
+ expectedAge: double;
57
+ begin
58
+ MyAge := NewSpaceAge(1000000000);
59
+ expectedAge := 31.69;
60
+ Assert.AreEqual(expectedAge, MyAge.OnEarth);
61
+ end;
62
+
63
+ procedure SpaceAgeTests.Age_on_jupiter;
64
+ var
65
+ MyAge: ISpaceAge;
66
+ expectedAge: double;
67
+ begin
68
+ MyAge := NewSpaceAge(901876382);
69
+ expectedAge := 2.41;
70
+ Assert.AreEqual(expectedAge, MyAge.OnJupiter);
71
+ end;
72
+
73
+ procedure SpaceAgeTests.Age_on_mars;
74
+ var
75
+ MyAge: ISpaceAge;
76
+ expectedAge: double;
77
+ begin
78
+ MyAge := NewSpaceAge(2329871239);
79
+ expectedAge := 39.25;
80
+ Assert.AreEqual(expectedAge, MyAge.OnMars);
81
+ end;
82
+
83
+ procedure SpaceAgeTests.Age_on_mercury;
84
+ var
85
+ MyAge: ISpaceAge;
86
+ expectedAge: double;
87
+ begin
88
+ MyAge := NewSpaceAge(2134835688);
89
+ expectedAge := 280.88;
90
+ Assert.AreEqual(expectedAge, MyAge.OnMercury);
91
+ end;
92
+
93
+ procedure SpaceAgeTests.Age_on_neptune;
94
+ var
95
+ MyAge: ISpaceAge;
96
+ expectedAge: double;
97
+ begin
98
+ MyAge := NewSpaceAge(8210123456);
99
+ expectedAge := 1.58;
100
+ Assert.AreEqual(expectedAge, MyAge.OnNeptune);
101
+ end;
102
+
103
+ procedure SpaceAgeTests.Age_on_saturn;
104
+ var
105
+ MyAge: ISpaceAge;
106
+ expectedAge: double;
107
+ begin
108
+ MyAge := NewSpaceAge(3000000000);
109
+ expectedAge := 3.23;
110
+ Assert.AreEqual(expectedAge, MyAge.OnSaturn);
111
+ end;
112
+
113
+ procedure SpaceAgeTests.Age_on_uranus;
114
+ var
115
+ MyAge: ISpaceAge;
116
+ expectedAge: double;
117
+ begin
118
+ MyAge := NewSpaceAge(3210123456);
119
+ expectedAge := 1.21;
120
+ Assert.AreEqual(expectedAge, MyAge.OnUranus);
121
+ end;
122
+
123
+ procedure SpaceAgeTests.Age_on_venus;
124
+ var
125
+ MyAge: ISpaceAge;
126
+ expectedAge: double;
127
+ begin
128
+ MyAge := NewSpaceAge(189839836);
129
+ expectedAge := 9.78;
130
+ Assert.AreEqual(expectedAge, MyAge.OnVenus);
131
+ end;
132
+
133
+ initialization
134
+ TDUnitX.RegisterTestFixture(SpaceAgeTests);
135
+ end.