trackler 2.2.1.13 → 2.2.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/change/canonical-data.json +8 -1
  4. data/tracks/csharp/config.json +25 -26
  5. data/tracks/csharp/docs/SNIPPET.txt +7 -0
  6. data/tracks/csharp/exercises/house/Example.cs +5 -5
  7. data/tracks/csharp/exercises/house/House.cs +6 -1
  8. data/tracks/csharp/exercises/house/HouseTest.cs +208 -5
  9. data/tracks/csharp/exercises/phone-number/Example.cs +2 -1
  10. data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +8 -7
  11. data/tracks/csharp/exercises/rna-transcription/Example.cs +2 -1
  12. data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +4 -3
  13. data/tracks/csharp/exercises/say/SayTest.cs +20 -24
  14. data/tracks/csharp/exercises/sieve/Example.cs +6 -0
  15. data/tracks/csharp/exercises/sieve/SieveTest.cs +25 -17
  16. data/tracks/csharp/exercises/space-age/SpaceAgeTest.cs +19 -24
  17. data/tracks/csharp/exercises/sum-of-multiples/Example.cs +1 -1
  18. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiples.cs +1 -1
  19. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiplesTest.cs +48 -16
  20. data/tracks/csharp/generators/Exercises/House.cs +16 -0
  21. data/tracks/csharp/generators/Exercises/PhoneNumber.cs +3 -1
  22. data/tracks/csharp/generators/Exercises/RnaTranscription.cs +11 -1
  23. data/tracks/csharp/generators/Exercises/Say.cs +22 -0
  24. data/tracks/csharp/generators/Exercises/Sieve.cs +17 -0
  25. data/tracks/csharp/generators/Exercises/SpaceAge.cs +25 -0
  26. data/tracks/csharp/generators/Exercises/SumOfMultiples.cs +22 -0
  27. data/tracks/csharp/generators/Output/ValueFormatter.cs +4 -0
  28. data/tracks/dart/docs/ABOUT.md +21 -0
  29. data/tracks/ecmascript/README.md +1 -1
  30. data/tracks/ecmascript/config.json +15 -0
  31. data/tracks/ecmascript/exercises/proverb/README.md +63 -0
  32. data/tracks/ecmascript/exercises/proverb/example.js +23 -0
  33. data/tracks/ecmascript/exercises/proverb/package.json +69 -0
  34. data/tracks/ecmascript/exercises/proverb/proverb.spec.js +70 -0
  35. data/tracks/go/config.json +226 -226
  36. data/tracks/groovy/config.json +11 -0
  37. data/tracks/groovy/exercises/two-fer/Example.groovy +6 -0
  38. data/tracks/groovy/exercises/two-fer/README.md +62 -0
  39. data/tracks/groovy/exercises/two-fer/TwoFer.groovy +6 -0
  40. data/tracks/groovy/exercises/two-fer/TwoFerSpec.groovy +24 -0
  41. data/tracks/java/.travis.yml +2 -2
  42. data/tracks/java/bin/journey-test.sh +44 -1
  43. data/tracks/java/bin/run-journey-test-from-ci.sh +28 -0
  44. data/tracks/java/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
  45. data/tracks/java/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
  46. data/tracks/java/exercises/change/src/test/java/ChangeCalculatorTest.java +27 -2
  47. data/tracks/java/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
  48. data/tracks/java/exercises/hamming/{HINTS.md → .meta/hints.md} +0 -0
  49. data/tracks/java/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
  50. data/tracks/java/exercises/isogram/{HINTS.md → .meta/hints.md} +0 -0
  51. data/tracks/java/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
  52. data/tracks/java/exercises/pig-latin/src/example/java/PigLatinTranslator.java +17 -20
  53. data/tracks/java/exercises/simple-cipher/{HINTS.md → .meta/hints.md} +0 -0
  54. data/tracks/java/exercises/two-fer/{HINTS.md → .meta/hints.md} +0 -0
  55. data/tracks/kotlin/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
  56. data/tracks/kotlin/exercises/accumulate/README.md +1 -4
  57. data/tracks/kotlin/exercises/acronym/README.md +1 -1
  58. data/tracks/kotlin/exercises/all-your-base/README.md +1 -1
  59. data/tracks/kotlin/exercises/allergies/README.md +1 -1
  60. data/tracks/kotlin/exercises/anagram/README.md +1 -1
  61. data/tracks/kotlin/exercises/atbash-cipher/README.md +1 -1
  62. data/tracks/kotlin/exercises/bank-account/README.md +1 -1
  63. data/tracks/kotlin/exercises/beer-song/README.md +1 -1
  64. data/tracks/kotlin/exercises/binary-search/README.md +1 -1
  65. data/tracks/kotlin/exercises/binary/README.md +1 -1
  66. data/tracks/kotlin/exercises/bob/README.md +1 -1
  67. data/tracks/kotlin/exercises/bracket-push/README.md +1 -1
  68. data/tracks/kotlin/exercises/change/README.md +1 -1
  69. data/tracks/kotlin/exercises/clock/README.md +1 -1
  70. data/tracks/kotlin/exercises/collatz-conjecture/README.md +1 -1
  71. data/tracks/kotlin/exercises/complex-numbers/README.md +1 -1
  72. data/tracks/kotlin/exercises/diamond/README.md +1 -1
  73. data/tracks/kotlin/exercises/difference-of-squares/README.md +1 -1
  74. data/tracks/kotlin/exercises/etl/README.md +1 -1
  75. data/tracks/kotlin/exercises/flatten-array/README.md +1 -1
  76. data/tracks/kotlin/exercises/gigasecond/README.md +1 -1
  77. data/tracks/kotlin/exercises/grade-school/README.md +1 -1
  78. data/tracks/kotlin/exercises/grains/README.md +1 -1
  79. data/tracks/kotlin/exercises/hamming/README.md +1 -1
  80. data/tracks/kotlin/exercises/hello-world/README.md +1 -1
  81. data/tracks/kotlin/exercises/hexadecimal/README.md +1 -1
  82. data/tracks/kotlin/exercises/isogram/README.md +1 -1
  83. data/tracks/kotlin/exercises/largest-series-product/README.md +1 -1
  84. data/tracks/kotlin/exercises/leap/README.md +1 -1
  85. data/tracks/kotlin/exercises/linked-list/README.md +1 -1
  86. data/tracks/kotlin/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
  87. data/tracks/kotlin/exercises/list-ops/README.md +1 -1
  88. data/tracks/kotlin/exercises/luhn/README.md +1 -1
  89. data/tracks/kotlin/exercises/minesweeper/README.md +1 -1
  90. data/tracks/kotlin/exercises/nth-prime/README.md +1 -1
  91. data/tracks/kotlin/exercises/nucleotide-count/README.md +1 -1
  92. data/tracks/kotlin/exercises/pangram/README.md +1 -1
  93. data/tracks/kotlin/exercises/pascals-triangle/README.md +1 -1
  94. data/tracks/kotlin/exercises/perfect-numbers/README.md +1 -1
  95. data/tracks/kotlin/exercises/phone-number/README.md +1 -1
  96. data/tracks/kotlin/exercises/pig-latin/README.md +1 -1
  97. data/tracks/kotlin/exercises/prime-factors/README.md +1 -1
  98. data/tracks/kotlin/exercises/raindrops/README.md +1 -1
  99. data/tracks/kotlin/exercises/react/README.md +1 -1
  100. data/tracks/kotlin/exercises/rna-transcription/README.md +1 -1
  101. data/tracks/kotlin/exercises/robot-name/README.md +1 -1
  102. data/tracks/kotlin/exercises/robot-simulator/README.md +1 -1
  103. data/tracks/kotlin/exercises/roman-numerals/README.md +1 -1
  104. data/tracks/kotlin/exercises/saddle-points/README.md +1 -1
  105. data/tracks/kotlin/exercises/scrabble-score/README.md +1 -1
  106. data/tracks/kotlin/exercises/secret-handshake/README.md +1 -1
  107. data/tracks/kotlin/exercises/series/README.md +1 -1
  108. data/tracks/kotlin/exercises/sieve/README.md +1 -1
  109. data/tracks/kotlin/exercises/simple-cipher/README.md +2 -2
  110. data/tracks/kotlin/exercises/space-age/README.md +3 -2
  111. data/tracks/kotlin/exercises/spiral-matrix/README.md +1 -1
  112. data/tracks/kotlin/exercises/strain/README.md +1 -1
  113. data/tracks/kotlin/exercises/sublist/README.md +1 -1
  114. data/tracks/kotlin/exercises/sum-of-multiples/README.md +1 -1
  115. data/tracks/kotlin/exercises/triangle/README.md +1 -1
  116. data/tracks/kotlin/exercises/word-count/README.md +1 -1
  117. data/tracks/pony/exercises/atbash-cipher/example.pony +4 -3
  118. data/tracks/pony/exercises/beer-song/example.pony +10 -9
  119. data/tracks/pony/exercises/bob/example.pony +1 -1
  120. data/tracks/pony/exercises/difference-of-squares/example.pony +2 -2
  121. data/tracks/pony/exercises/hamming/example.pony +1 -1
  122. data/tracks/pony/exercises/hamming/test.pony +2 -2
  123. data/tracks/pony/exercises/leap/example.pony +1 -1
  124. data/tracks/pony/exercises/pascals-triangle/example.pony +2 -2
  125. data/tracks/pony/exercises/rna-transcription/test.pony +2 -2
  126. data/tracks/pony/exercises/roman-numerals/test.pony +2 -2
  127. data/tracks/python/config.json +22 -0
  128. data/tracks/python/docs/ABOUT.md +11 -3
  129. data/tracks/python/exercises/collatz-conjecture/README.md +61 -0
  130. data/tracks/python/exercises/collatz-conjecture/collatz_conjecture.py +2 -0
  131. data/tracks/python/exercises/collatz-conjecture/collatz_conjecture_test.py +32 -0
  132. data/tracks/python/exercises/collatz-conjecture/example.py +17 -0
  133. data/tracks/python/exercises/isogram/isogram.py +1 -1
  134. data/tracks/python/exercises/isogram/isogram_test.py +3 -0
  135. data/tracks/python/exercises/scale-generator/example.py +2 -0
  136. data/tracks/python/exercises/scale-generator/scale_generator_test.py +4 -0
  137. data/tracks/python/exercises/two-fer/README.md +29 -0
  138. data/tracks/python/exercises/two-fer/example.py +5 -0
  139. data/tracks/python/exercises/two-fer/two_fer.py +2 -0
  140. data/tracks/python/exercises/two-fer/two_fer_test.py +18 -0
  141. data/tracks/r/config/maintainers.json +2 -2
  142. data/tracks/ruby/config.json +2 -1
  143. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +85 -36
  144. data/tracks/scala/testgen/src/main/scala/MinesweeperTestGenerator.scala +15 -0
  145. data/tracks/vimscript/README.md +1 -1
  146. metadata +37 -13
