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.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/change/canonical-data.json +8 -1
- data/tracks/csharp/config.json +25 -26
- data/tracks/csharp/docs/SNIPPET.txt +7 -0
- data/tracks/csharp/exercises/house/Example.cs +5 -5
- data/tracks/csharp/exercises/house/House.cs +6 -1
- data/tracks/csharp/exercises/house/HouseTest.cs +208 -5
- data/tracks/csharp/exercises/phone-number/Example.cs +2 -1
- data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +8 -7
- data/tracks/csharp/exercises/rna-transcription/Example.cs +2 -1
- data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +4 -3
- data/tracks/csharp/exercises/say/SayTest.cs +20 -24
- data/tracks/csharp/exercises/sieve/Example.cs +6 -0
- data/tracks/csharp/exercises/sieve/SieveTest.cs +25 -17
- data/tracks/csharp/exercises/space-age/SpaceAgeTest.cs +19 -24
- data/tracks/csharp/exercises/sum-of-multiples/Example.cs +1 -1
- data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiples.cs +1 -1
- data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiplesTest.cs +48 -16
- data/tracks/csharp/generators/Exercises/House.cs +16 -0
- data/tracks/csharp/generators/Exercises/PhoneNumber.cs +3 -1
- data/tracks/csharp/generators/Exercises/RnaTranscription.cs +11 -1
- data/tracks/csharp/generators/Exercises/Say.cs +22 -0
- data/tracks/csharp/generators/Exercises/Sieve.cs +17 -0
- data/tracks/csharp/generators/Exercises/SpaceAge.cs +25 -0
- data/tracks/csharp/generators/Exercises/SumOfMultiples.cs +22 -0
- data/tracks/csharp/generators/Output/ValueFormatter.cs +4 -0
- data/tracks/dart/docs/ABOUT.md +21 -0
- data/tracks/ecmascript/README.md +1 -1
- data/tracks/ecmascript/config.json +15 -0
- data/tracks/ecmascript/exercises/proverb/README.md +63 -0
- data/tracks/ecmascript/exercises/proverb/example.js +23 -0
- data/tracks/ecmascript/exercises/proverb/package.json +69 -0
- data/tracks/ecmascript/exercises/proverb/proverb.spec.js +70 -0
- data/tracks/go/config.json +226 -226
- data/tracks/groovy/config.json +11 -0
- data/tracks/groovy/exercises/two-fer/Example.groovy +6 -0
- data/tracks/groovy/exercises/two-fer/README.md +62 -0
- data/tracks/groovy/exercises/two-fer/TwoFer.groovy +6 -0
- data/tracks/groovy/exercises/two-fer/TwoFerSpec.groovy +24 -0
- data/tracks/java/.travis.yml +2 -2
- data/tracks/java/bin/journey-test.sh +44 -1
- data/tracks/java/bin/run-journey-test-from-ci.sh +28 -0
- data/tracks/java/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
- data/tracks/java/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/change/src/test/java/ChangeCalculatorTest.java +27 -2
- data/tracks/java/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/hamming/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/isogram/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/pig-latin/src/example/java/PigLatinTranslator.java +17 -20
- data/tracks/java/exercises/simple-cipher/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/two-fer/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/kotlin/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
- data/tracks/kotlin/exercises/accumulate/README.md +1 -4
- data/tracks/kotlin/exercises/acronym/README.md +1 -1
- data/tracks/kotlin/exercises/all-your-base/README.md +1 -1
- data/tracks/kotlin/exercises/allergies/README.md +1 -1
- data/tracks/kotlin/exercises/anagram/README.md +1 -1
- data/tracks/kotlin/exercises/atbash-cipher/README.md +1 -1
- data/tracks/kotlin/exercises/bank-account/README.md +1 -1
- data/tracks/kotlin/exercises/beer-song/README.md +1 -1
- data/tracks/kotlin/exercises/binary-search/README.md +1 -1
- data/tracks/kotlin/exercises/binary/README.md +1 -1
- data/tracks/kotlin/exercises/bob/README.md +1 -1
- data/tracks/kotlin/exercises/bracket-push/README.md +1 -1
- data/tracks/kotlin/exercises/change/README.md +1 -1
- data/tracks/kotlin/exercises/clock/README.md +1 -1
- data/tracks/kotlin/exercises/collatz-conjecture/README.md +1 -1
- data/tracks/kotlin/exercises/complex-numbers/README.md +1 -1
- data/tracks/kotlin/exercises/diamond/README.md +1 -1
- data/tracks/kotlin/exercises/difference-of-squares/README.md +1 -1
- data/tracks/kotlin/exercises/etl/README.md +1 -1
- data/tracks/kotlin/exercises/flatten-array/README.md +1 -1
- data/tracks/kotlin/exercises/gigasecond/README.md +1 -1
- data/tracks/kotlin/exercises/grade-school/README.md +1 -1
- data/tracks/kotlin/exercises/grains/README.md +1 -1
- data/tracks/kotlin/exercises/hamming/README.md +1 -1
- data/tracks/kotlin/exercises/hello-world/README.md +1 -1
- data/tracks/kotlin/exercises/hexadecimal/README.md +1 -1
- data/tracks/kotlin/exercises/isogram/README.md +1 -1
- data/tracks/kotlin/exercises/largest-series-product/README.md +1 -1
- data/tracks/kotlin/exercises/leap/README.md +1 -1
- data/tracks/kotlin/exercises/linked-list/README.md +1 -1
- data/tracks/kotlin/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/kotlin/exercises/list-ops/README.md +1 -1
- data/tracks/kotlin/exercises/luhn/README.md +1 -1
- data/tracks/kotlin/exercises/minesweeper/README.md +1 -1
- data/tracks/kotlin/exercises/nth-prime/README.md +1 -1
- data/tracks/kotlin/exercises/nucleotide-count/README.md +1 -1
- data/tracks/kotlin/exercises/pangram/README.md +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/README.md +1 -1
- data/tracks/kotlin/exercises/perfect-numbers/README.md +1 -1
- data/tracks/kotlin/exercises/phone-number/README.md +1 -1
- data/tracks/kotlin/exercises/pig-latin/README.md +1 -1
- data/tracks/kotlin/exercises/prime-factors/README.md +1 -1
- data/tracks/kotlin/exercises/raindrops/README.md +1 -1
- data/tracks/kotlin/exercises/react/README.md +1 -1
- data/tracks/kotlin/exercises/rna-transcription/README.md +1 -1
- data/tracks/kotlin/exercises/robot-name/README.md +1 -1
- data/tracks/kotlin/exercises/robot-simulator/README.md +1 -1
- data/tracks/kotlin/exercises/roman-numerals/README.md +1 -1
- data/tracks/kotlin/exercises/saddle-points/README.md +1 -1
- data/tracks/kotlin/exercises/scrabble-score/README.md +1 -1
- data/tracks/kotlin/exercises/secret-handshake/README.md +1 -1
- data/tracks/kotlin/exercises/series/README.md +1 -1
- data/tracks/kotlin/exercises/sieve/README.md +1 -1
- data/tracks/kotlin/exercises/simple-cipher/README.md +2 -2
- data/tracks/kotlin/exercises/space-age/README.md +3 -2
- data/tracks/kotlin/exercises/spiral-matrix/README.md +1 -1
- data/tracks/kotlin/exercises/strain/README.md +1 -1
- data/tracks/kotlin/exercises/sublist/README.md +1 -1
- data/tracks/kotlin/exercises/sum-of-multiples/README.md +1 -1
- data/tracks/kotlin/exercises/triangle/README.md +1 -1
- data/tracks/kotlin/exercises/word-count/README.md +1 -1
- data/tracks/pony/exercises/atbash-cipher/example.pony +4 -3
- data/tracks/pony/exercises/beer-song/example.pony +10 -9
- data/tracks/pony/exercises/bob/example.pony +1 -1
- data/tracks/pony/exercises/difference-of-squares/example.pony +2 -2
- data/tracks/pony/exercises/hamming/example.pony +1 -1
- data/tracks/pony/exercises/hamming/test.pony +2 -2
- data/tracks/pony/exercises/leap/example.pony +1 -1
- data/tracks/pony/exercises/pascals-triangle/example.pony +2 -2
- data/tracks/pony/exercises/rna-transcription/test.pony +2 -2
- data/tracks/pony/exercises/roman-numerals/test.pony +2 -2
- data/tracks/python/config.json +22 -0
- data/tracks/python/docs/ABOUT.md +11 -3
- data/tracks/python/exercises/collatz-conjecture/README.md +61 -0
- data/tracks/python/exercises/collatz-conjecture/collatz_conjecture.py +2 -0
- data/tracks/python/exercises/collatz-conjecture/collatz_conjecture_test.py +32 -0
- data/tracks/python/exercises/collatz-conjecture/example.py +17 -0
- data/tracks/python/exercises/isogram/isogram.py +1 -1
- data/tracks/python/exercises/isogram/isogram_test.py +3 -0
- data/tracks/python/exercises/scale-generator/example.py +2 -0
- data/tracks/python/exercises/scale-generator/scale_generator_test.py +4 -0
- data/tracks/python/exercises/two-fer/README.md +29 -0
- data/tracks/python/exercises/two-fer/example.py +5 -0
- data/tracks/python/exercises/two-fer/two_fer.py +2 -0
- data/tracks/python/exercises/two-fer/two_fer_test.py +18 -0
- data/tracks/r/config/maintainers.json +2 -2
- data/tracks/ruby/config.json +2 -1
- data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +85 -36
- data/tracks/scala/testgen/src/main/scala/MinesweeperTestGenerator.scala +15 -0
- data/tracks/vimscript/README.md +1 -1
- metadata +37 -13
data/tracks/groovy/config.json
CHANGED
@@ -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,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,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
|
+
}
|
data/tracks/java/.travis.yml
CHANGED
@@ -4,7 +4,8 @@ jdk:
|
|
4
4
|
- oraclejdk8
|
5
5
|
env:
|
6
6
|
- SCRIPT=bin/unit-tests.sh
|
7
|
-
|
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
|
-
|
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
|
File without changes
|
File without changes
|
@@ -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
|
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
|
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() {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,26 +2,23 @@ import java.util.Arrays;
|
|
2
2
|
import java.util.List;
|
3
3
|
import java.util.stream.Collectors;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
.
|
21
|
-
.
|
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) {
|
File without changes
|
File without changes
|
File without changes
|
@@ -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
|
-
|
29
|
-
as this is idiomatic Lisp, not a library function.
|
30
|
-
|
31
|
-
|
28
|
+
|
32
29
|
|
33
30
|
## Source
|
34
31
|
|