trackler 2.0.5.1 → 2.0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/tree-building/description.md +15 -3
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/ecmascript/exercises/queen-attack/queen-attack.spec.js +1 -1
  5. data/tracks/elm/.gitignore +1 -0
  6. data/tracks/elm/.travis.yml +3 -3
  7. data/tracks/elm/SETUP.md +16 -3
  8. data/tracks/elm/bin/build.sh +10 -10
  9. data/tracks/elm/bin/install-elm-format +1 -1
  10. data/tracks/elm/docs/INSTALLATION.md +2 -2
  11. data/tracks/elm/docs/TESTS.md +3 -3
  12. data/tracks/elm/elm-package.json +5 -5
  13. data/tracks/elm/exercises/accumulate/{Accumulate.example → Accumulate.example.elm} +0 -0
  14. data/tracks/elm/exercises/accumulate/{AccumulateTests.elm → Tests.elm} +2 -2
  15. data/tracks/elm/exercises/accumulate/elm-package.json +4 -4
  16. data/tracks/elm/exercises/accumulate/package.json +13 -0
  17. data/tracks/elm/exercises/allergies/{Allergies.example → Allergies.example.elm} +2 -2
  18. data/tracks/elm/exercises/allergies/{AllergiesTests.elm → Tests.elm} +2 -2
  19. data/tracks/elm/exercises/allergies/elm-package.json +4 -4
  20. data/tracks/elm/exercises/allergies/package.json +13 -0
  21. data/tracks/elm/exercises/anagram/{Anagram.example → Anagram.example.elm} +0 -0
  22. data/tracks/elm/exercises/anagram/{AnagramTests.elm → Tests.elm} +2 -2
  23. data/tracks/elm/exercises/anagram/elm-package.json +4 -4
  24. data/tracks/elm/exercises/anagram/package.json +13 -0
  25. data/tracks/elm/exercises/atbash-cipher/{AtbashCipher.example → AtbashCipher.example.elm} +0 -0
  26. data/tracks/elm/exercises/atbash-cipher/{AtbashCipherTests.elm → Tests.elm} +2 -2
  27. data/tracks/elm/exercises/atbash-cipher/elm-package.json +4 -4
  28. data/tracks/elm/exercises/atbash-cipher/package.json +13 -0
  29. data/tracks/elm/exercises/bob/{Bob.example → Bob.example.elm} +0 -0
  30. data/tracks/elm/exercises/bob/{BobTests.elm → Tests.elm} +3 -3
  31. data/tracks/elm/exercises/bob/elm-package.json +4 -4
  32. data/tracks/elm/exercises/bob/package.json +13 -0
  33. data/tracks/elm/exercises/difference-of-squares/{DifferenceOfSquares.example → DifferenceOfSquares.example.elm} +1 -1
  34. data/tracks/elm/exercises/difference-of-squares/{DifferenceOfSquaresTests.elm → Tests.elm} +2 -2
  35. data/tracks/elm/exercises/difference-of-squares/elm-package.json +4 -4
  36. data/tracks/elm/exercises/difference-of-squares/package.json +13 -0
  37. data/tracks/elm/exercises/gigasecond/{Gigasecond.example → Gigasecond.example.elm} +0 -0
  38. data/tracks/elm/exercises/gigasecond/{GigasecondTests.elm → Tests.elm} +2 -2
  39. data/tracks/elm/exercises/gigasecond/elm-package.json +4 -4
  40. data/tracks/elm/exercises/gigasecond/package.json +13 -0
  41. data/tracks/elm/exercises/grade-school/{GradeSchool.example → GradeSchool.example.elm} +1 -1
  42. data/tracks/elm/exercises/grade-school/{GradeSchoolTests.elm → Tests.elm} +2 -2
  43. data/tracks/elm/exercises/grade-school/elm-package.json +4 -4
  44. data/tracks/elm/exercises/grade-school/package.json +13 -0
  45. data/tracks/elm/exercises/hamming/{Hamming.example → Hamming.example.elm} +0 -0
  46. data/tracks/elm/exercises/hamming/{HammingTests.elm → Tests.elm} +2 -2
  47. data/tracks/elm/exercises/hamming/elm-package.json +4 -4
  48. data/tracks/elm/exercises/hamming/package.json +13 -0
  49. data/tracks/elm/exercises/hello-world/HelloWorld.elm +8 -8
  50. data/tracks/elm/exercises/hello-world/{HelloWorld.example → HelloWorld.example.elm} +0 -0
  51. data/tracks/elm/exercises/hello-world/{HelloWorldTests.elm → Tests.elm} +2 -2
  52. data/tracks/elm/exercises/hello-world/elm-package.json +4 -4
  53. data/tracks/elm/exercises/hello-world/package.json +13 -0
  54. data/tracks/elm/exercises/hello-world/yarn.lock +1136 -0
  55. data/tracks/elm/exercises/largest-series-product/{LargestSeriesProduct.example → LargestSeriesProduct.example.elm} +0 -0
  56. data/tracks/elm/exercises/largest-series-product/{LargestSeriesProductTests.elm → Tests.elm} +2 -2
  57. data/tracks/elm/exercises/largest-series-product/elm-package.json +4 -4
  58. data/tracks/elm/exercises/largest-series-product/package.json +13 -0
  59. data/tracks/elm/exercises/leap/{Leap.example → Leap.example.elm} +0 -0
  60. data/tracks/elm/exercises/leap/{LeapTests.elm → Tests.elm} +2 -2
  61. data/tracks/elm/exercises/leap/elm-package.json +4 -4
  62. data/tracks/elm/exercises/leap/package.json +13 -0
  63. data/tracks/elm/exercises/list-ops/{ListOps.example → ListOps.example.elm} +0 -0
  64. data/tracks/elm/exercises/list-ops/{ListOpsTests.elm → Tests.elm} +14 -14
  65. data/tracks/elm/exercises/list-ops/elm-package.json +4 -4
  66. data/tracks/elm/exercises/list-ops/package.json +13 -0
  67. data/tracks/elm/exercises/nucleotide-count/{NucleotideCount.example → NucleotideCount.example.elm} +0 -0
  68. data/tracks/elm/exercises/nucleotide-count/{NucleotideCountTests.elm → Tests.elm} +2 -2
  69. data/tracks/elm/exercises/nucleotide-count/elm-package.json +4 -4
  70. data/tracks/elm/exercises/nucleotide-count/package.json +13 -0
  71. data/tracks/elm/exercises/pangram/{Pangram.example → Pangram.example.elm} +0 -0
  72. data/tracks/elm/exercises/pangram/{PangramTests.elm → Tests.elm} +2 -2
  73. data/tracks/elm/exercises/pangram/elm-package.json +4 -4
  74. data/tracks/elm/exercises/pangram/package.json +13 -0
  75. data/tracks/elm/exercises/phone-number/{PhoneNumber.example → PhoneNumber.example.elm} +0 -0
  76. data/tracks/elm/exercises/phone-number/{PhoneNumberTests.elm → Tests.elm} +2 -2
  77. data/tracks/elm/exercises/phone-number/elm-package.json +4 -4
  78. data/tracks/elm/exercises/phone-number/package.json +13 -0
  79. data/tracks/elm/exercises/raindrops/{Raindrops.example → Raindrops.example.elm} +0 -0
  80. data/tracks/elm/exercises/raindrops/{RaindropsTests.elm → Tests.elm} +2 -2
  81. data/tracks/elm/exercises/raindrops/elm-package.json +4 -4
  82. data/tracks/elm/exercises/raindrops/package.json +13 -0
  83. data/tracks/elm/exercises/rna-transcription/{RNATranscription.example → RNATranscription.example.elm} +0 -0
  84. data/tracks/elm/exercises/rna-transcription/{RNATranscriptionTests.elm → Tests.elm} +2 -2
  85. data/tracks/elm/exercises/rna-transcription/elm-package.json +4 -4
  86. data/tracks/elm/exercises/rna-transcription/package.json +13 -0
  87. data/tracks/elm/exercises/robot-simulator/{RobotSimulator.example → RobotSimulator.example.elm} +0 -0
  88. data/tracks/elm/exercises/robot-simulator/{RobotSimulatorTests.elm → Tests.elm} +4 -4
  89. data/tracks/elm/exercises/robot-simulator/elm-package.json +4 -4
  90. data/tracks/elm/exercises/robot-simulator/package.json +13 -0
  91. data/tracks/elm/exercises/roman-numerals/{RomanNumerals.example → RomanNumerals.example.elm} +0 -0
  92. data/tracks/elm/exercises/roman-numerals/{RomanNumeralsTests.elm → Tests.elm} +2 -2
  93. data/tracks/elm/exercises/roman-numerals/elm-package.json +4 -4
  94. data/tracks/elm/exercises/roman-numerals/package.json +13 -0
  95. data/tracks/elm/exercises/run-length-encoding/{RunLengthEncoding.example → RunLengthEncoding.example.elm} +2 -2
  96. data/tracks/elm/exercises/run-length-encoding/{RunLengthEncodingTests.elm → Tests.elm} +2 -2
  97. data/tracks/elm/exercises/run-length-encoding/elm-package.json +4 -4
  98. data/tracks/elm/exercises/run-length-encoding/package.json +13 -0
  99. data/tracks/elm/exercises/say/{Say.example → Say.example.elm} +0 -0
  100. data/tracks/elm/exercises/say/{SayTests.elm → Tests.elm} +2 -2
  101. data/tracks/elm/exercises/say/elm-package.json +4 -4
  102. data/tracks/elm/exercises/say/package.json +13 -0
  103. data/tracks/elm/exercises/scrabble-score/{ScrabbleScore.example → ScrabbleScore.example.elm} +0 -0
  104. data/tracks/elm/exercises/scrabble-score/{ScrabbleScoreTests.elm → Tests.elm} +2 -2
  105. data/tracks/elm/exercises/scrabble-score/elm-package.json +4 -4
  106. data/tracks/elm/exercises/scrabble-score/package.json +13 -0
  107. data/tracks/elm/exercises/series/{Series.example → Series.example.elm} +0 -0
  108. data/tracks/elm/exercises/series/{SeriesTests.elm → Tests.elm} +2 -2
  109. data/tracks/elm/exercises/series/elm-package.json +4 -4
  110. data/tracks/elm/exercises/series/package.json +13 -0
  111. data/tracks/elm/exercises/space-age/{SpaceAge.example → SpaceAge.example.elm} +0 -0
  112. data/tracks/elm/exercises/space-age/{SpaceAgeTests.elm → Tests.elm} +2 -2
  113. data/tracks/elm/exercises/space-age/elm-package.json +4 -4
  114. data/tracks/elm/exercises/space-age/package.json +13 -0
  115. data/tracks/elm/exercises/strain/{Strain.example → Strain.example.elm} +0 -0
  116. data/tracks/elm/exercises/strain/{StrainTests.elm → Tests.elm} +3 -3
  117. data/tracks/elm/exercises/strain/elm-package.json +4 -4
  118. data/tracks/elm/exercises/strain/package.json +13 -0
  119. data/tracks/elm/exercises/sublist/{Sublist.example → Sublist.example.elm} +0 -0
  120. data/tracks/elm/exercises/sublist/{SublistTests.elm → Tests.elm} +5 -5
  121. data/tracks/elm/exercises/sublist/elm-package.json +4 -4
  122. data/tracks/elm/exercises/sublist/package.json +13 -0
  123. data/tracks/elm/exercises/sum-of-multiples/{SumOfMultiples.example → SumOfMultiples.example.elm} +1 -1
  124. data/tracks/elm/exercises/sum-of-multiples/{SumOfMultiplesTests.elm → Tests.elm} +2 -2
  125. data/tracks/elm/exercises/sum-of-multiples/elm-package.json +4 -4
  126. data/tracks/elm/exercises/sum-of-multiples/package.json +13 -0
  127. data/tracks/elm/exercises/triangle/{TriangleTests.elm → Tests.elm} +2 -2
  128. data/tracks/elm/exercises/triangle/{Triangle.example → Triangle.example.elm} +1 -1
  129. data/tracks/elm/exercises/triangle/elm-package.json +4 -4
  130. data/tracks/elm/exercises/triangle/package.json +13 -0
  131. data/tracks/elm/exercises/word-count/{WordCountTests.elm → Tests.elm} +2 -2
  132. data/tracks/elm/exercises/word-count/{WordCount.example → WordCount.example.elm} +0 -0
  133. data/tracks/elm/exercises/word-count/elm-package.json +4 -4
  134. data/tracks/elm/exercises/word-count/package.json +13 -0
  135. data/tracks/elm/package.json +10 -0
  136. data/tracks/fsharp/exercises/beer-song/HINTS.md +2 -0
  137. data/tracks/fsharp/exercises/grade-school/HINTS.md +3 -0
  138. data/tracks/fsharp/exercises/tree-building/Example.fs +7 -3
  139. data/tracks/fsharp/exercises/tree-building/TreeBuilding.fs +7 -4
  140. data/tracks/fsharp/exercises/tree-building/TreeBuildingTest.fs +49 -49
  141. data/tracks/fsharp/exercises/wordy/HINTS.md +3 -0
  142. data/tracks/java/config.json +13 -1
  143. data/tracks/java/exercises/anagram/build.gradle +0 -1
  144. data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +17 -13
  145. data/tracks/java/exercises/etl/build.gradle +0 -2
  146. data/tracks/java/exercises/grade-school/build.gradle +0 -1
  147. data/tracks/java/exercises/grade-school/src/test/java/SchoolTest.java +17 -13
  148. data/tracks/java/exercises/linked-list/build.gradle +0 -1
  149. data/tracks/java/exercises/linked-list/src/test/java/DequeTest.java +16 -15
  150. data/tracks/java/exercises/meetup/build.gradle +0 -1
  151. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +96 -95
  152. data/tracks/java/exercises/nth-prime/build.gradle +0 -1
  153. data/tracks/java/exercises/nth-prime/src/test/java/PrimeTest.java +6 -5
  154. data/tracks/java/exercises/palindrome-products/build.gradle +18 -0
  155. data/tracks/java/exercises/palindrome-products/src/example/java/Palindromes.java +77 -0
  156. data/tracks/java/exercises/palindrome-products/src/main/java/.keep +0 -0
  157. data/tracks/java/exercises/palindrome-products/src/test/java/PalindromesTest.java +162 -0
  158. data/tracks/java/exercises/settings.gradle +2 -0
  159. data/tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java +1 -2
  160. data/tracks/java/exercises/sum-of-multiples/src/main/java/SumOfMultiples.java +0 -1
  161. data/tracks/java/exercises/sum-of-multiples/src/test/{SumOfMultiplesTest.java → java/SumOfMultiplesTest.java} +12 -24
  162. data/tracks/java/exercises/wordy/build.gradle +17 -0
  163. data/tracks/java/exercises/wordy/src/example/java/WordProblemSolver.java +57 -0
  164. data/tracks/java/exercises/wordy/src/main/java/WordProblemSolver.java +5 -0
  165. data/tracks/java/exercises/wordy/src/test/java/WordProblemSolverTest.java +119 -0
  166. data/tracks/lua/docs/TESTS.md +1 -1
  167. data/tracks/ruby/lib/generator.rb +17 -8
  168. data/tracks/ruby/test/fixtures/exercises/alpha/.meta/.version +1 -0
  169. data/tracks/ruby/test/fixtures/exercises/alpha/alpha_test.rb +1 -0
  170. data/tracks/ruby/test/fixtures/exercises/alpha/example.rb +5 -0
  171. data/tracks/ruby/test/fixtures/exercises/alpha/example.tt +1 -0
  172. data/tracks/ruby/test/fixtures/metadata/exercises/alpha/canonical-data.json +11 -0
  173. data/tracks/ruby/test/generator_test.rb +54 -1
  174. data/tracks/swift/docs/TESTS.md +12 -12
  175. data/tracks/swift/{img/page_assets/001-splash.png → docs/img/tests_001-splash.png} +0 -0
  176. data/tracks/swift/{img/page_assets/002-templateChooser.png → docs/img/tests_002-templateChooser.png} +0 -0
  177. data/tracks/swift/{img/page_assets/003-nameProject.jpg → docs/img/tests_003-nameProject.jpg} +0 -0
  178. data/tracks/swift/{img/page_assets/004-saveProject.jpg → docs/img/tests_004-saveProject.jpg} +0 -0
  179. data/tracks/swift/{img/page_assets/005-folderLayout.png → docs/img/tests_005-folderLayout.png} +0 -0
  180. data/tracks/swift/{img/page_assets/006-newProjectInitial.jpg → docs/img/tests_006-newProjectInitial.jpg} +0 -0
  181. data/tracks/swift/{img/page_assets/007-fileInspectorUpdate.png → docs/img/tests_007-fileInspectorUpdate.png} +0 -0
  182. data/tracks/swift/{img/page_assets/008-templateChooserSwift.png → docs/img/tests_008-templateChooserSwift.png} +0 -0
  183. data/tracks/swift/{img/page_assets/009-importTestSource.png → docs/img/tests_009-importTestSource.png} +0 -0
  184. data/tracks/swift/{img/page_assets/010-testsImportExample.png → docs/img/tests_010-testsImportExample.png} +0 -0
  185. data/tracks/swift/{img/page_assets/011-finalLayoutExample.png → docs/img/tests_011-finalLayoutExample.png} +0 -0
  186. metadata +122 -134
  187. data/tracks/elm/exercises/accumulate/runtests.bat +0 -1
  188. data/tracks/elm/exercises/accumulate/runtests.sh +0 -2
  189. data/tracks/elm/exercises/allergies/runtests.bat +0 -1
  190. data/tracks/elm/exercises/allergies/runtests.sh +0 -2
  191. data/tracks/elm/exercises/anagram/runtests.bat +0 -1
  192. data/tracks/elm/exercises/anagram/runtests.sh +0 -2
  193. data/tracks/elm/exercises/atbash-cipher/runtests.bat +0 -1
  194. data/tracks/elm/exercises/atbash-cipher/runtests.sh +0 -2
  195. data/tracks/elm/exercises/bob/runtests.bat +0 -1
  196. data/tracks/elm/exercises/bob/runtests.sh +0 -2
  197. data/tracks/elm/exercises/difference-of-squares/runtests.bat +0 -1
  198. data/tracks/elm/exercises/difference-of-squares/runtests.sh +0 -2
  199. data/tracks/elm/exercises/gigasecond/runtests.bat +0 -1
  200. data/tracks/elm/exercises/gigasecond/runtests.sh +0 -2
  201. data/tracks/elm/exercises/grade-school/runtests.bat +0 -1
  202. data/tracks/elm/exercises/grade-school/runtests.sh +0 -2
  203. data/tracks/elm/exercises/hamming/runtests.bat +0 -1
  204. data/tracks/elm/exercises/hamming/runtests.sh +0 -2
  205. data/tracks/elm/exercises/hello-world/runtests.bat +0 -1
  206. data/tracks/elm/exercises/hello-world/runtests.sh +0 -2
  207. data/tracks/elm/exercises/largest-series-product/runtests.bat +0 -1
  208. data/tracks/elm/exercises/largest-series-product/runtests.sh +0 -2
  209. data/tracks/elm/exercises/leap/runtests.bat +0 -1
  210. data/tracks/elm/exercises/leap/runtests.sh +0 -2
  211. data/tracks/elm/exercises/list-ops/runtests.bat +0 -1
  212. data/tracks/elm/exercises/list-ops/runtests.sh +0 -2
  213. data/tracks/elm/exercises/nucleotide-count/runtests.bat +0 -1
  214. data/tracks/elm/exercises/nucleotide-count/runtests.sh +0 -2
  215. data/tracks/elm/exercises/pangram/runtests.bat +0 -1
  216. data/tracks/elm/exercises/pangram/runtests.sh +0 -2
  217. data/tracks/elm/exercises/phone-number/runtests.bat +0 -1
  218. data/tracks/elm/exercises/phone-number/runtests.sh +0 -2
  219. data/tracks/elm/exercises/raindrops/runtests.bat +0 -1
  220. data/tracks/elm/exercises/raindrops/runtests.sh +0 -2
  221. data/tracks/elm/exercises/rna-transcription/runtests.bat +0 -1
  222. data/tracks/elm/exercises/rna-transcription/runtests.sh +0 -2
  223. data/tracks/elm/exercises/robot-simulator/runtests.bat +0 -1
  224. data/tracks/elm/exercises/robot-simulator/runtests.sh +0 -2
  225. data/tracks/elm/exercises/roman-numerals/runtests.bat +0 -1
  226. data/tracks/elm/exercises/roman-numerals/runtests.sh +0 -2
  227. data/tracks/elm/exercises/run-length-encoding/runtests.bat +0 -1
  228. data/tracks/elm/exercises/run-length-encoding/runtests.sh +0 -2
  229. data/tracks/elm/exercises/say/runtests.bat +0 -1
  230. data/tracks/elm/exercises/say/runtests.sh +0 -2
  231. data/tracks/elm/exercises/scrabble-score/runtests.bat +0 -1
  232. data/tracks/elm/exercises/scrabble-score/runtests.sh +0 -2
  233. data/tracks/elm/exercises/series/runtests.bat +0 -1
  234. data/tracks/elm/exercises/series/runtests.sh +0 -2
  235. data/tracks/elm/exercises/space-age/runtests.bat +0 -1
  236. data/tracks/elm/exercises/space-age/runtests.sh +0 -2
  237. data/tracks/elm/exercises/strain/runtests.bat +0 -1
  238. data/tracks/elm/exercises/strain/runtests.sh +0 -2
  239. data/tracks/elm/exercises/sublist/runtests.bat +0 -1
  240. data/tracks/elm/exercises/sublist/runtests.sh +0 -2
  241. data/tracks/elm/exercises/sum-of-multiples/runtests.bat +0 -1
  242. data/tracks/elm/exercises/sum-of-multiples/runtests.sh +0 -2
  243. data/tracks/elm/exercises/triangle/runtests.bat +0 -1
  244. data/tracks/elm/exercises/triangle/runtests.sh +0 -2
  245. data/tracks/elm/exercises/word-count/runtests.bat +0 -1
  246. data/tracks/elm/exercises/word-count/runtests.sh +0 -2