@@ -78,6 +78,17 @@
78
78
  "logical operators"
79
79
  ]
80
80
  },
81
+ {
82
+ "uuid": "3227f4a2-0ffc-1480-5018-4ef3479dbcffdcf3f2b",
83
+ "slug": "two-fer",
84
+ "core": true,
85
+ "unlocked_by": null,
86
+ "difficulty": 1,
87
+ "topics": [
88
+ "strings",
89
+ "control-flow (if-else statements)"
90
+ ]
91
+ },
81
92
  {
82
93
  "uuid": "307f0a89-f185-41de-9ab7-f8d7ebfa3a2b",
83
94
  "slug": "nth-prime",
@@ -0,0 +1,6 @@
1
+ class TwoFer {
2
+
3
+ static String twoFer(String name) {
4
+ return name == null || name.isEmpty() ? "One for you, one for me." : "One for ${name}, one for me."
5
+ }
6
+ }
@@ -0,0 +1,62 @@
1
+ # Two Fer
2
+
3
+ `Two-fer` or `2-fer` is short for two for one. One for you and one for me.
4
+
5
+ ```
6
+ "One for X, one for me."
7
+ ```
8
+
9
+ When X is a name or "you".
10
+
11
+ If the given name is "Alice", the result should be "One for Alice, one for me."
12
+ If no name is given, the result should be "One for you, one for me."
13
+
14
+
15
+ ## Test-Driven Development
16
+
17
+ As programmers mature, they eventually want to test their code.
18
+
19
+ Here at Exercism we simulate [Test-Driven
20
+ Development](http://en.wikipedia.org/wiki/Test-driven_development) (TDD), where
21
+ you write your tests before writing any functionality. The simulation comes in
22
+ the form of a pre-written test suite, which will signal that you have solved
23
+ the problem.
24
+
25
+ It will also provide you with a safety net to explore other solutions without
26
+ breaking the functionality.
27
+
28
+ ### A typical TDD workflow on Exercism:
29
+
30
+ 1. Run the test file and pick one test that's failing.
31
+ 2. Write some code to fix the test you picked.
32
+ 3. Re-run the tests to confirm the test is now passing.
33
+ 4. Repeat from step 1.
34
+ 5. Submit your solution (`exercism submit /path/to/file`)
35
+
36
+ ## Instructions
37
+
38
+ Submissions are encouraged to be general, within reason. Having said that, it's
39
+ also important not to over-engineer a solution.
40
+
41
+ It's important to remember that the goal is to make code as expressive and
42
+ readable as we can.
43
+
44
+ For installation and learning resources, refer to the
45
+ [exercism help page](http://exercism.io/languages/groovy).
46
+
47
+ Run the tests by executing the test script.
48
+
49
+ ```
50
+ $ groovy ./TwoFerSpec.groovy
51
+ ```
52
+
53
+ After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
54
+
55
+ When all tests pass, congratulations!
56
+
57
+ ## Source
58
+
59
+ This is an exercise to introduce users to basic programming constructs, just after hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
60
+
61
+ ## Submitting Incomplete Solutions
62
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,6 @@
1
+ class TwoFer {
2
+
3
+ static String twoFer(String name) {
4
+ throw UnsupportedOperionExcetion('Method is not implemented')
5
+ }
6
+ }
@@ -0,0 +1,24 @@
1
+ @Grab('org.spockframework:spock-core:1.0-groovy-2.4')
2
+
3
+ import spock.lang.Specification
4
+
5
+ class TwoFerSpec extends Specification {
6
+
7
+ def 'no name given'() {
8
+ expect: TwoFer.twoFer() == 'One for you, one for me.'
9
+ }
10
+
11
+ def 'empty name given'() {
12
+ expect: TwoFer.twoFer('') == 'One for you, one for me.'
13
+ }
14
+
15
+ def 'Alice given as a name'() {
16
+ expect: TwoFer.twoFer('Alice') == 'One for Alice, one for me.'
17
+ }
18
+
19
+ def 'Bob given as name'() {
20
+ expect: TwoFer.twoFer('Bob') == 'One for Bob, one for me.'
21
+ }
22
+
23
+
24
+ }
@@ -4,7 +4,8 @@ jdk:
4
4
  - oraclejdk8
5
5
  env:
6
6
  - SCRIPT=bin/unit-tests.sh
7
- - SCRIPT=bin/journey-test.sh
7
+
8
+ - SCRIPT=bin/run-journey-test-from-ci.sh
8
9
 
9
10
  # http://docs.travis-ci.com/user/migrating-from-legacy
10
11
  sudo: false
@@ -17,7 +18,6 @@ addons:
17
18
  before_install:
18
19
  - rvm install 2.2.5
19
20
  - rvm use 2.2.5
20
- - bin/build-jq.sh # we want jq 1.5 features; not avail through pkg repo.
21
21
 
22
22
  # https://docs.travis-ci.com/user/customizing-the-build#Skipping-the-Installation-Step
23
23
  install: true # if we don't skip install, ./gradlew assemble is invoked, but this task is not available.
@@ -4,6 +4,7 @@ TRACK=java
4
4
  TRACK_REPO="$TRACK"
5
5
  TRACK_SRC_EXT="java"
6
6
  CPU_CORES=`getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`
7
+ EXERCISES_TO_SOLVE=$@
7
8
 
8
9
  on_exit() {
9
10
  echo ">>> on_exit()"
@@ -256,6 +257,42 @@ solve_all_exercises() {
256
257
  popd
257
258
  }
258
259
 
260
+ solve_single_exercise() {
261
+ local exercism_exercises_dir="$1"
262
+ local exercism_configfile="$2"
263
+ local exercise_to_solve="$3"
264
+ echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\", exercise_to_solve=\"$exercise_to_solve\")"
265
+
266
+ local track_root=$( pwd )
267
+ local exercism_cli="./exercism --config ${exercism_configfile}"
268
+ local tempfile="${TMPDIR:-/tmp}/journey-test.sh-unignore_all_tests.txt"
269
+
270
+ pushd ${exercism_exercises_dir}
271
+
272
+ echo -e "\n\n"
273
+ echo "=================================================="
274
+ echo "Solving ${exercise_to_solve}"
275
+ echo "=================================================="
276
+
277
+ ${exercism_cli} fetch ${TRACK} $exercise_to_solve
278
+ cp -R -H ${track_root}/exercises/${exercise_to_solve}/src/example/${TRACK}/* ${exercism_exercises_dir}/${TRACK}/${exercise_to_solve}/src/main/${TRACK}/
279
+
280
+ pushd ${exercism_exercises_dir}/${TRACK}/${exercise_to_solve}
281
+ # Check that tests compile before we strip @Ignore annotations
282
+ "$EXECPATH"/gradlew compileTestJava
283
+ # Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
284
+ for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
285
+ # Strip @Ignore annotations to ensure we run the tests (as delivered, all but the first is @Ignore'd).
286
+ # Note that unit-test.sh also strips @Ignore annotations via the Gradle task copyTestsFilteringIgnores.
287
+ # The stripping implementations here and in copyTestsFilteringIgnores should be kept consistent.
288
+ sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
289
+ done
290
+ "$EXECPATH"/gradlew test
291
+ popd
292
+
293
+ popd
294
+ }
295
+
259
296
  main() {
260
297
  # all functions assume current working directory is repository root.
261
298
  cd "${SCRIPTPATH}/.."
@@ -296,7 +333,13 @@ main() {
296
333
  # Create a CLI install and config just for this build; this script does not use your CLI install.
297
334
  configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
298
335
 
299
- solve_all_exercises "${exercism_home}" "${exercism_configfile}"
336
+ if [[ $EXERCISES_TO_SOLVE == "" ]]; then
337
+ solve_all_exercises "${exercism_home}" "${exercism_configfile}"
338
+ else
339
+ for exercise in $EXERCISES_TO_SOLVE
340
+ do solve_single_exercise "${exercism_home}" "${exercism_configfile}" "${exercise}"
341
+ done
342
+ fi
300
343
  }
301
344
 
302
345
  ##########################################################################
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+
3
+ bin/build-jq.sh
4
+
5
+ pr_files_json=`curl -s https://api.github.com/repos/exercism/java/pulls/${TRAVIS_PULL_REQUEST}/files`
6
+
7
+ # if jq fails to get the required data, then that means TRAVIS_PULL_REQUEST was not set (not run in travis-ci),
8
+ # or was false (not a pull request). In that case, we should fall back with testing every exercise
9
+
10
+ modded_files=`echo $pr_files_json | bin/jq -r '.[].filename'` || bin/journey-test.sh
11
+
12
+ for file in $modded_files
13
+ do if [[ $file == exercises* ]] || [[ $file == config.json ]]
14
+ then
15
+ for file2 in $modded_files
16
+ do if [[ $file2 == exercises* ]]
17
+ then modded_exercise=${file2#exercises/}
18
+ modded_exercise=${modded_exercise%%/*}
19
+ if [[ $last_modded_exercise != $modded_exercise ]]
20
+ then modded_exercises=$modded_exercises$modded_exercise$'\n'
21
+ fi
22
+ last_modded_exercise=$modded_exercise
23
+ fi
24
+ done
25
+ bin/journey-test.sh $modded_exercises
26
+ break
27
+ fi
28
+ done
@@ -8,6 +8,9 @@ import static java.util.Collections.emptyList;
8
8
  import static java.util.Collections.singletonList;
9
9
  import static org.junit.Assert.assertEquals;
10
10
 
11
+ /*
12
+ * version: 1.1.0
13
+ */
11
14
  public class ChangeCalculatorTest {
12
15
 
13
16
  @Rule
@@ -35,7 +38,7 @@ public class ChangeCalculatorTest {
35
38
  @Ignore("Remove to run test")
36
39
  @Test
37
40
  // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
38
- public void testLilliputianCurrencyForWhichGreedyAlgorithmFails() {
41
+ public void testLilliputianCurrency() {
39
42
  ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 4, 15, 20, 50));
40
43
 
41
44
  assertEquals(
@@ -46,7 +49,7 @@ public class ChangeCalculatorTest {
46
49
  @Ignore("Remove to run test")
47
50
  @Test
48
51
  // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
49
- public void testLowerElbonianCurrencyForWhichGreedyAlgorithmFails() {
52
+ public void testLowerElbonianCurrency() {
50
53
  ChangeCalculator changeCalculator = new ChangeCalculator(asList(1, 5, 10, 21, 25));
51
54
 
52
55
  assertEquals(
@@ -64,6 +67,28 @@ public class ChangeCalculatorTest {
64
67
  changeCalculator.computeMostEfficientChange(999));
65
68
  }
66
69
 
70
+ @Ignore("Remove to run test")
71
+ @Test
72
+ // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
73
+ public void testPossibleChangeWithoutUnitCoinAvailable() {
74
+ ChangeCalculator changeCalculator = new ChangeCalculator(asList(2, 5, 10, 20, 50));
75
+
76
+ assertEquals(
77
+ asList(2, 2, 2, 5, 10),
78
+ changeCalculator.computeMostEfficientChange(21));
79
+ }
80
+
81
+ @Ignore("Remove to run test")
82
+ @Test
83
+ // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
84
+ public void testAnotherPossibleChangeWithoutUnitCoinAvailable() {
85
+ ChangeCalculator changeCalculator = new ChangeCalculator(asList(4, 5));
86
+
87
+ assertEquals(
88
+ asList(4, 4, 4, 5, 5, 5),
89
+ changeCalculator.computeMostEfficientChange(27));
90
+ }
91
+
67
92
  @Ignore("Remove to run test")
68
93
  @Test
69
94
  public void testZeroChange() {
@@ -2,26 +2,23 @@ import java.util.Arrays;
2
2
  import java.util.List;
3
3
  import java.util.stream.Collectors;
4
4
 
5
- public class PigLatinTranslator {
6
-
7
- public static final String AY = "ay";
8
- public static final String THR = "thr";
9
- public static final String SCH = "sch";
10
- public static final String CH = "ch";
11
- public static final String QU = "qu";
12
- public static final String TH = "th";
13
- public static final String QUAY = "quay";
14
- public static final String XR = "xr";
15
- public static final String YT = "yt";
16
- public static final String VOWELS_REGEX = "[aeiou]";
17
-
18
- public String translate(String sentence) {
19
- List<String> translatedWords = Arrays.asList(sentence.split(" "))
20
- .stream()
21
- .map(x -> translateWord(x))
22
- .collect(Collectors.toList());
23
-
24
- return String.join(" ", translatedWords);
5
+ class PigLatinTranslator {
6
+
7
+ private static final String AY = "ay";
8
+ private static final String THR = "thr";
9
+ private static final String SCH = "sch";
10
+ private static final String CH = "ch";
11
+ private static final String QU = "qu";
12
+ private static final String TH = "th";
13
+ private static final String QUAY = "quay";
14
+ private static final String XR = "xr";
15
+ private static final String YT = "yt";
16
+ private static final String VOWELS_REGEX = "[aeiou]";
17
+
18
+ String translate(String sentence) {
19
+ return Arrays.stream(sentence.split(" "))
20
+ .map(this::translateWord)
21
+ .collect(Collectors.joining(" "));
25
22
  }
26
23
 
27
24
  private String translateWord(String word) {
@@ -25,10 +25,7 @@ Keep your hands off that collect/map/fmap/whatchamacallit functionality
25
25
  provided by your standard library!
26
26
  Solve this one yourself using other basic tools instead.
27
27
 
28
- Lisp specific: it's perfectly fine to use `MAPCAR` or the equivalent,
29
- as this is idiomatic Lisp, not a library function.
30
-
31
-
28
+
32
29
 
33
30
  ## Source
34
31
 
@@ -8,7 +8,7 @@ Help generate some jargon by writing a program that converts a long name
8
8
  like Portable Network Graphics to its acronym (PNG).
9
9
 
10
10
 
11
-
11
+
12
12
 
13
13
  ## Source
14
14
 
@@ -31,7 +31,7 @@ I think you got the idea!
31
31
 
32
32
  *Yes. Those three numbers above are exactly the same. Congratulations!*
33
33
 
34
-
34
+
35
35
 
36
36
 
37
37
  ## Submitting Incomplete Solutions
@@ -30,7 +30,7 @@ ignore those components of the score. For example, if the allergy
30
30
  score is 257, your program should only report the eggs (1) allergy.
31
31
 
32
32
 
33
-
33
+
34
34
 
35
35
  ## Source
36
36
 
@@ -6,7 +6,7 @@ Given `"listen"` and a list of candidates like `"enlists" "google"
6
6
  "inlets" "banana"` the program should return a list containing
7
7
  `"inlets"`.
8
8
 
9
-
9
+
10
10
 
11
11
  ## Source
12
12
 
@@ -27,7 +27,7 @@ things based on word boundaries.
27
27
  - Decoding `gvhg` gives `test`
28
28
  - Decoding `gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt` gives `thequickbrownfoxjumpsoverthelazydog`
29
29
 
30
-
30
+
31
31
 
32
32
  ## Source
33
33
 
@@ -26,7 +26,7 @@ it.
26
26
 
27
27
  Have fun!
28
28
 
29
-
29
+
30
30
 
31
31
 
32
32
  ## Submitting Incomplete Solutions
@@ -320,7 +320,7 @@ are some additional things you could try:
320
320
  Then please share your thoughts in a comment on the submission. Did this
321
321
  experiment make the code better? Worse? Did you learn anything from it?
322
322
 
323
-
323
+
324
324
 
325
325
  ## Source
326
326
 
@@ -34,7 +34,7 @@ A binary search halves the number of items to check with each iteration,
34
34
  so locating an item (or determining its absence) takes logarithmic time.
35
35
  A binary search is a dichotomic divide and conquer search algorithm.
36
36
 
37
-
37
+
38
38
 
39
39
  ## Source
40
40