trackler 2.2.1.62 → 2.2.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/all-your-base/canonical-data.json +20 -29
- data/problem-specifications/exercises/forth/canonical-data.json +52 -5
- data/problem-specifications/exercises/isbn-verifier/canonical-data.json +15 -15
- data/problem-specifications/exercises/protein-translation/canonical-data.json +153 -0
- data/problem-specifications/exercises/reverse-string/canonical-data.json +39 -0
- data/problem-specifications/exercises/reverse-string/description.md +5 -0
- data/problem-specifications/exercises/reverse-string/metadata.yml +5 -0
- data/tracks/c/config.json +42 -41
- data/tracks/csharp/config.json +13 -0
- data/tracks/csharp/exercises/Exercises.sln +6 -0
- data/tracks/csharp/exercises/isbn-verifier/Example.cs +27 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifier.cs +9 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifier.csproj +19 -0
- data/tracks/csharp/exercises/isbn-verifier/IsbnVerifierTest.cs +84 -0
- data/tracks/csharp/exercises/isbn-verifier/README.md +40 -0
- data/tracks/csharp/generators/Exercises/IsbnVerifier.cs +15 -0
- data/tracks/delphi/config.json +28 -28
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/accumulate/rebar.config +1 -1
- data/tracks/erlang/exercises/accumulate/test/accumulate_tests.erl +9 -7
- data/tracks/erlang/exercises/all-your-base/rebar.config +1 -1
- data/tracks/erlang/exercises/all-your-base/test/all_your_base_tests.erl +26 -24
- data/tracks/erlang/exercises/allergies/rebar.config +1 -1
- data/tracks/erlang/exercises/allergies/test/allergies_tests.erl +19 -17
- data/tracks/erlang/exercises/anagram/rebar.config +1 -3
- data/tracks/erlang/exercises/anagram/test/anagram_tests.erl +14 -12
- data/tracks/erlang/exercises/atbash-cipher/rebar.config +1 -1
- data/tracks/erlang/exercises/atbash-cipher/test/atbash_cipher_tests.erl +7 -5
- data/tracks/erlang/exercises/bank-account/rebar.config +1 -1
- data/tracks/erlang/exercises/bank-account/test/bank_account_tests.erl +52 -51
- data/tracks/erlang/exercises/beer-song/rebar.config +30 -0
- data/tracks/erlang/exercises/beer-song/test/beer_song_tests.erl +11 -10
- data/tracks/erlang/exercises/bob/rebar.config +1 -1
- data/tracks/erlang/exercises/bob/test/bob_tests.erl +33 -35
- data/tracks/erlang/exercises/circular-buffer/rebar.config +1 -1
- data/tracks/erlang/exercises/circular-buffer/test/circular_buffer_tests.erl +33 -32
- data/tracks/erlang/exercises/clock/rebar.config +1 -1
- data/tracks/erlang/exercises/clock/test/clock_tests.erl +57 -50
- data/tracks/erlang/exercises/collatz-conjecture/rebar.config +1 -1
- data/tracks/erlang/exercises/collatz-conjecture/test/collatz_conjecture_tests.erl +11 -9
- data/tracks/erlang/exercises/complex-numbers/rebar.config +1 -1
- data/tracks/erlang/exercises/complex-numbers/test/complex_numbers_tests.erl +102 -76
- data/tracks/erlang/exercises/custom-set/rebar.config +1 -1
- data/tracks/erlang/exercises/custom-set/test/custom_set_tests.erl +100 -109
- data/tracks/erlang/exercises/difference-of-squares/rebar.config +1 -1
- data/tracks/erlang/exercises/difference-of-squares/test/difference_of_squares_tests.erl +8 -7
- data/tracks/erlang/exercises/etl/rebar.config +1 -1
- data/tracks/erlang/exercises/etl/test/etl_tests.erl +6 -5
- data/tracks/erlang/exercises/gigasecond/rebar.config +1 -1
- data/tracks/erlang/exercises/gigasecond/test/gigasecond_tests.erl +9 -8
- data/tracks/erlang/exercises/grade-school/rebar.config +1 -1
- data/tracks/erlang/exercises/grade-school/test/grade_school_tests.erl +27 -23
- data/tracks/erlang/exercises/grains/rebar.config +1 -1
- data/tracks/erlang/exercises/grains/test/grains_tests.erl +7 -6
- data/tracks/erlang/exercises/hamming/rebar.config +1 -1
- data/tracks/erlang/exercises/hamming/test/hamming_tests.erl +20 -23
- data/tracks/erlang/exercises/hello-world/rebar.config +1 -1
- data/tracks/erlang/exercises/hello-world/test/hello_world_tests.erl +6 -4
- data/tracks/erlang/exercises/isogram/rebar.config +1 -1
- data/tracks/erlang/exercises/isogram/test/isogram_tests.erl +14 -12
- data/tracks/erlang/exercises/largest-series-product/rebar.config +1 -1
- data/tracks/erlang/exercises/largest-series-product/test/largest_series_product_tests.erl +22 -21
- data/tracks/erlang/exercises/leap/rebar.config +1 -1
- data/tracks/erlang/exercises/leap/test/leap_tests.erl +8 -7
- data/tracks/erlang/exercises/luhn/rebar.config +1 -1
- data/tracks/erlang/exercises/luhn/test/luhn_tests.erl +18 -16
- data/tracks/erlang/exercises/meetup/rebar.config +1 -1
- data/tracks/erlang/exercises/meetup/test/meetup_tests.erl +96 -95
- data/tracks/erlang/exercises/nucleotide-count/rebar.config +1 -1
- data/tracks/erlang/exercises/nucleotide-count/test/nucleotide_count_tests.erl +12 -11
- data/tracks/erlang/exercises/pangram/README.md +60 -0
- data/tracks/erlang/exercises/{accumulate → pangram}/include/exercism.hrl +0 -0
- data/tracks/erlang/exercises/{beer-song/rebar.conf → pangram/rebar.config} +0 -0
- data/tracks/erlang/exercises/pangram/src/example.erl +11 -0
- data/tracks/erlang/exercises/pangram/src/pangram.app.src +9 -0
- data/tracks/erlang/exercises/pangram/src/pangram.erl +8 -0
- data/tracks/erlang/exercises/pangram/test/pangram_tests.erl +38 -0
- data/tracks/erlang/exercises/parallel-letter-frequency/rebar.config +1 -1
- data/tracks/erlang/exercises/parallel-letter-frequency/test/parallel_letter_frequency_tests.erl +7 -6
- data/tracks/erlang/exercises/phone-number/rebar.config +1 -1
- data/tracks/erlang/exercises/phone-number/test/phone_number_tests.erl +13 -12
- data/tracks/erlang/exercises/rna-transcription/rebar.config +1 -1
- data/tracks/erlang/exercises/rna-transcription/test/rna_transcription_tests.erl +13 -11
- data/tracks/erlang/exercises/robot-simulator/rebar.config +1 -1
- data/tracks/erlang/exercises/robot-simulator/test/robot_simulator_tests.erl +70 -69
- data/tracks/erlang/exercises/roman-numerals/rebar.config +1 -1
- data/tracks/erlang/exercises/roman-numerals/test/roman_numerals_tests.erl +6 -5
- data/tracks/erlang/exercises/rotational-cipher/rebar.config +1 -8
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +29 -27
- data/tracks/erlang/exercises/scrabble-score/rebar.config +1 -1
- data/tracks/erlang/exercises/scrabble-score/test/scrabble_score_tests.erl +6 -5
- data/tracks/erlang/exercises/series/rebar.config +1 -1
- data/tracks/erlang/exercises/series/test/series_tests.erl +6 -5
- data/tracks/erlang/exercises/sieve/rebar.config +1 -1
- data/tracks/erlang/exercises/sieve/test/sieve_tests.erl +10 -8
- data/tracks/erlang/exercises/space-age/rebar.config +1 -1
- data/tracks/erlang/exercises/space-age/test/space_age_tests.erl +20 -19
- data/tracks/erlang/exercises/spiral-matrix/rebar.config +1 -1
- data/tracks/erlang/exercises/spiral-matrix/test/spiral_matrix_tests.erl +12 -10
- data/tracks/erlang/exercises/strain/rebar.config +1 -1
- data/tracks/erlang/exercises/strain/test/strain_tests.erl +17 -16
- data/tracks/erlang/exercises/sum-of-multiples/rebar.config +1 -1
- data/tracks/erlang/exercises/sum-of-multiples/test/sum_of_multiples_tests.erl +16 -15
- data/tracks/erlang/exercises/triangle/rebar.config +1 -1
- data/tracks/erlang/exercises/triangle/test/triangle_tests.erl +20 -19
- data/tracks/erlang/exercises/two-fer/rebar.config +1 -1
- data/tracks/erlang/exercises/two-fer/test/two_fer_tests.erl +8 -7
- data/tracks/erlang/exercises/word-count/rebar.config +1 -1
- data/tracks/erlang/exercises/word-count/test/word_count_tests.erl +6 -5
- data/tracks/erlang/exercises/zipper/rebar.config +1 -1
- data/tracks/erlang/exercises/zipper/test/zipper_tests.erl +47 -46
- data/tracks/erlang/testgen/src/tgen.erl +8 -6
- data/tracks/erlang/testgen/src/tgen_bob.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_collatz-conjecture.erl +2 -2
- data/tracks/erlang/testgen/src/tgen_complex-numbers.erl +11 -11
- data/tracks/erlang/testgen/src/tgen_custom-set.erl +14 -14
- data/tracks/erlang/testgen/src/tgen_hamming.erl +2 -2
- data/tracks/erlang/testgen/src/tgen_hello-world.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_leap.erl +1 -1
- data/tracks/erlang/testgen/src/tgen_rna-transcription.erl +2 -2
- data/tracks/erlang/testgen/src/tgs.erl +6 -0
- data/tracks/fsharp/exercises/beer-song/BeerSong.fs +1 -5
- data/tracks/fsharp/exercises/beer-song/BeerSongTest.fs +342 -20
- data/tracks/fsharp/exercises/beer-song/Example.fs +16 -10
- data/tracks/fsharp/exercises/food-chain/Example.fs +1 -1
- data/tracks/fsharp/exercises/food-chain/FoodChain.fs +1 -3
- data/tracks/fsharp/exercises/food-chain/FoodChainTest.fs +11 -11
- data/tracks/fsharp/exercises/house/Example.fs +1 -1
- data/tracks/fsharp/exercises/house/House.fs +1 -3
- data/tracks/fsharp/exercises/house/HouseTest.fs +202 -202
- data/tracks/fsharp/exercises/proverb/Example.fs +9 -9
- data/tracks/fsharp/exercises/proverb/Proverb.fs +1 -3
- data/tracks/fsharp/exercises/proverb/ProverbTest.fs +50 -21
- data/tracks/fsharp/exercises/twelve-days/Example.fs +4 -4
- data/tracks/fsharp/exercises/twelve-days/TwelveDays.fs +2 -6
- data/tracks/fsharp/exercises/twelve-days/TwelveDaysTest.fs +81 -57
- data/tracks/fsharp/generators/Generators.fs +39 -15
- data/tracks/go/bin/run-generators +5 -1
- data/tracks/go/config.json +14 -2
- data/tracks/go/exercises/accumulate/example.go +2 -1
- data/tracks/go/exercises/zebra-puzzle/.meta/hints.md +24 -0
- data/tracks/go/exercises/zebra-puzzle/README.md +76 -0
- data/tracks/go/exercises/zebra-puzzle/example.go +256 -0
- data/tracks/go/exercises/zebra-puzzle/zebra_puzzle_test.go +18 -0
- data/tracks/haskell/exercises/forth/package.yaml +1 -1
- data/tracks/haskell/exercises/forth/test/Tests.hs +1 -4
- data/tracks/haskell/exercises/pascals-triangle/package.yaml +1 -1
- data/tracks/haskell/exercises/pascals-triangle/test/Tests.hs +22 -1
- data/tracks/java/POLICIES.md +3 -3
- data/tracks/java/config.json +21 -2
- data/tracks/java/exercises/atbash-cipher/.meta/src/reference/java/Atbash.java +12 -12
- data/tracks/java/exercises/protein-translation/.meta/src/reference/java/ProteinTranslator.java +47 -0
- data/tracks/java/exercises/protein-translation/.meta/version +1 -0
- data/tracks/java/exercises/protein-translation/README.md +58 -0
- data/tracks/java/exercises/protein-translation/build.gradle +18 -0
- data/tracks/java/exercises/protein-translation/src/main/java/ProteinTranslator.java +8 -0
- data/tracks/java/exercises/protein-translation/src/test/java/ProteinTranslatorTest.java +179 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/javascript/.eslintignore +2 -2
- data/tracks/javascript/exercises/accumulate/example.js +1 -2
- data/tracks/javascript/exercises/grains/example.js +6 -3
- data/tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt +3 -3
- data/tracks/kotlin/exercises/beer-song/.meta/version +1 -1
- data/tracks/kotlin/exercises/beer-song/README.md +1 -1
- data/tracks/kotlin/exercises/beer-song/src/test/kotlin/BeerSongTest.kt +6 -6
- data/tracks/kotlin/exercises/forth/.meta/version +1 -1
- data/tracks/kotlin/exercises/forth/src/test/kotlin/ForthEvaluatorTest.kt +0 -7
- data/tracks/kotlin/exercises/meetup/README.md +16 -12
- data/tracks/kotlin/exercises/nth-prime/.meta/src/reference/kotlin/Prime.kt +7 -2
- data/tracks/kotlin/exercises/nth-prime/.meta/version +1 -1
- data/tracks/kotlin/exercises/nth-prime/src/test/kotlin/PrimeTest.kt +10 -1
- data/tracks/kotlin/exercises/nucleotide-count/README.md +2 -2
- data/tracks/kotlin/exercises/pascals-triangle/.meta/src/reference/kotlin/PascalsTriangle.kt +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/.meta/version +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/src/test/kotlin/PascalsTriangleTest.kt +58 -1
- data/tracks/kotlin/exercises/sum-of-multiples/README.md +3 -3
- data/tracks/ocaml/exercises/forth/test.ml +1 -3
- data/tracks/ocaml/exercises/rectangles/example.ml +11 -11
- data/tracks/php/exercises/bob/example.php +2 -2
- data/tracks/purescript/config.json +3 -3
- data/tracks/python/config.json +34 -22
- data/tracks/python/exercises/alphametics/example.py +90 -34
- data/tracks/python/exercises/ocr-numbers/example.py +18 -21
- data/tracks/python/exercises/ocr-numbers/ocr_numbers.py +1 -5
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +124 -106
- data/tracks/python/exercises/simple-linked-list/README.md +49 -0
- data/tracks/python/exercises/simple-linked-list/example.py +67 -0
- data/tracks/python/exercises/simple-linked-list/hints.md +10 -0
- data/tracks/python/exercises/simple-linked-list/simple_linked_list.py +33 -0
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +112 -0
- data/tracks/rust/README.md +2 -0
- data/tracks/rust/bin/init_exercise.py +586 -0
- data/tracks/rust/config.json +20 -10
- data/tracks/rust/exercises/book-store/.gitignore +3 -0
- data/tracks/rust/exercises/book-store/Cargo-example.toml +7 -0
- data/tracks/rust/exercises/book-store/Cargo.toml +6 -0
- data/tracks/rust/exercises/book-store/README.md +107 -0
- data/tracks/rust/exercises/book-store/example.rs +187 -0
- data/tracks/rust/exercises/book-store/src/lib.rs +3 -0
- data/tracks/rust/exercises/book-store/tests/book-store.rs +130 -0
- data/tracks/sml/config.json +8 -8
- data/tracks/typescript/config.json +6 -6
- metadata +43 -46
- data/tracks/erlang/exercises/all-your-base/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/allergies/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/anagram/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/atbash-cipher/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/bank-account/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/beer-song/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/bob/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/circular-buffer/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/clock/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/collatz-conjecture/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/complex-numbers/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/custom-set/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/difference-of-squares/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/etl/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/gigasecond/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/grade-school/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/grains/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/hamming/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/hello-world/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/isogram/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/largest-series-product/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/leap/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/luhn/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/meetup/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/nucleotide-count/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/parallel-letter-frequency/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/phone-number/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/rna-transcription/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/robot-simulator/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/roman-numerals/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/rotational-cipher/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/scrabble-score/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/series/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/sieve/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/space-age/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/spiral-matrix/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/strain/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/sum-of-multiples/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/triangle/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/two-fer/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/word-count/include/exercism.hrl +0 -11
- data/tracks/erlang/exercises/zipper/include/exercism.hrl +0 -11
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import org.junit.Before;
|
|
2
|
+
import org.junit.Ignore;
|
|
3
|
+
import org.junit.Test;
|
|
4
|
+
|
|
5
|
+
import java.util.Arrays;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
|
|
8
|
+
import static org.junit.Assert.assertEquals;
|
|
9
|
+
|
|
10
|
+
public class ProteinTranslatorTest {
|
|
11
|
+
|
|
12
|
+
private ProteinTranslator proteinTranslator;
|
|
13
|
+
|
|
14
|
+
@Before
|
|
15
|
+
public void setUp() {
|
|
16
|
+
proteinTranslator = new ProteinTranslator();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Test
|
|
20
|
+
public void testMethionineRnaSequence() {
|
|
21
|
+
List<String> expected = Arrays.asList("Methionine");
|
|
22
|
+
assertEquals(expected, proteinTranslator.translate("AUG"));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Ignore("Remove to run test")
|
|
26
|
+
@Test
|
|
27
|
+
public void testPhenylalanineRnaSequence1() {
|
|
28
|
+
List<String> expected = Arrays.asList("Phenylalanine");
|
|
29
|
+
assertEquals(expected, proteinTranslator.translate("UUU"));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Ignore("Remove to run test")
|
|
33
|
+
@Test
|
|
34
|
+
public void testPhenylalanineRnaSequence2() {
|
|
35
|
+
List<String> expected = Arrays.asList("Phenylalanine");
|
|
36
|
+
assertEquals(expected, proteinTranslator.translate("UUC"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Ignore("Remove to run test")
|
|
40
|
+
@Test
|
|
41
|
+
public void testLeucineRnaSequence1() {
|
|
42
|
+
List<String> expected = Arrays.asList("Leucine");
|
|
43
|
+
assertEquals(expected, proteinTranslator.translate("UUA"));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Ignore("Remove to run test")
|
|
47
|
+
@Test
|
|
48
|
+
public void testLeucineRnaSequence2() {
|
|
49
|
+
List<String> expected = Arrays.asList("Leucine");
|
|
50
|
+
assertEquals(expected, proteinTranslator.translate("UUG"));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Ignore("Remove to run test")
|
|
54
|
+
@Test
|
|
55
|
+
public void testSerineRnaSequence1() {
|
|
56
|
+
List<String> expected = Arrays.asList("Serine");
|
|
57
|
+
assertEquals(expected, proteinTranslator.translate("UCU"));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Ignore("Remove to run test")
|
|
61
|
+
@Test
|
|
62
|
+
public void testSerineRnaSequence2() {
|
|
63
|
+
List<String> expected = Arrays.asList("Serine");
|
|
64
|
+
assertEquals(expected, proteinTranslator.translate("UCC"));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Ignore("Remove to run test")
|
|
68
|
+
@Test
|
|
69
|
+
public void testSerineRnaSequence3() {
|
|
70
|
+
List<String> expected = Arrays.asList("Serine");
|
|
71
|
+
assertEquals(expected, proteinTranslator.translate("UCA"));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Ignore("Remove to run test")
|
|
75
|
+
@Test
|
|
76
|
+
public void testSerineRnaSequence4() {
|
|
77
|
+
List<String> expected = Arrays.asList("Serine");
|
|
78
|
+
assertEquals(expected, proteinTranslator.translate("UCG"));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Ignore("Remove to run test")
|
|
82
|
+
@Test
|
|
83
|
+
public void testTyrosineRnaSequence1() {
|
|
84
|
+
List<String> expected = Arrays.asList("Tyrosine");
|
|
85
|
+
assertEquals(expected, proteinTranslator.translate("UAU"));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Ignore("Remove to run test")
|
|
89
|
+
@Test
|
|
90
|
+
public void testTyrosineRnaSequence2() {
|
|
91
|
+
List<String> expected = Arrays.asList("Tyrosine");
|
|
92
|
+
assertEquals(expected, proteinTranslator.translate("UAC"));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Ignore("Remove to run test")
|
|
96
|
+
@Test
|
|
97
|
+
public void testCysteineRnaSequence1() {
|
|
98
|
+
List<String> expected = Arrays.asList("Cysteine");
|
|
99
|
+
assertEquals(expected, proteinTranslator.translate("UGU"));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Ignore("Remove to run test")
|
|
103
|
+
@Test
|
|
104
|
+
public void testCysteineRnaSequence2() {
|
|
105
|
+
List<String> expected = Arrays.asList("Cysteine");
|
|
106
|
+
assertEquals(expected, proteinTranslator.translate("UGC"));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Ignore("Remove to run test")
|
|
110
|
+
@Test
|
|
111
|
+
public void testTryptophanRnaSequence1() {
|
|
112
|
+
List<String> expected = Arrays.asList("Tryptophan");
|
|
113
|
+
assertEquals(expected, proteinTranslator.translate("UGG"));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Ignore("Remove to run test")
|
|
117
|
+
@Test
|
|
118
|
+
public void testStopRnaSequence1() {
|
|
119
|
+
List<String> expected = Arrays.asList();
|
|
120
|
+
assertEquals(expected, proteinTranslator.translate("UAA"));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Ignore("Remove to run test")
|
|
124
|
+
@Test
|
|
125
|
+
public void testStopRnaSequence2() {
|
|
126
|
+
List<String> expected = Arrays.asList();
|
|
127
|
+
assertEquals(expected, proteinTranslator.translate("UAG"));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Ignore("Remove to run test")
|
|
131
|
+
@Test
|
|
132
|
+
public void testStopRnaSequence3() {
|
|
133
|
+
List<String> expected = Arrays.asList();
|
|
134
|
+
assertEquals(expected, proteinTranslator.translate("UGA"));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@Ignore("Remove to run test")
|
|
138
|
+
@Test
|
|
139
|
+
public void testTranslationOfRnaToProteinList() {
|
|
140
|
+
List<String> expected = Arrays.asList("Methionine","Phenylalanine","Tryptophan");
|
|
141
|
+
assertEquals(expected, proteinTranslator.translate("AUGUUUUGG"));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@Ignore("Remove to run test")
|
|
145
|
+
@Test
|
|
146
|
+
public void testTranslationStopsIfStopCodonAtBeginning() {
|
|
147
|
+
List<String> expected = Arrays.asList();
|
|
148
|
+
assertEquals(expected, proteinTranslator.translate("UAGUGG"));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Ignore("Remove to run test")
|
|
152
|
+
@Test
|
|
153
|
+
public void testTranslationStopsIfStopCodonAtEnd1() {
|
|
154
|
+
List<String> expected = Arrays.asList("Tryptophan");
|
|
155
|
+
assertEquals(expected, proteinTranslator.translate("UGGUAG"));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@Ignore("Remove to run test")
|
|
159
|
+
@Test
|
|
160
|
+
public void testTranslationStopsIfStopCodonAtEnd2() {
|
|
161
|
+
List<String> expected = Arrays.asList("Methionine", "Phenylalanine");
|
|
162
|
+
assertEquals(expected, proteinTranslator.translate("AUGUUUUAA"));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@Ignore("Remove to run test")
|
|
166
|
+
@Test
|
|
167
|
+
public void testTranslationStopsIfStopCodonInMiddle1() {
|
|
168
|
+
List<String> expected = Arrays.asList("Tryptophan");
|
|
169
|
+
assertEquals(expected, proteinTranslator.translate("UGGUAGUGG"));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@Ignore("Remove to run test")
|
|
173
|
+
@Test
|
|
174
|
+
public void testTranslationStopsIfStopCodonInMiddle2() {
|
|
175
|
+
List<String> expected = Arrays.asList("Tryptophan","Cysteine","Tyrosine");
|
|
176
|
+
assertEquals(expected, proteinTranslator.translate("UGGUGUUAUUAAUGGUUU"));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
big-integer.js
|
|
2
|
-
exercises/accumulate
|
|
3
2
|
exercises/alphametics
|
|
4
3
|
exercises/anagram
|
|
5
4
|
exercises/binary-search
|
|
@@ -12,7 +11,8 @@ exercises/custom-set
|
|
|
12
11
|
exercises/flatten-array
|
|
13
12
|
exercises/food-chain
|
|
14
13
|
exercises/grade-school
|
|
15
|
-
exercises/grains
|
|
14
|
+
exercises/grains/big-integer.js
|
|
15
|
+
exercises/grains/big-integer.spec.js
|
|
16
16
|
exercises/kindergarten-garden
|
|
17
17
|
exercises/leap
|
|
18
18
|
exercises/linked-list
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
module.exports = function (list, accumulator) {
|
|
2
2
|
var out = [];
|
|
3
3
|
var idx = -1;
|
|
4
4
|
var end = Array.isArray(list) ? list.length : 0;
|
|
@@ -9,4 +9,3 @@ var accumulate = module.exports = function (list, accumulator) {
|
|
|
9
9
|
|
|
10
10
|
return out;
|
|
11
11
|
};
|
|
12
|
-
|
|
@@ -4,7 +4,7 @@ var BigInt = require('./big-integer');
|
|
|
4
4
|
* @author github.com/nonsensery
|
|
5
5
|
* @class Grains
|
|
6
6
|
*
|
|
7
|
-
* Computes the number of grains on the squares of a
|
|
7
|
+
* @classdesc Computes the number of grains on the squares of a
|
|
8
8
|
* chess board, starting with one grain on the first
|
|
9
9
|
* square, and doubling with each successive square.
|
|
10
10
|
*/
|
|
@@ -14,16 +14,19 @@ function Grains() {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Gets the number of grains on the nth square.
|
|
17
|
+
* @param {number} num - the value to square
|
|
18
|
+
* @return {number} the square of num
|
|
17
19
|
*/
|
|
18
20
|
Grains.prototype.square = function (num) {
|
|
19
|
-
return BigInt(2).pow(num - 1).toString();
|
|
21
|
+
return new BigInt(2).pow(num - 1).toString();
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Gets the total number of grains on all squares.
|
|
26
|
+
* @return {string} the total
|
|
24
27
|
*/
|
|
25
28
|
Grains.prototype.total = function () {
|
|
26
|
-
var total = BigInt(0);
|
|
29
|
+
var total = new BigInt(0);
|
|
27
30
|
|
|
28
31
|
for (var squareNum = 1; squareNum <= 64; ++squareNum) {
|
|
29
32
|
total = total.add(this.square(squareNum));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
object BeerSong {
|
|
2
|
-
val lyrics: String by lazy { verses(99, 0) }
|
|
3
2
|
|
|
4
|
-
fun
|
|
3
|
+
fun verses(startBottles: Int, takeDown: Int) = (startBottles downTo takeDown).joinToString("\n") { verse(it) }
|
|
4
|
+
|
|
5
|
+
private fun verse(number: Int) = when (number) {
|
|
5
6
|
0 -> "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
|
|
6
7
|
1 -> "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"
|
|
7
8
|
2 -> "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"
|
|
@@ -9,5 +10,4 @@ object BeerSong {
|
|
|
9
10
|
else -> throw IllegalArgumentException("Invalid verse number: $number, must be within 0 and 99")
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
fun verses(upperBound: Int, lowerBound: Int) = (upperBound downTo lowerBound).map { verse(it) }.joinToString("\n")
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2.0.0
|
|
@@ -7,35 +7,35 @@ class BeerSongTest {
|
|
|
7
7
|
@Test
|
|
8
8
|
fun firstGenericVerse() {
|
|
9
9
|
val expected = "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n"
|
|
10
|
-
assertEquals(expected, BeerSong.
|
|
10
|
+
assertEquals(expected, BeerSong.verses(99, 99))
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@Ignore
|
|
14
14
|
@Test
|
|
15
15
|
fun lastGenericVerse() {
|
|
16
16
|
val expected = "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n"
|
|
17
|
-
assertEquals(expected, BeerSong.
|
|
17
|
+
assertEquals(expected, BeerSong.verses(3, 3))
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
@Ignore
|
|
21
21
|
@Test
|
|
22
22
|
fun verse2() {
|
|
23
23
|
val expected = "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"
|
|
24
|
-
assertEquals(expected, BeerSong.
|
|
24
|
+
assertEquals(expected, BeerSong.verses(2, 2))
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
@Ignore
|
|
28
28
|
@Test
|
|
29
29
|
fun verse1() {
|
|
30
30
|
val expected = "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"
|
|
31
|
-
assertEquals(expected, BeerSong.
|
|
31
|
+
assertEquals(expected, BeerSong.verses(1, 1))
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
@Ignore
|
|
35
35
|
@Test
|
|
36
36
|
fun verse0() {
|
|
37
37
|
val expected = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
|
|
38
|
-
assertEquals(expected, BeerSong.
|
|
38
|
+
assertEquals(expected, BeerSong.verses(0, 0))
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
@Ignore
|
|
@@ -356,7 +356,7 @@ Take it down and pass it around, no more bottles of beer on the wall.
|
|
|
356
356
|
No more bottles of beer on the wall, no more bottles of beer.
|
|
357
357
|
Go to the store and buy some more, 99 bottles of beer on the wall.
|
|
358
358
|
"""
|
|
359
|
-
assertEquals(expected, BeerSong.
|
|
359
|
+
assertEquals(expected, BeerSong.verses(99, 0))
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.3.0
|
|
@@ -18,13 +18,6 @@ class ForthEvaluatorTest {
|
|
|
18
18
|
forthEvaluator = ForthEvaluator()
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
@Test
|
|
22
|
-
fun testEmptyProgramResultsInEmptyStack() {
|
|
23
|
-
assertEquals(
|
|
24
|
-
emptyList(),
|
|
25
|
-
forthEvaluator.evaluateProgram(emptyList()))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
@Ignore
|
|
29
22
|
@Test
|
|
30
23
|
fun testNumbersAreJustPushedOntoTheStack() {
|
|
@@ -2,25 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Calculate the date of meetups.
|
|
4
4
|
|
|
5
|
-
Typically meetups happen on the same day of the week. In this exercise, you
|
|
6
|
-
a description of a meetup date, and return the actual meetup date.
|
|
5
|
+
Typically meetups happen on the same day of the week. In this exercise, you
|
|
6
|
+
will take a description of a meetup date, and return the actual meetup date.
|
|
7
7
|
|
|
8
8
|
Examples of general descriptions are:
|
|
9
9
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
10
|
+
- The first Monday of January 2017
|
|
11
|
+
- The third Tuesday of January 2017
|
|
12
|
+
- The wednesteenth of January 2017
|
|
13
|
+
- The last Thursday of January 2017
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
The descriptors you are expected to parse are:
|
|
16
|
+
first, second, third, fourth, fifth, last, monteenth, tuesteenth, wednesteenth,
|
|
17
|
+
thursteenth, friteenth, saturteenth, sunteenth
|
|
18
|
+
|
|
19
|
+
Note that "monteenth", "tuesteenth", etc are all made up words. There was a
|
|
20
|
+
meetup whose members realized that there are exactly 7 numbered days in a month
|
|
21
|
+
that end in '-teenth'. Therefore, one is guaranteed that each day of the week
|
|
18
22
|
(Monday, Tuesday, ...) will have exactly one date that is named with '-teenth'
|
|
19
23
|
in every month.
|
|
20
24
|
|
|
21
|
-
Given examples of a meetup dates, each containing a month, day, year, and
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
Given examples of a meetup dates, each containing a month, day, year, and
|
|
26
|
+
descriptor calculate the date of the actual meetup. For example, if given
|
|
27
|
+
"The first Monday of January 2017", the correct meetup date is 2017/1/2.
|
|
24
28
|
|
|
25
29
|
|
|
26
30
|
|
|
@@ -2,9 +2,14 @@ import java.math.BigInteger
|
|
|
2
2
|
|
|
3
3
|
object Prime {
|
|
4
4
|
|
|
5
|
-
fun nth(n: Int): Int
|
|
5
|
+
fun nth(n: Int): Int {
|
|
6
|
+
require(n > 0) { "There is no zeroth prime." }
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
return primes().drop(n - 1).first().toInt()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private fun primes(): Sequence<BigInteger> = generateSequence(BigInteger.valueOf(2)) { previous ->
|
|
8
12
|
previous.nextProbablePrime()
|
|
9
13
|
}
|
|
14
|
+
|
|
10
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2.0.0
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import org.junit.Test
|
|
2
2
|
import org.junit.Ignore
|
|
3
|
+
import org.junit.Rule
|
|
4
|
+
import org.junit.rules.ExpectedException
|
|
3
5
|
import kotlin.test.assertEquals
|
|
4
6
|
|
|
5
7
|
class PrimeTest {
|
|
6
8
|
|
|
9
|
+
@Rule
|
|
10
|
+
@JvmField
|
|
11
|
+
var expectedException: ExpectedException = ExpectedException.none()
|
|
12
|
+
|
|
7
13
|
@Test
|
|
8
14
|
fun firstPrime() {
|
|
9
15
|
assertEquals(2, Prime.nth(1))
|
|
@@ -28,8 +34,11 @@ class PrimeTest {
|
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
@Ignore
|
|
31
|
-
@Test
|
|
37
|
+
@Test
|
|
32
38
|
fun undefinedPrime() {
|
|
39
|
+
expectedException.expect(IllegalArgumentException::class.java)
|
|
40
|
+
expectedException.expectMessage("There is no zeroth prime.")
|
|
41
|
+
|
|
33
42
|
Prime.nth(0)
|
|
34
43
|
}
|
|
35
44
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Given a single stranded DNA string, compute how many times each nucleotide occurs in the string.
|
|
4
4
|
|
|
5
|
-
The genetic language of every living thing on the planet is DNA.
|
|
6
|
-
DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
|
|
5
|
+
The genetic language of every living thing on the planet is DNA.
|
|
6
|
+
DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
|
|
7
7
|
4 types exist in DNA and these differ only slightly and can be represented as the following symbols: 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' thymine.
|
|
8
8
|
|
|
9
9
|
Here is an analogy:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.2.0
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import org.junit.Test
|
|
2
2
|
import org.junit.Ignore
|
|
3
|
+
import org.junit.Rule
|
|
4
|
+
import org.junit.rules.ExpectedException
|
|
3
5
|
import kotlin.test.assertEquals
|
|
4
6
|
|
|
5
7
|
class PascalsTriangleTest {
|
|
6
8
|
|
|
9
|
+
@Rule
|
|
10
|
+
@JvmField
|
|
11
|
+
var expectedException: ExpectedException = ExpectedException.none()
|
|
12
|
+
|
|
7
13
|
@Test
|
|
8
14
|
fun zeroRows() {
|
|
9
15
|
val expectedOutput = emptyList<List<Int>>()
|
|
@@ -58,8 +64,59 @@ class PascalsTriangleTest {
|
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
@Ignore
|
|
61
|
-
@Test
|
|
67
|
+
@Test
|
|
68
|
+
fun fiveRows() {
|
|
69
|
+
val expectedOutput = listOf(
|
|
70
|
+
listOf(1),
|
|
71
|
+
listOf(1, 1),
|
|
72
|
+
listOf(1, 2, 1),
|
|
73
|
+
listOf(1, 3, 3, 1),
|
|
74
|
+
listOf(1, 4, 6, 4, 1)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(5))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Ignore
|
|
81
|
+
@Test
|
|
82
|
+
fun sixRows() {
|
|
83
|
+
val expectedOutput = listOf(
|
|
84
|
+
listOf(1),
|
|
85
|
+
listOf(1, 1),
|
|
86
|
+
listOf(1, 2, 1),
|
|
87
|
+
listOf(1, 3, 3, 1),
|
|
88
|
+
listOf(1, 4, 6, 4, 1),
|
|
89
|
+
listOf(1, 5, 10, 10, 5, 1)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(6))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Ignore
|
|
96
|
+
@Test
|
|
97
|
+
fun tenRows() {
|
|
98
|
+
val expectedOutput = listOf(
|
|
99
|
+
listOf(1),
|
|
100
|
+
listOf(1, 1),
|
|
101
|
+
listOf(1, 2, 1),
|
|
102
|
+
listOf(1, 3, 3, 1),
|
|
103
|
+
listOf(1, 4, 6, 4, 1),
|
|
104
|
+
listOf(1, 5, 10, 10, 5, 1),
|
|
105
|
+
listOf(1, 6, 15, 20, 15, 6, 1),
|
|
106
|
+
listOf(1, 7, 21, 35, 35, 21, 7, 1),
|
|
107
|
+
listOf(1, 8, 28, 56, 70, 56, 28, 8, 1),
|
|
108
|
+
listOf(1, 9, 36, 84, 126, 126, 84, 36, 9, 1)
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(10))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@Ignore
|
|
115
|
+
@Test
|
|
62
116
|
fun validatesNotNegativeRows() {
|
|
117
|
+
expectedException.expect(IllegalArgumentException::class.java)
|
|
118
|
+
expectedException.expectMessage("Rows can't be negative!")
|
|
119
|
+
|
|
63
120
|
PascalsTriangle.computeTriangle(-1)
|
|
64
121
|
}
|
|
65
122
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Sum Of Multiples
|
|
2
2
|
|
|
3
|
-
Given a number, find the sum of all the multiples of particular numbers up to
|
|
3
|
+
Given a number, find the sum of all the unique multiples of particular numbers up to
|
|
4
4
|
but not including that number.
|
|
5
5
|
|
|
6
|
-
If we list all the natural numbers
|
|
7
|
-
|
|
6
|
+
If we list all the natural numbers below 20 that are multiples of 3 or 5,
|
|
7
|
+
we get 3, 5, 6, 9, 10, 12, 15, and 18.
|
|
8
8
|
|
|
9
9
|
The sum of these multiples is 78.
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(* Test/exercise version: "1.
|
|
1
|
+
(* Test/exercise version: "1.3.0" *)
|
|
2
2
|
|
|
3
3
|
open Core
|
|
4
4
|
open OUnit2
|
|
@@ -10,8 +10,6 @@ let print_int_list_option (xs: int list option) = match xs with
|
|
|
10
10
|
let ae exp got _test_ctxt = assert_equal ~printer:print_int_list_option exp got
|
|
11
11
|
|
|
12
12
|
let parsing_and_numbers_tests = [
|
|
13
|
-
"empty input results in empty stack" >::
|
|
14
|
-
ae (Some []) (evaluate []);
|
|
15
13
|
"numbers just get pushed onto the stack" >::
|
|
16
14
|
ae (Some [1; 2; 3; 4; 5]) (evaluate ["1 2 3 4 5"]);
|
|
17
15
|
]
|
|
@@ -3,28 +3,28 @@ type position = Start | UpperSide | RightSide | LowerSide | LeftSide
|
|
|
3
3
|
let count_rectangles pic =
|
|
4
4
|
let maxY = Array.length pic in
|
|
5
5
|
let maxX = if maxY > 0 then String.length pic.(0) else 0 in
|
|
6
|
-
let rec go
|
|
6
|
+
let rec go x y xStart yStart pos =
|
|
7
7
|
let on_side_fn dx dy next_pos () =
|
|
8
|
-
go
|
|
8
|
+
go (x+dx) (y+dy) xStart yStart next_pos in
|
|
9
9
|
let on_corner_fn dx1 dy1 dx2 dy2 next_pos () =
|
|
10
|
-
go
|
|
10
|
+
go (x+dx1) (y+dy1) xStart yStart next_pos + go (x+dx2) (y+dy2) xStart yStart pos in
|
|
11
11
|
let progress side_ch on_side on_corner =
|
|
12
12
|
try
|
|
13
13
|
match pic.(y).[x] with
|
|
14
14
|
| c when c = side_ch -> on_side ()
|
|
15
15
|
| '+' -> on_corner ()
|
|
16
|
-
| _ ->
|
|
17
|
-
with Invalid_argument _ ->
|
|
16
|
+
| _ -> 0
|
|
17
|
+
with Invalid_argument _ -> 0 in
|
|
18
18
|
match pos with
|
|
19
19
|
| Start ->
|
|
20
|
-
if y = maxY then
|
|
21
|
-
else if x = maxX then go
|
|
20
|
+
if y = maxY then 0
|
|
21
|
+
else if x = maxX then go 0 (y+1) 0 (y+1) Start
|
|
22
22
|
else (match pic.(y).[x] with
|
|
23
|
-
| '+' -> go
|
|
24
|
-
| _ -> go
|
|
23
|
+
| '+' -> go (x+1) y x y UpperSide + go (x+1) y x y Start
|
|
24
|
+
| _ -> go (x+1) y (x+1) y Start
|
|
25
25
|
)
|
|
26
26
|
| UpperSide -> progress '-' (on_side_fn 1 0 UpperSide) (on_corner_fn 0 1 1 0 RightSide)
|
|
27
27
|
| RightSide -> progress '|' (on_side_fn 0 1 RightSide) (on_corner_fn (-1) 0 0 1 LowerSide)
|
|
28
28
|
| LowerSide -> progress '-' (on_side_fn (-1) 0 LowerSide) (on_corner_fn 0 (-1) (-1) 0 LeftSide)
|
|
29
|
-
| LeftSide -> progress '|' (on_side_fn 0 (-1) LeftSide) (fun () -> if x = xStart && y = yStart then
|
|
30
|
-
in go 0 0 0 0
|
|
29
|
+
| LeftSide -> progress '|' (on_side_fn 0 (-1) LeftSide) (fun () -> if x = xStart && y = yStart then 1 else go x (y-1) xStart yStart LeftSide)
|
|
30
|
+
in go 0 0 0 0 Start
|
|
@@ -12,7 +12,7 @@ class Bob
|
|
|
12
12
|
{
|
|
13
13
|
$str = $this->prepareText($str);
|
|
14
14
|
|
|
15
|
-
if (
|
|
15
|
+
if ($this->isSilence($str)) {
|
|
16
16
|
return "Fine. Be that way!";
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -85,7 +85,7 @@ class Bob
|
|
|
85
85
|
*/
|
|
86
86
|
private function isSilence($str)
|
|
87
87
|
{
|
|
88
|
-
return
|
|
88
|
+
return empty($str);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
]
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
|
-
"uuid": "
|
|
255
|
+
"uuid": "b2d299f3-c382-4271-bd9e-f9d5615e5403",
|
|
256
256
|
"slug": "collatz-conjecture",
|
|
257
257
|
"core": false,
|
|
258
258
|
"unlocked_by": null,
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
]
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
|
-
"uuid": "
|
|
266
|
+
"uuid": "a686d00c-4dd4-4208-88c9-d17b00d97b28",
|
|
267
267
|
"slug": "sum-of-multiples",
|
|
268
268
|
"core": false,
|
|
269
269
|
"unlocked_by": null,
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
]
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
|
-
"uuid": "
|
|
278
|
+
"uuid": "b7648fa5-1aff-477c-973c-079245060d73",
|
|
279
279
|
"slug": "rna-transcription",
|
|
280
280
|
"core": false,
|
|
281
281
|
"unlocked_by": null,
|