trackler 2.0.1.0 → 2.0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/isogram/canonical-data.json +42 -31
- data/common/exercises/leap/canonical-data.json +7 -7
- data/common/exercises/matrix/description.md +3 -3
- data/common/exercises/minesweeper/canonical-data.json +54 -2
- data/common/exercises/pangram/canonical-data.json +5 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/acronym/project.clj +4 -0
- data/tracks/clojure/exercises/acronym/src/example.clj +8 -0
- data/tracks/clojure/exercises/acronym/test/acronym_test.clj +12 -0
- data/tracks/crystal/config.json +6 -0
- data/tracks/crystal/exercises/binary/spec/binary_spec.cr +76 -0
- data/tracks/crystal/exercises/binary/src/example.cr +18 -0
- data/tracks/crystal/src/generator/exercises/binary.cr +42 -0
- data/tracks/csharp/docs/TESTS.md +6 -2
- data/tracks/go/config.json +5 -0
- data/tracks/go/exercises/perfect-numbers/example.go +41 -0
- data/tracks/go/exercises/perfect-numbers/perfect_numbers_test.go +41 -0
- data/tracks/groovy/.gitignore +1 -0
- data/tracks/groovy/SETUP.md +6 -54
- data/tracks/groovy/exercises/difference-of-squares/Example.groovy +17 -15
- data/tracks/groovy/exercises/difference-of-squares/SquaresSpec.groovy +42 -0
- data/tracks/groovy/exercises/gigasecond/Example.groovy +9 -7
- data/tracks/groovy/exercises/gigasecond/Gigasecond.groovy +5 -2
- data/tracks/groovy/exercises/gigasecond/GigasecondSpec.groovy +38 -0
- data/tracks/groovy/exercises/hamming/Example.groovy +7 -5
- data/tracks/groovy/exercises/hamming/HammingSpec.groovy +50 -0
- data/tracks/groovy/exercises/hello-world/Example.groovy +5 -3
- data/tracks/groovy/exercises/hello-world/HelloWorld.groovy +5 -3
- data/tracks/groovy/exercises/hello-world/HelloWorldSpec.groovy +23 -0
- data/tracks/groovy/exercises/raindrops/Example.groovy +8 -8
- data/tracks/groovy/exercises/raindrops/RaindropsSpec.groovy +98 -0
- data/tracks/groovy/exercises/rna-transcription/ComplementSpec.groovy +51 -0
- data/tracks/groovy/exercises/rna-transcription/Example.groovy +19 -14
- data/tracks/haskell/.travis.yml +1 -1
- data/tracks/haskell/common/stack.yaml +1 -0
- data/tracks/haskell/config.json +1 -0
- data/tracks/haskell/exercises/pov/stack.yaml +1 -0
- data/tracks/haskell/exercises/robot-name/examples/success-standard/src/Robot.hs +1 -1
- data/tracks/java/bin/journey-test.sh +9 -4
- data/tracks/objective-c/Dangerfile +0 -2
- data/tracks/ocaml/exercises/hello-world/test.ml +6 -9
- data/tracks/ocaml/tools/test-generator/.merlin +1 -0
- data/tracks/ocaml/tools/test-generator/Makefile +4 -4
- data/tracks/ocaml/tools/test-generator/{src → interfaces}/codegen.mli +5 -1
- data/tracks/ocaml/tools/test-generator/{src → interfaces}/parser.mli +0 -0
- data/tracks/ocaml/tools/test-generator/interfaces/special_cases.mli +7 -0
- data/tracks/ocaml/tools/test-generator/interfaces/template.mli +11 -0
- data/tracks/ocaml/tools/test-generator/interfaces/test_generator.mli +3 -0
- data/tracks/ocaml/tools/test-generator/{src → interfaces}/utils.mli +0 -0
- data/tracks/ocaml/tools/test-generator/src/codegen.ml +6 -6
- data/tracks/ocaml/tools/test-generator/src/template.ml +24 -0
- data/tracks/ocaml/tools/test-generator/src/test_generator.ml +10 -26
- data/tracks/ocaml/tools/test-generator/test/all_tests.ml +2 -2
- data/tracks/ocaml/tools/test-generator/test/codegen_test.ml +1 -1
- data/tracks/ocaml/tools/test-generator/test/sample_template.txt +14 -0
- data/tracks/ocaml/tools/test-generator/test/template_test.ml +26 -0
- data/tracks/perl6/exercises/binary/binary.t +1 -1
- data/tracks/perl6/exercises/raindrops/Example.pm +2 -2
- data/tracks/perl6/exercises/raindrops/raindrops.t +19 -24
- data/tracks/php/.travis.yml +1 -0
- data/tracks/php/Makefile +26 -15
- data/tracks/php/README.md +19 -0
- data/tracks/ruby/README.md +10 -0
- data/tracks/rust/config.json +1 -0
- data/tracks/rust/exercises/alphametics/Cargo-example.toml +7 -0
- data/tracks/rust/exercises/alphametics/Cargo.lock +4 -0
- data/tracks/rust/exercises/alphametics/Cargo.toml +3 -0
- data/tracks/rust/exercises/alphametics/example.rs +76 -0
- data/tracks/rust/exercises/alphametics/src/lib.rs +5 -0
- data/tracks/rust/exercises/alphametics/tests/alphametics.rs +62 -0
- data/tracks/rust/problems.md +1 -0
- data/tracks/scala/exercises/dominoes/src/test/scala/DominoesSuite.scala +1 -1
- data/tracks/swift/Dangerfile +0 -2
- metadata +32 -39
- data/tracks/groovy/exercises/difference-of-squares/SquaresTest.groovy +0 -49
- data/tracks/groovy/exercises/gigasecond/GigasecondTest.groovy +0 -29
- data/tracks/groovy/exercises/hamming/HammingTest.groovy +0 -56
- data/tracks/groovy/exercises/hello-world/HelloWorldTest.groovy +0 -19
- data/tracks/groovy/exercises/raindrops/RaindropsTest.groovy +0 -21
- data/tracks/groovy/exercises/rna-transcription/ComplementTest.groovy +0 -55
- data/tracks/haskell/exercises/pov/stack.yaml +0 -1
- data/tracks/java/exercises/anagram/src/main/java/.keep +0 -0
- data/tracks/java/exercises/beer-song/src/example/java/.keep +0 -0
- data/tracks/java/exercises/beer-song/src/main/java/.keep +0 -0
- data/tracks/java/exercises/beer-song/src/test/java/.keep +0 -0
- data/tracks/java/exercises/difference-of-squares/src/example/java/.keep +0 -0
- data/tracks/java/exercises/difference-of-squares/src/main/java/.keep +0 -0
- data/tracks/java/exercises/etl/src/main/java/.keep +0 -0
- data/tracks/java/exercises/etl/src/test/java/.keep +0 -0
- data/tracks/java/exercises/grade-school/src/test/java/.keep +0 -0
- data/tracks/java/exercises/hamming/src/main/java/.keep +0 -0
- data/tracks/java/exercises/hello-world/src/main/java/.keep +0 -0
- data/tracks/java/exercises/hexadecimal/src/test/java/.keep +0 -0
- data/tracks/java/exercises/linked-list/src/example/java/.keep +0 -0
- data/tracks/java/exercises/linked-list/src/test/java/.keep +0 -0
- data/tracks/java/exercises/meetup/src/main/java/.keep +0 -0
- data/tracks/java/exercises/meetup/src/test/java/.keep +0 -0
- data/tracks/java/exercises/nth-prime/src/example/java/.keep +0 -0
- data/tracks/java/exercises/nth-prime/src/test/java/.keep +0 -0
- data/tracks/java/exercises/nucleotide-count/src/main/java/.keep +0 -0
- data/tracks/java/exercises/nucleotide-count/src/test/java/.keep +0 -0
- data/tracks/java/exercises/pangram/src/test/java/.keep +0 -0
- data/tracks/java/exercises/pascals-triangle/src/test/java/.keep +0 -0
- data/tracks/java/exercises/series/src/main/java/.keep +0 -0
- data/tracks/java/exercises/series/src/test/java/.keep +0 -0
- data/tracks/java/exercises/triangle/src/main/java/.keep +0 -0
- data/tracks/ocaml/tools/test-generator/src/special_cases.mli +0 -13
- data/tracks/ocaml/tools/test-generator/src/test_generator.mli +0 -6
- data/tracks/ocaml/tools/test-generator/test/test_generator_test.ml +0 -11
data/tracks/groovy/SETUP.md
CHANGED
@@ -1,60 +1,12 @@
|
|
1
|
-
|
1
|
+
For installation and learning resources, refer to the
|
2
|
+
[exercism help page](http://exercism.io/languages/groovy).
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
In a Command Prompt or Terminal, fetch the first exercise.
|
4
|
+
Run the tests by executing the test script.
|
6
5
|
|
7
6
|
```
|
8
|
-
|
9
|
-
|
10
|
-
Not Submitted: 1 problem
|
11
|
-
groovy (Hello World) Path\To\Your\Exercism\groovy\hello-world
|
12
|
-
|
13
|
-
New: 1 problem
|
14
|
-
groovy (Hello World) Path\To\Your\Exercism\groovy\hello-world
|
15
|
-
|
16
|
-
unchanged: 0, updated: 0, new: 1
|
7
|
+
$ groovy ./HelloWorldSpec.groovy
|
17
8
|
```
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
1) Start IntelliJ IDEA. In the "Welcome to IntelliJ IDEA" window, click the "Open" option.
|
22
|
-
|
23
|
-
2) Navigate to the "Path\To\Your\Exercism\groovy\THIS_EXERCISE" folder. Make sure you've selected the root directory of the exercise. Click "OK".
|
24
|
-
|
25
|
-
3) Follow the dialog for creating the project from existing external sources.
|
26
|
-
|
27
|
-
4) IntelliJ will then create a new project structure in the editor for your exercise.
|
28
|
-
|
29
|
-
5) Depending on how much of the IDE you have configured before, you will likely need to add a Groovy SDK and a Java SDK (JDK 7+, ideally). These can be configured through the project/module settings by right clicking on the imported project.
|
30
|
-
|
31
|
-
6) You may also need to configure the location of the compiler output (exercism doesn't provide all IDE files since you could work the problems in a myriad of editors instead). This can be configured in the project settings as well.
|
32
|
-
|
33
|
-
## Start the exercise
|
34
|
-
|
35
|
-
1) Open the `README.md` file and carefully read the background for the assignment.
|
36
|
-
|
37
|
-
2) Start by running the test suite: In the "Project" view, right-click on the test file (`hello-world\HelloWorldTest.groovy`), select "Run", then pick the "HelloWorldTest" that has a JUnit icon to the left of it (red and green arrows).
|
38
|
-
|
39
|
-
3) The tests are designed to fail at the beginning. Each exercise will expect you to update the associated groovy file (named the same as the test without the ````Tests```` suffix in the filename.
|
40
|
-
|
41
|
-
4) To skip a test, you can add the @Ignore annotation a test method:
|
42
|
-
|
43
|
-
````
|
44
|
-
//This test will run.
|
45
|
-
@Test
|
46
|
-
void testNoName() {
|
47
|
-
assertTrue new HelloWorld().hello() == 'Hello, World!'
|
48
|
-
}
|
49
|
-
|
50
|
-
//this test will be skipped.
|
51
|
-
@Test
|
52
|
-
@Ignore
|
53
|
-
void testSampleName() {
|
54
|
-
assertTrue new HelloWorld().hello('Alice') == 'Hello, Alice!'
|
55
|
-
}
|
56
|
-
````
|
57
|
-
|
58
|
-
Alternatively, you can simply comment out an entire method to have it removed from compilation and being included in test output.
|
10
|
+
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
|
59
11
|
|
60
|
-
|
12
|
+
When all tests pass, congratulations!
|
@@ -1,21 +1,23 @@
|
|
1
1
|
class Squares {
|
2
|
-
def naturalNum
|
3
2
|
|
4
|
-
|
5
|
-
this.naturalNum = num
|
6
|
-
}
|
3
|
+
def naturalNum
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def Squares(num) {
|
6
|
+
this.naturalNum = num
|
7
|
+
}
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
def squareOfSums() {
|
10
|
+
(1..naturalNum).inject(0) {result, i -> result += i } ** 2
|
11
|
+
}
|
12
|
+
|
13
|
+
def sumOfSquares() {
|
14
|
+
(1..naturalNum).inject(0) {result, i ->
|
15
|
+
result += i ** 2
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
def difference() {
|
20
|
+
squareOfSums() - sumOfSquares()
|
21
|
+
}
|
17
22
|
|
18
|
-
def difference() {
|
19
|
-
squareOfSums() - sumOfSquares()
|
20
|
-
}
|
21
23
|
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class SquaresSpec extends Specification {
|
5
|
+
|
6
|
+
@Unroll("can square the sum of the numbers up to #integer")
|
7
|
+
def "can square the sum up to the given integer"() {
|
8
|
+
expect:
|
9
|
+
new Squares(integer).squareOfSums() == result
|
10
|
+
where:
|
11
|
+
integer | result
|
12
|
+
5 | 225
|
13
|
+
10 | 3025
|
14
|
+
100 | 25502500
|
15
|
+
}
|
16
|
+
|
17
|
+
@Ignore
|
18
|
+
@Unroll("can sum the squares up to #integer")
|
19
|
+
def 'can sum the squares up to the given integer'() {
|
20
|
+
expect:
|
21
|
+
new Squares(integer).sumOfSquares() == result
|
22
|
+
where:
|
23
|
+
integer | result
|
24
|
+
5 | 55
|
25
|
+
10 | 385
|
26
|
+
100 | 338350
|
27
|
+
}
|
28
|
+
|
29
|
+
@Ignore
|
30
|
+
@Unroll("can subtract sum of squares from square of sums of #integer")
|
31
|
+
def 'can subtract sum of squares from square of sums'() {
|
32
|
+
expect:
|
33
|
+
new Squares(integer).difference() == result
|
34
|
+
where:
|
35
|
+
integer | result
|
36
|
+
0 | 0
|
37
|
+
5 | 170
|
38
|
+
10 | 2640
|
39
|
+
100 | 25164150
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
}
|
1
|
+
import groovy.time.TimeCategory
|
2
|
+
|
3
|
+
class Gigasecond {
|
4
|
+
|
5
|
+
static Date from(Date date) {
|
6
|
+
use ( TimeCategory ) { date + (10**9).seconds }
|
7
|
+
}
|
8
|
+
|
9
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
import static java.util.Calendar.*
|
4
|
+
|
5
|
+
class GigasecondSpec extends Specification {
|
6
|
+
|
7
|
+
def gigasecond = new Gigasecond()
|
8
|
+
|
9
|
+
def 'calculates one gigasecond after a date'() {
|
10
|
+
given:
|
11
|
+
def start = Date.parse('yyyy-MMM-dd', '2011-Apr-25')
|
12
|
+
when:
|
13
|
+
def result = gigasecond.from(start)
|
14
|
+
then:
|
15
|
+
result == Date.parse('yyyy-MMM-dd hh:mm:ss', '2043-Jan-01 00:46:40')
|
16
|
+
}
|
17
|
+
|
18
|
+
@Ignore
|
19
|
+
def 'calculates one gigasecond after a date with hours and minutes'() {
|
20
|
+
given:
|
21
|
+
def start = Date.parse('yyyy-MMM-dd hh:mm', '1959-Jul-19 12:31')
|
22
|
+
when:
|
23
|
+
def result = gigasecond.from(start)
|
24
|
+
then:
|
25
|
+
result == Date.parse('yyyy-MMM-dd hh:mm:ss', '1991-Mar-27 01:17:40')
|
26
|
+
}
|
27
|
+
|
28
|
+
@Ignore
|
29
|
+
def 'calculates one gigasecond after a date with hours and minutes and seconds'() {
|
30
|
+
given:
|
31
|
+
def start = Date.parse('yyyy-MMM-dd hh:mm:ss', '1977-Jun-13 02:15:45')
|
32
|
+
when:
|
33
|
+
def result = gigasecond.from(start)
|
34
|
+
then:
|
35
|
+
result == Date.parse('yyyy-MMM-dd hh:mm:ss', '2009-Feb-19 03:02:25')
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class Hamming {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
|
3
|
+
def compute(strand1, strand2) {
|
4
|
+
(0..[strand1.size(), strand2.size()].min() - 1).step(1).count() {
|
5
|
+
strand1[it] != strand2[it]
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
7
9
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class HammingSpec extends Specification {
|
5
|
+
|
6
|
+
def 'computes zero distance for identical strands'() {
|
7
|
+
expect: new Hamming().compute('A','A') == 0
|
8
|
+
}
|
9
|
+
|
10
|
+
@Ignore
|
11
|
+
def 'computes the distance for a single nucleotide strand'() {
|
12
|
+
expect: new Hamming().compute('A','G') == 1
|
13
|
+
}
|
14
|
+
|
15
|
+
@Ignore
|
16
|
+
def 'computes the distance for a small strand'() {
|
17
|
+
expect: new Hamming().compute('AG','CT') == 2
|
18
|
+
}
|
19
|
+
|
20
|
+
@Ignore
|
21
|
+
def 'computes a small Hamming distance'() {
|
22
|
+
expect: new Hamming().compute('AT','CT') == 1
|
23
|
+
}
|
24
|
+
|
25
|
+
@Ignore
|
26
|
+
def 'computes a small Hamming distance in a longer strand'() {
|
27
|
+
expect: new Hamming().compute('GGACG','GGTCG') == 1
|
28
|
+
}
|
29
|
+
|
30
|
+
@Ignore
|
31
|
+
def 'ignores additional nucleotides when the first strand is longer'() {
|
32
|
+
expect: new Hamming().compute('AGAGACTTA','AAA') == 1
|
33
|
+
}
|
34
|
+
|
35
|
+
@Ignore
|
36
|
+
def 'ignores additional nucleotides when the second strand is longer'() {
|
37
|
+
expect: new Hamming().compute('AGG','AAAACTGACCCACCCCAGG') == 2
|
38
|
+
}
|
39
|
+
|
40
|
+
@Ignore
|
41
|
+
def 'computes a large Hamming distance'() {
|
42
|
+
expect: new Hamming().compute('GATACA','GCATAA') == 4
|
43
|
+
}
|
44
|
+
|
45
|
+
@Ignore
|
46
|
+
def 'computes a very long Hamming distance'() {
|
47
|
+
expect: new Hamming().compute('GGACGGATTCTG','AGGACGGATTCT') == 9
|
48
|
+
}
|
49
|
+
|
50
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class HelloWorldSpec extends Specification {
|
5
|
+
|
6
|
+
@Shared
|
7
|
+
def hello = new HelloWorld()
|
8
|
+
|
9
|
+
def 'outputs "Hello, World!"'() {
|
10
|
+
expect: hello.hello() == 'Hello, World!'
|
11
|
+
}
|
12
|
+
|
13
|
+
@Ignore
|
14
|
+
def 'outputs "Hello, Alice!" when given the name "Alice"'() {
|
15
|
+
expect: hello.hello('Alice') == 'Hello, Alice!'
|
16
|
+
}
|
17
|
+
|
18
|
+
@Ignore
|
19
|
+
def 'outputs "Hello, Bob!" when given the name "Bob"'() {
|
20
|
+
expect: hello.hello('Bob') == 'Hello, Bob!'
|
21
|
+
}
|
22
|
+
|
23
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class Raindrops {
|
2
|
-
private def primeSounds = [ 3:'Pling', 5:'Plang', 7:'Plong']
|
3
2
|
|
4
|
-
|
5
|
-
def result = new String()
|
3
|
+
private def primeSounds = [ 3:'Pling', 5:'Plang', 7:'Plong']
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def convert(num) {
|
6
|
+
def result = new String()
|
7
|
+
primeSounds.each({ k, v ->
|
8
|
+
if ((num % k).equals(0)) { result += v }
|
9
|
+
})
|
10
|
+
result.isEmpty() ? num.toString() : result
|
11
|
+
}
|
10
12
|
|
11
|
-
result.isEmpty() ? num.toString() : result
|
12
|
-
}
|
13
13
|
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class RaindropsSpec extends Specification {
|
5
|
+
|
6
|
+
@Shared
|
7
|
+
def raindrops = new Raindrops()
|
8
|
+
|
9
|
+
def '1 returns 1'() {
|
10
|
+
expect: raindrops.convert(1) == '1'
|
11
|
+
}
|
12
|
+
|
13
|
+
@Ignore
|
14
|
+
def '3, being divisible by 3, returns "Pling"'() {
|
15
|
+
expect: raindrops.convert(3) == 'Pling'
|
16
|
+
}
|
17
|
+
|
18
|
+
@Ignore
|
19
|
+
def '5, divisible by 5, returns "Plang"'() {
|
20
|
+
expect: raindrops.convert(5) == 'Plang'
|
21
|
+
}
|
22
|
+
|
23
|
+
@Ignore
|
24
|
+
def '7, divisible by 7, returns "Plong"'() {
|
25
|
+
expect: raindrops.convert(7) == 'Plong'
|
26
|
+
}
|
27
|
+
|
28
|
+
@Ignore
|
29
|
+
def '6, divisible by 3, returns "Pling"'() {
|
30
|
+
expect: raindrops.convert(6) == 'Pling'
|
31
|
+
}
|
32
|
+
|
33
|
+
@Ignore
|
34
|
+
def '8 returns the string "8"'() {
|
35
|
+
expect: raindrops.convert(8) == '8'
|
36
|
+
}
|
37
|
+
|
38
|
+
@Ignore
|
39
|
+
def '9, divisible by 3, returns "Pling"'() {
|
40
|
+
expect: raindrops.convert(9) == 'Pling'
|
41
|
+
}
|
42
|
+
|
43
|
+
@Ignore
|
44
|
+
def '10, divisible by 5, returns "Plang"'() {
|
45
|
+
expect: raindrops.convert(10) == 'Plang'
|
46
|
+
}
|
47
|
+
|
48
|
+
@Ignore
|
49
|
+
def '14, divisible by 7, returns "Plong"'() {
|
50
|
+
expect: raindrops.convert(14) == 'Plong'
|
51
|
+
}
|
52
|
+
|
53
|
+
@Ignore
|
54
|
+
def '15, divisible by both 3 and 5, returns "PlingPang"'() {
|
55
|
+
expect: raindrops.convert(15) == 'PlingPlang'
|
56
|
+
}
|
57
|
+
|
58
|
+
@Ignore
|
59
|
+
def '21, divisible by 3 and 7, returns "PlingPlong"'() {
|
60
|
+
expect: raindrops.convert(21) == 'PlingPlong'
|
61
|
+
}
|
62
|
+
|
63
|
+
@Ignore
|
64
|
+
def '25, divisible by 5, returns "Plang"'() {
|
65
|
+
expect: raindrops.convert(25) == 'Plang'
|
66
|
+
}
|
67
|
+
|
68
|
+
@Ignore
|
69
|
+
def '27, divisible by 3, returns "Pling"'() {
|
70
|
+
expect: raindrops.convert(27) == 'Pling'
|
71
|
+
}
|
72
|
+
|
73
|
+
@Ignore
|
74
|
+
def '35, divisible by 5 and 7, returns "PlangPlong"'() {
|
75
|
+
expect: raindrops.convert(35) == 'PlangPlong'
|
76
|
+
}
|
77
|
+
|
78
|
+
@Ignore
|
79
|
+
def '49, divisible by 7, returns "Plong"'() {
|
80
|
+
expect: raindrops.convert(49) == 'Plong'
|
81
|
+
}
|
82
|
+
|
83
|
+
@Ignore
|
84
|
+
def '52 returns the string "52"'() {
|
85
|
+
expect: raindrops.convert(52) == '52'
|
86
|
+
}
|
87
|
+
|
88
|
+
@Ignore
|
89
|
+
def '105 returns "PlingPlangPlong"'() {
|
90
|
+
expect: raindrops.convert(105) == 'PlingPlangPlong'
|
91
|
+
}
|
92
|
+
|
93
|
+
@Ignore
|
94
|
+
def '3125, divisible by 5, returns "Plang"'() {
|
95
|
+
expect: raindrops.convert(3125) == 'Plang'
|
96
|
+
}
|
97
|
+
|
98
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
2
|
+
import spock.lang.*
|
3
|
+
|
4
|
+
class ComplementTest extends Specification {
|
5
|
+
|
6
|
+
@Shared
|
7
|
+
def complement = new Complement()
|
8
|
+
|
9
|
+
def 'the rna complement of cytosine is guanine'() {
|
10
|
+
expect: complement.ofDNA('C') == 'G'
|
11
|
+
}
|
12
|
+
|
13
|
+
@Ignore
|
14
|
+
def 'the rna complement of guanine is cytosine'() {
|
15
|
+
expect: complement.ofDNA('G') == 'C'
|
16
|
+
}
|
17
|
+
|
18
|
+
@Ignore
|
19
|
+
def 'the rna complement of thymine is adenine'() {
|
20
|
+
expect: complement.ofDNA('T') == 'A'
|
21
|
+
}
|
22
|
+
|
23
|
+
@Ignore
|
24
|
+
def 'the rna complement of adenine is uracil'() {
|
25
|
+
expect: complement.ofDNA('A') == 'U'
|
26
|
+
}
|
27
|
+
|
28
|
+
@Ignore
|
29
|
+
def 'can calculate long strand complement'() {
|
30
|
+
expect: complement.ofDNA('ACGTGGTCTTAA') == 'UGCACCAGAAUU'
|
31
|
+
}
|
32
|
+
|
33
|
+
@Ignore
|
34
|
+
def 'correctly handles invalid input'() {
|
35
|
+
when: complement.ofDNA('U')
|
36
|
+
then: thrown(IllegalArgumentException)
|
37
|
+
}
|
38
|
+
|
39
|
+
@Ignore
|
40
|
+
def 'correctly handles completely invalid input'() {
|
41
|
+
when: complement.ofDNA('XXX')
|
42
|
+
then: thrown(IllegalArgumentException)
|
43
|
+
}
|
44
|
+
|
45
|
+
@Ignore
|
46
|
+
def 'correctly handles partially invalid input'() {
|
47
|
+
when: complement.ofDNA('ACGTXXXCTTAA')
|
48
|
+
then: thrown(IllegalArgumentException)
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
@@ -1,20 +1,25 @@
|
|
1
1
|
class Complement {
|
2
|
-
private def dnaMap = ["G":"C","C":"G","T":"A","A":"U"]
|
3
|
-
private def rnaMap = ["C":"G","G":"C","A":"T","U":"A"]
|
4
2
|
|
5
|
-
|
6
|
-
def
|
7
|
-
|
8
|
-
|
3
|
+
private def dnaMap = ["G":"C","C":"G","T":"A","A":"U"]
|
4
|
+
private def rnaMap = ["C":"G","G":"C","A":"T","U":"A"]
|
5
|
+
|
6
|
+
private def transcribe(seq, seqMap) {
|
7
|
+
def result = new String()
|
8
|
+
seq.split('').each() {
|
9
|
+
if ( !seqMap[it] ) {
|
10
|
+
throw new IllegalArgumentException()
|
11
|
+
}
|
12
|
+
result += seqMap[it]
|
13
|
+
}
|
14
|
+
return result
|
15
|
+
}
|
16
|
+
|
17
|
+
def ofDNA(strand) {
|
18
|
+
transcribe(strand, dnaMap)
|
9
19
|
}
|
10
|
-
return result
|
11
|
-
}
|
12
20
|
|
13
|
-
|
14
|
-
|
15
|
-
|
21
|
+
def ofRNA(strand) {
|
22
|
+
transcribe(strand, rnaMap)
|
23
|
+
}
|
16
24
|
|
17
|
-
def ofRNA(strand) {
|
18
|
-
transcribe(strand, rnaMap)
|
19
|
-
}
|
20
25
|
}
|
data/tracks/haskell/.travis.yml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
resolver: lts-7.9
|
data/tracks/haskell/config.json
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
tracks/haskell/exercises/pov/../../common/stack.yaml
|
@@ -4,7 +4,7 @@ import Control.Concurrent (MVar, readMVar, swapMVar, newMVar)
|
|
4
4
|
import Control.Monad (void)
|
5
5
|
import System.Random (randomRIO)
|
6
6
|
|
7
|
-
|
7
|
+
newtype Robot = Robot { robotNameVar :: MVar String }
|
8
8
|
|
9
9
|
mkRobot :: IO Robot
|
10
10
|
mkRobot = fmap Robot $ generateName >>= newMVar
|
@@ -121,7 +121,8 @@ git_clone() {
|
|
121
121
|
|
122
122
|
make_local_trackler() {
|
123
123
|
local trackler="$1"
|
124
|
-
|
124
|
+
local xapi_home="$2"
|
125
|
+
echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
|
125
126
|
|
126
127
|
local xjava=$( pwd )
|
127
128
|
pushd ${trackler}
|
@@ -134,6 +135,10 @@ make_local_trackler() {
|
|
134
135
|
cp ${xjava}/config.json tracks/java
|
135
136
|
cp -r ${xjava}/exercises tracks/java
|
136
137
|
|
138
|
+
# Set the version to that expected by x-api
|
139
|
+
version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
|
140
|
+
echo "module Trackler VERSION = \"${version}\" end" > lib/trackler/version.rb
|
141
|
+
|
137
142
|
gem install bundler
|
138
143
|
bundle install
|
139
144
|
gem build trackler.gemspec
|
@@ -237,12 +242,12 @@ main() {
|
|
237
242
|
clean "${build_dir}"
|
238
243
|
|
239
244
|
# Make a version of trackler that includes the source from this repo.
|
245
|
+
git_clone "x-api" "${xapi_home}"
|
240
246
|
git_clone "trackler" "${trackler_home}"
|
241
247
|
assert_ruby_installed "${trackler_home}"
|
242
|
-
make_local_trackler "${trackler_home}"
|
248
|
+
make_local_trackler "${trackler_home}" "${xapi_home}"
|
243
249
|
|
244
250
|
# Stand-up a local instance of x-api so we can fetch the exercises through it.
|
245
|
-
git_clone "x-api" "${xapi_home}"
|
246
251
|
assert_ruby_installed "${xapi_home}"
|
247
252
|
start_x_api "${xapi_home}"
|
248
253
|
|
@@ -257,7 +262,7 @@ main() {
|
|
257
262
|
# Execution begins here...
|
258
263
|
|
259
264
|
# If any command fails, fail the script.
|
260
|
-
set -
|
265
|
+
set -ex
|
261
266
|
SCRIPTPATH=$( pushd `dirname $0` > /dev/null && pwd && popd > /dev/null )
|
262
267
|
EXECPATH=$( pwd )
|
263
268
|
# Make output easier to read in CI
|
@@ -4,14 +4,11 @@ open Hello_world
|
|
4
4
|
|
5
5
|
let ae exp got _test_ctxt = assert_equal ~printer:String.to_string exp got
|
6
6
|
|
7
|
-
let tests =
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"other sample name">::
|
13
|
-
ae "Hello, Bob!" (greet (Some "Bob"));
|
14
|
-
]
|
7
|
+
let tests = [
|
8
|
+
"no name" >:: ae "Hello, World!" (greet None);
|
9
|
+
"sample name" >:: ae "Hello, Alice!" (greet (Some "Alice"));
|
10
|
+
"other sample name" >:: ae "Hello, Bob!" (greet (Some "Bob"));
|
11
|
+
]
|
15
12
|
|
16
13
|
let () =
|
17
|
-
run_test_tt_main ("Hello World tests" >::: tests)
|
14
|
+
run_test_tt_main ("Hello World tests" >::: tests)
|