@@ -8,7 +8,6 @@ repositories {
8
8
 
9
9
  dependencies {
10
10
  testCompile "junit:junit:4.12"
11
- testCompile "org.assertj:assertj-core:3.2.0"
12
11
  }
13
12
  test {
14
13
  testLogging {
@@ -1,31 +1,32 @@
1
1
  import org.junit.Test;
2
2
  import org.junit.Ignore;
3
3
 
4
- import static org.assertj.core.api.Assertions.assertThat;
4
+ import static org.hamcrest.CoreMatchers.*;
5
+ import static org.junit.Assert.*;
5
6
 
6
7
  public class PrimeTest {
7
8
 
8
9
  @Test
9
10
  public void testFirstPrime() {
10
- assertThat(Prime.nth(1)).isEqualTo(2);
11
+ assertThat(Prime.nth(1), is(2));
11
12
  }
12
13
 
13
14
  @Ignore
14
15
  @Test
15
16
  public void testSecondPrime() {
16
- assertThat(Prime.nth(2)).isEqualTo(3);
17
+ assertThat(Prime.nth(2), is(3));
17
18
  }
18
19
 
19
20
  @Ignore
20
21
  @Test
21
22
  public void testSixthPrime() {
22
- assertThat(Prime.nth(6)).isEqualTo(13);
23
+ assertThat(Prime.nth(6), is(13));
23
24
  }
24
25
 
25
26
  @Ignore
26
27
  @Test
27
28
  public void testBigPrime() {
28
- assertThat(Prime.nth(10001)).isEqualTo(104743);
29
+ assertThat(Prime.nth(10001), is(104743));
29
30
  }
30
31
 
31
32
  @Ignore
@@ -0,0 +1,18 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+
13
+ test {
14
+ testLogging {
15
+ exceptionFormat = 'full'
16
+ events = ["passed", "failed", "skipped"]
17
+ }
18
+ }
@@ -0,0 +1,77 @@
1
+
2
+ import java.util.ArrayList;
3
+ import java.util.Arrays;
4
+ import java.util.Collections;
5
+ import java.util.List;
6
+ import java.util.SortedMap;
7
+ import java.util.TreeMap;
8
+
9
+ public class Palindromes {
10
+
11
+ public static class PalindromeSortedSetBuilder {
12
+
13
+ private int minFactor = 1;
14
+ private int maxFactor = 1;
15
+
16
+ public PalindromeSortedSetBuilder() {
17
+ }
18
+
19
+ public PalindromeSortedSetBuilder withFactorsLessThanOrEqualTo(
20
+ final int maxFactor) {
21
+ this.maxFactor = maxFactor;
22
+ return this;
23
+ }
24
+
25
+ public PalindromeSortedSetBuilder withFactorsGreaterThanOrEqualTo(
26
+ final int minFactor) {
27
+ this.minFactor = minFactor;
28
+ return this;
29
+ }
30
+
31
+ public SortedMap<Long, List<List<Integer>>> build() {
32
+ SortedMap<Long, List<List<Integer>>> palindromes = new TreeMap<>();
33
+ long num;
34
+ List<List<Integer>> factors;
35
+ for (int i = this.maxFactor; i >= this.minFactor; i--) {
36
+ for (int j = this.maxFactor; j >= i; j--) {
37
+ num = i * j;
38
+ if (isPalindrome(num)) {
39
+ factors = palindromes.get(num);
40
+ if (factors == null) {
41
+ factors = new ArrayList<>();
42
+ }
43
+ factors.add(Arrays.asList(i, j));
44
+ palindromes.put(num, factors);
45
+ }
46
+ }
47
+ }
48
+ return Collections.unmodifiableSortedMap(palindromes);
49
+ }
50
+
51
+ // http://stackoverflow.com/questions/23984654/how-to-print-all-palindromes-upto-1000-without-using-any-string-stringbuilder
52
+ private long reverseNumber(long number) {
53
+ if (number < 10l) {
54
+ return number;
55
+ }
56
+ long result = 0;
57
+ long tmp = number;
58
+ while (tmp > 0) {
59
+ result = result * 10 + (tmp % 10);
60
+ tmp /= 10;
61
+
62
+ }
63
+ return result;
64
+ }
65
+
66
+ private boolean isPalindrome(long number) {
67
+ return number == reverseNumber(number);
68
+ }
69
+ }
70
+
71
+ private Palindromes() {
72
+ }
73
+
74
+ public static PalindromeSortedSetBuilder getPalindromeSortedListBuilder() {
75
+ return new PalindromeSortedSetBuilder();
76
+ }
77
+ }
@@ -0,0 +1,162 @@
1
+
2
+ import java.util.Arrays;
3
+ import java.util.Collections;
4
+ import java.util.List;
5
+ import java.util.SortedMap;
6
+ import java.util.stream.Collectors;
7
+ import static junit.framework.TestCase.assertEquals;
8
+ import static junit.framework.TestCase.assertFalse;
9
+ import static junit.framework.TestCase.assertNotNull;
10
+ import org.junit.Ignore;
11
+ import org.junit.Test;
12
+
13
+ public class PalindromesTest {
14
+
15
+ @Test
16
+ public void largestPalindromeFromSingleDigitFactors() {
17
+ final List<List<Integer>> expected = Collections.unmodifiableList(
18
+ Arrays.asList(
19
+ Arrays.asList(1, 9),
20
+ Arrays.asList(3, 3)
21
+ )
22
+ );
23
+ final long expectedValue = 9l;
24
+
25
+ final SortedMap<Long, List<List<Integer>>> palindromes
26
+ = Palindromes.getPalindromeSortedListBuilder()
27
+ .withFactorsLessThanOrEqualTo(9).build();
28
+
29
+ assertNotNull(palindromes);
30
+ assertFalse(palindromes.isEmpty());
31
+
32
+ long actualValue = palindromes.lastKey();
33
+ assertEquals(expectedValue, actualValue);
34
+
35
+ List<List<Integer>> actual = palindromes
36
+ .get(palindromes.lastKey())
37
+ .stream()
38
+ .sorted((a, b) -> Integer.compare(a.get(0), b.get(0)))
39
+ .collect(Collectors.toList());
40
+ assertEquals(expected, actual);
41
+ }
42
+
43
+ @Test
44
+ @Ignore
45
+ public void largestPalindromeFromDoubleDigitFactors() {
46
+ final List<List<Integer>> expected = Collections.unmodifiableList(
47
+ Arrays.asList(
48
+ Arrays.asList(91, 99)
49
+ )
50
+ );
51
+ final long expectedValue = 9009l;
52
+
53
+ final SortedMap<Long, List<List<Integer>>> palindromes
54
+ = Palindromes.getPalindromeSortedListBuilder()
55
+ .withFactorsLessThanOrEqualTo(99)
56
+ .withFactorsGreaterThanOrEqualTo(10)
57
+ .build();
58
+
59
+ assertNotNull(palindromes);
60
+ assertFalse(palindromes.isEmpty());
61
+
62
+ long actualValue = palindromes.lastKey();
63
+ assertEquals(expectedValue, actualValue);
64
+
65
+ List<List<Integer>> actual = palindromes
66
+ .get(palindromes.lastKey())
67
+ .stream()
68
+ .sorted((a, b) -> Integer.compare(a.get(0), b.get(0)))
69
+ .collect(Collectors.toList());
70
+ assertEquals(expected, actual);
71
+ }
72
+
73
+ @Test
74
+ @Ignore
75
+ public void smallestPalindromeFromDoubleDigitFactors() {
76
+ final List<List<Integer>> expected = Collections.unmodifiableList(
77
+ Arrays.asList(
78
+ Arrays.asList(11, 11)
79
+ )
80
+ );
81
+ final long expectedValue = 121l;
82
+
83
+ final SortedMap<Long, List<List<Integer>>> palindromes
84
+ = Palindromes.getPalindromeSortedListBuilder()
85
+ .withFactorsLessThanOrEqualTo(99)
86
+ .withFactorsGreaterThanOrEqualTo(10)
87
+ .build();
88
+
89
+ assertNotNull(palindromes);
90
+ assertFalse(palindromes.isEmpty());
91
+
92
+ long actualValue = palindromes.firstKey();
93
+ assertEquals(expectedValue, actualValue);
94
+
95
+ List<List<Integer>> actual = palindromes
96
+ .get(palindromes.firstKey())
97
+ .stream()
98
+ .sorted((a, b) -> Integer.compare(a.get(0), b.get(0)))
99
+ .collect(Collectors.toList());
100
+ assertEquals(expected, actual);
101
+ }
102
+
103
+ @Test
104
+ @Ignore
105
+ public void largestPalindromeFromTripleDigitFactors() {
106
+ final List<List<Integer>> expected = Collections.unmodifiableList(
107
+ Arrays.asList(
108
+ Arrays.asList(913, 993)
109
+ )
110
+ );
111
+ final long expectedValue = 906609l;
112
+
113
+ final SortedMap<Long, List<List<Integer>>> palindromes
114
+ = Palindromes.getPalindromeSortedListBuilder()
115
+ .withFactorsLessThanOrEqualTo(999)
116
+ .withFactorsGreaterThanOrEqualTo(100)
117
+ .build();
118
+
119
+ assertNotNull(palindromes);
120
+ assertFalse(palindromes.isEmpty());
121
+
122
+ long actualValue = palindromes.lastKey();
123
+ assertEquals(expectedValue, actualValue);
124
+
125
+ List<List<Integer>> actual = palindromes
126
+ .get(palindromes.lastKey())
127
+ .stream()
128
+ .sorted((a, b) -> Integer.compare(a.get(0), b.get(0)))
129
+ .collect(Collectors.toList());
130
+ assertEquals(expected, actual);
131
+ }
132
+
133
+ @Test
134
+ @Ignore
135
+ public void smallestPalindromeFromTripleDigitFactors() {
136
+ final List<List<Integer>> expected = Collections.unmodifiableList(
137
+ Arrays.asList(
138
+ Arrays.asList(101, 101)
139
+ )
140
+ );
141
+ final long expectedValue = 10201l;
142
+
143
+ final SortedMap<Long, List<List<Integer>>> palindromes
144
+ = Palindromes.getPalindromeSortedListBuilder()
145
+ .withFactorsLessThanOrEqualTo(999)
146
+ .withFactorsGreaterThanOrEqualTo(100)
147
+ .build();
148
+
149
+ assertNotNull(palindromes);
150
+ assertFalse(palindromes.isEmpty());
151
+
152
+ long actualValue = palindromes.firstKey();
153
+ assertEquals(expectedValue, actualValue);
154
+
155
+ List<List<Integer>> actual = palindromes
156
+ .get(palindromes.firstKey())
157
+ .stream()
158
+ .sorted((a, b) -> Integer.compare(a.get(0), b.get(0)))
159
+ .collect(Collectors.toList());
160
+ assertEquals(expected, actual);
161
+ }
162
+ }
@@ -25,6 +25,7 @@ include 'meetup'
25
25
  include 'nth-prime'
26
26
  include 'nucleotide-count'
27
27
  include 'octal'
28
+ include 'palindrome-products'
28
29
  include 'pangram'
29
30
  include 'pascals-triangle'
30
31
  include 'phone-number'
@@ -48,3 +49,4 @@ include 'strain'
48
49
  include 'triangle'
49
50
  include 'trinary'
50
51
  include 'word-count'
52
+ include 'wordy'
@@ -1,8 +1,7 @@
1
- import java.util.Arrays;
2
1
  public class SumOfMultiples {
3
2
 
4
3
 
5
- public int Sum(int number, int[] set) {
4
+ public static int sum(int number, int[] set) {
6
5
 
7
6
  int sum = 0;
8
7
  int count = 0;
@@ -1,4 +1,3 @@
1
- import java.util.Arrays;
2
1
  public class SumOfMultiples {
3
2
 
4
3
  }
@@ -9,12 +9,11 @@ public class SumOfMultiplesTest {
9
9
  @Test
10
10
  public void testSumOfMultiplesOf3and4UpToOne() {
11
11
 
12
- SumOfMultiples mySum = new SumOfMultiples();
13
12
  int[] set = {
14
13
  3,
15
14
  5
16
15
  };
17
- int output = mySum.Sum(1, set);
16
+ int output = SumOfMultiples.sum(1, set);
18
17
  assertEquals(0, output);
19
18
 
20
19
  }
@@ -24,12 +23,11 @@ public class SumOfMultiplesTest {
24
23
  @Ignore
25
24
  public void testSumOfMultiplesOf3and5UpToFour() {
26
25
 
27
- SumOfMultiples mySum = new SumOfMultiples();
28
26
  int[] set = {
29
27
  3,
30
28
  5
31
29
  };
32
- int output = mySum.Sum(4, set);
30
+ int output = SumOfMultiples.sum(4, set);
33
31
  assertEquals(3, output);
34
32
 
35
33
  }
@@ -39,12 +37,11 @@ public class SumOfMultiplesTest {
39
37
  @Ignore
40
38
  public void testSumOfMultiplesOf3and5UpToTen() {
41
39
 
42
- SumOfMultiples mySum = new SumOfMultiples();
43
40
  int[] set = {
44
41
  3,
45
42
  5
46
43
  };
47
- int output = mySum.Sum(10, set);
44
+ int output = SumOfMultiples.sum(10, set);
48
45
  assertEquals(23, output);
49
46
 
50
47
  }
@@ -54,12 +51,11 @@ public class SumOfMultiplesTest {
54
51
  @Ignore
55
52
  public void testSumOfMultiplesOf3and5UpToOneHundred() {
56
53
 
57
- SumOfMultiples mySum = new SumOfMultiples();
58
54
  int[] set = {
59
55
  3,
60
56
  5
61
57
  };
62
- int output = mySum.Sum(100, set);
58
+ int output = SumOfMultiples.sum(100, set);
63
59
  assertEquals(2318, output);
64
60
 
65
61
  }
@@ -69,12 +65,11 @@ public class SumOfMultiplesTest {
69
65
  @Ignore
70
66
  public void testSumOfMultiplesOf3and5UpToOneThousand() {
71
67
 
72
- SumOfMultiples mySum = new SumOfMultiples();
73
68
  int[] set = {
74
69
  3,
75
70
  5
76
71
  };
77
- int output = mySum.Sum(1000, set);
72
+ int output = SumOfMultiples.sum(1000, set);
78
73
  assertEquals(233168, output);
79
74
 
80
75
  }
@@ -84,13 +79,12 @@ public class SumOfMultiplesTest {
84
79
  @Ignore
85
80
  public void testSumOfMultiplesOf7and13and17UpToTwenty() {
86
81
 
87
- SumOfMultiples mySum = new SumOfMultiples();
88
82
  int[] set = {
89
83
  7,
90
84
  13,
91
85
  17
92
86
  };
93
- int output = mySum.Sum(20, set);
87
+ int output = SumOfMultiples.sum(20, set);
94
88
  assertEquals(51, output);
95
89
 
96
90
  }
@@ -100,12 +94,11 @@ public class SumOfMultiplesTest {
100
94
  @Ignore
101
95
  public void testSumOfMultiplesOf4and6UpToFifteen() {
102
96
 
103
- SumOfMultiples mySum = new SumOfMultiples();
104
97
  int[] set = {
105
98
  4,
106
99
  6
107
100
  };
108
- int output = mySum.Sum(15, set);
101
+ int output = SumOfMultiples.sum(15, set);
109
102
  assertEquals(30, output);
110
103
 
111
104
  }
@@ -115,13 +108,12 @@ public class SumOfMultiplesTest {
115
108
  @Ignore
116
109
  public void testSumOfMultiplesOf5and6and8UpToOneHundredFifty() {
117
110
 
118
- SumOfMultiples mySum = new SumOfMultiples();
119
111
  int[] set = {
120
112
  5,
121
113
  6,
122
114
  8
123
115
  };
124
- int output = mySum.Sum(150, set);
116
+ int output = SumOfMultiples.sum(150, set);
125
117
  assertEquals(4419, output);
126
118
 
127
119
  }
@@ -131,12 +123,11 @@ public class SumOfMultiplesTest {
131
123
  @Ignore
132
124
  public void testSumOfMultiplesOf5and25UpToTwoHundredSeventyFive() {
133
125
 
134
- SumOfMultiples mySum = new SumOfMultiples();
135
126
  int[] set = {
136
127
  5,
137
128
  25
138
129
  };
139
- int output = mySum.Sum(51, set);
130
+ int output = SumOfMultiples.sum(51, set);
140
131
  assertEquals(275, output);
141
132
 
142
133
  }
@@ -146,12 +137,11 @@ public class SumOfMultiplesTest {
146
137
  @Ignore
147
138
  public void testSumOfMultiplesOf43and47UpToTenThousand() {
148
139
 
149
- SumOfMultiples mySum = new SumOfMultiples();
150
140
  int[] set = {
151
141
  43,
152
142
  47
153
143
  };
154
- int output = mySum.Sum(10000, set);
144
+ int output = SumOfMultiples.sum(10000, set);
155
145
  assertEquals(2203160, output);
156
146
 
157
147
  }
@@ -161,11 +151,10 @@ public class SumOfMultiplesTest {
161
151
  @Ignore
162
152
  public void testSumOfMultiplesOfOneUpToOneHundred() {
163
153
 
164
- SumOfMultiples mySum = new SumOfMultiples();
165
154
  int[] set = {
166
155
  1
167
156
  };
168
- int output = mySum.Sum(100, set);
157
+ int output = SumOfMultiples.sum(100, set);
169
158
  assertEquals(4950, output);
170
159
 
171
160
  }
@@ -175,9 +164,8 @@ public class SumOfMultiplesTest {
175
164
  @Ignore
176
165
  public void testSumOfMultiplesOfNoneUpToTenThousand() {
177
166
 
178
- SumOfMultiples mySum = new SumOfMultiples();
179
167
  int[] set = {};
180
- int output = mySum.Sum(10000, set);
168
+ int output = SumOfMultiples.sum(10000, set);
181
169
  assertEquals(0, output);
182
170
 
183
171
  }