trackler 2.2.1.138 → 2.2.1.139
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/crypto-square/description.md +23 -19
- data/problem-specifications/exercises/yacht/canonical-data.json +10 -1
- data/tracks/clojure/exercises/gigasecond/src/gigasecond.clj +5 -0
- data/tracks/clojure/exercises/grade-school/src/grade_school.clj +13 -0
- data/tracks/clojure/exercises/grains/src/grains.clj +9 -0
- data/tracks/clojure/exercises/minesweeper/src/minesweeper.clj +5 -0
- data/tracks/fsharp/docs/GENERATORS.md +12 -14
- data/tracks/fsharp/exercises/bowling/BowlingTest.fs +15 -15
- data/tracks/fsharp/exercises/perfect-numbers/PerfectNumbersTest.fs +11 -11
- data/tracks/fsharp/exercises/rna-transcription/Example.fs +7 -15
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscription.fs +1 -1
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscriptionTest.fs +5 -5
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulatorTest.fs +34 -34
- data/tracks/fsharp/exercises/sublist/Example.fs +1 -1
- data/tracks/fsharp/exercises/sublist/Sublist.fs +1 -1
- data/tracks/fsharp/exercises/sublist/SublistTest.fs +17 -17
- data/tracks/fsharp/exercises/word-search/WordSearchTest.fs +56 -57
- data/tracks/fsharp/generators/CanonicalData.fs +14 -15
- data/tracks/fsharp/generators/Common.fs +4 -84
- data/tracks/fsharp/generators/Conversion.fs +75 -0
- data/tracks/fsharp/generators/Exercise.fs +15 -11
- data/tracks/fsharp/generators/Generators.fs +294 -468
- data/tracks/fsharp/generators/Generators.fsproj +2 -1
- data/tracks/fsharp/generators/Rendering.fs +169 -61
- data/tracks/fsharp/generators/Templates.fs +64 -0
- data/tracks/fsharp/generators/Track.fs +3 -3
- data/tracks/idris/exercises/accumulate/src/Example.idr +1 -1
- data/tracks/idris/exercises/accumulate/src/Test/Accumulate.idr +2 -2
- data/tracks/java/exercises/rna-transcription/.meta/hints.md +2 -0
- data/tracks/java/exercises/rna-transcription/README.md +6 -0
- data/tracks/nim/.gitignore +1 -0
- data/tracks/nim/config.json +38 -0
- data/tracks/nim/config/maintainers.json +10 -0
- data/tracks/nim/docs/ABOUT.md +7 -0
- data/tracks/nim/exercises/bob/README.md +2 -0
- data/tracks/nim/exercises/bob/bob_test.nim +31 -13
- data/tracks/nim/exercises/bob/example.nim +2 -2
- data/tracks/nim/exercises/gigasecond/README.md +22 -0
- data/tracks/nim/exercises/gigasecond/example.nim +4 -0
- data/tracks/nim/exercises/gigasecond/gigasecond_test.nim +32 -0
- data/tracks/nim/exercises/isogram/README.md +20 -0
- data/tracks/nim/exercises/isogram/example.nim +6 -0
- data/tracks/nim/exercises/isogram/isogram_test.nim +32 -0
- data/tracks/nim/exercises/space-age/README.md +24 -0
- data/tracks/nim/exercises/space-age/example.nim +17 -0
- data/tracks/nim/exercises/space-age/space_age_test.nim +29 -0
- data/tracks/nim/exercises/triangle/example.nim +22 -22
- data/tracks/nim/exercises/triangle/triangle_test.nim +32 -44
- metadata +19 -3
- data/tracks/fsharp/generators/Formatting.fs +0 -189
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
|
|
6
6
|
|
7
7
|
He answers 'Whoa, chill out!' if you yell at him.
|
8
8
|
|
9
|
+
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
|
10
|
+
|
9
11
|
He says 'Fine. Be that way!' if you address him without actually saying
|
10
12
|
anything.
|
11
13
|
|
@@ -1,19 +1,27 @@
|
|
1
1
|
import unittest
|
2
|
-
|
2
|
+
|
3
|
+
import bob
|
3
4
|
|
4
5
|
suite "hey tests":
|
6
|
+
|
5
7
|
test "stating something":
|
6
8
|
check hey("Tom-ay-to, tom-aaaah-to.") == "Whatever."
|
7
9
|
|
8
10
|
test "shouting":
|
9
11
|
check hey("WATCH OUT!") == "Whoa, chill out!"
|
10
12
|
|
13
|
+
test "shouting gibberish":
|
14
|
+
check hey("FCECDFCAAB") == "Whoa, chill out!"
|
15
|
+
|
11
16
|
test "asking a question":
|
12
17
|
check hey("Does this cryogenic chamber make me look fat?") == "Sure."
|
13
18
|
|
14
19
|
test "asking a numeric question":
|
15
20
|
check hey("You are, what, like 15?") == "Sure."
|
16
21
|
|
22
|
+
test "asking a numeric question":
|
23
|
+
check hey("fffbbcbeab?") == "Sure."
|
24
|
+
|
17
25
|
test "talking forcefully":
|
18
26
|
check hey("Let's go make out behind the gym!") == "Whatever."
|
19
27
|
|
@@ -33,13 +41,7 @@ suite "hey tests":
|
|
33
41
|
check hey("4?") == "Sure."
|
34
42
|
|
35
43
|
test "shouting with special characters":
|
36
|
-
check hey("ZOMG THE %^*@#$(
|
37
|
-
|
38
|
-
test "shouting with umlauts":
|
39
|
-
check hey("ÜMLÄÜTS!") == "Whoa, chill out!"
|
40
|
-
|
41
|
-
test "calmly speaking with umlauts":
|
42
|
-
check hey("Ümläüts!") == "Whatever."
|
44
|
+
check hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!") == "Whoa, chill out!"
|
43
45
|
|
44
46
|
test "shouting with no exclamation mark":
|
45
47
|
check hey("I HATE YOU") == "Whoa, chill out!"
|
@@ -47,6 +49,9 @@ suite "hey tests":
|
|
47
49
|
test "statement containing question mark":
|
48
50
|
check hey("Ending with ? means a question.") == "Whatever."
|
49
51
|
|
52
|
+
test "non-letters with question":
|
53
|
+
check hey(":) ?") == "Sure."
|
54
|
+
|
50
55
|
test "prattling on":
|
51
56
|
check hey("Wait! Hang on. Are you going to be OK?") == "Sure."
|
52
57
|
|
@@ -54,10 +59,23 @@ suite "hey tests":
|
|
54
59
|
check hey("") == "Fine. Be that way!"
|
55
60
|
|
56
61
|
test "prolonged silence":
|
57
|
-
check hey("
|
62
|
+
check hey(" ") == "Fine. Be that way!"
|
63
|
+
|
64
|
+
test "alternate silence":
|
65
|
+
check hey("\t\t\t\t\t\t\t\t\t\t") == "Fine. Be that way!"
|
66
|
+
|
67
|
+
test "multiple line question":
|
68
|
+
check hey("\nDoes this cryogenic chamber make me look fat?\nno") == "Whatever."
|
69
|
+
|
70
|
+
test "starting with whitespace":
|
71
|
+
check hey(" hmmmmmmm...") == "Whatever."
|
72
|
+
|
73
|
+
test "ending with whitespace":
|
74
|
+
check hey("Okay if like my spacebar quite a bit? ") == "Sure."
|
75
|
+
|
76
|
+
test "other whitespace":
|
77
|
+
check hey("\n\r \t") == "Fine. Be that way!"
|
58
78
|
|
59
|
-
test "
|
60
|
-
check hey("
|
79
|
+
test "non-question ending with whitespace":
|
80
|
+
check hey("This is a statement ending with whitespace ") == "Whatever."
|
61
81
|
|
62
|
-
test "multi line trick question":
|
63
|
-
check hey("Do I ever change my mind?\nNo.") == "Whatever."
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from strutils import endsWith
|
1
|
+
from strutils import endsWith, strip
|
2
2
|
from unicode import isLower, isUpper, isWhiteSpace, runes
|
3
3
|
|
4
4
|
proc isSilence(s: string): bool =
|
@@ -17,7 +17,7 @@ proc isYelling(s: string): bool =
|
|
17
17
|
return nUpperRunes > 0
|
18
18
|
|
19
19
|
proc isQuestion(s: string): bool =
|
20
|
-
return s.endsWith("?")
|
20
|
+
return s.strip().endsWith("?")
|
21
21
|
|
22
22
|
proc hey*(msg: string): string {.noSideEffect.} =
|
23
23
|
## Returns the response of a lackadaisical teenager to a futile attempt to
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Gigasecond
|
2
|
+
|
3
|
+
Calculate the moment when someone has lived for 10^9 seconds.
|
4
|
+
|
5
|
+
A gigasecond is 10^9 (1,000,000,000) seconds.
|
6
|
+
|
7
|
+
## Submitting Exercises
|
8
|
+
|
9
|
+
Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/nim/gigasecond` directory.
|
10
|
+
|
11
|
+
You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`.
|
12
|
+
|
13
|
+
For more detailed information about running tests, code style and linting,
|
14
|
+
please see the [help page](http://exercism.io/languages/nim).
|
15
|
+
|
16
|
+
## Source
|
17
|
+
|
18
|
+
Chapter 9 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=09](http://pine.fm/LearnToProgram/?Chapter=09)
|
19
|
+
|
20
|
+
## Submitting Incomplete Solutions
|
21
|
+
|
22
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import unittest, times
|
2
|
+
|
3
|
+
import gigasecond
|
4
|
+
|
5
|
+
suite "Gigasecond":
|
6
|
+
|
7
|
+
test "date only specification of time":
|
8
|
+
let birthday = initDateTime(25, mApr, 2011, 0, 0, 0, utc())
|
9
|
+
let expected = initDateTime(1, mJan, 2043, 1, 46, 40, utc())
|
10
|
+
check add_gigasecond(birthday) == expected
|
11
|
+
|
12
|
+
test "second test for date only specification of time":
|
13
|
+
let birthday = initDateTime(13, mJun, 1977, 0, 0, 0, utc())
|
14
|
+
let expected = initDateTime(19, mFeb, 2009, 1, 46, 40, utc())
|
15
|
+
check add_gigasecond(birthday) == expected
|
16
|
+
|
17
|
+
test "third test for date only specification of time":
|
18
|
+
let birthday = initDateTime(19, mJul, 1959, 0, 0, 0, utc())
|
19
|
+
let expected = initDateTime(27, mMar, 1991, 1, 46, 40, utc())
|
20
|
+
check add_gigasecond(birthday) == expected
|
21
|
+
|
22
|
+
test "full time specified":
|
23
|
+
let birthday = initDateTime(24, mJan, 2015, 22, 0, 0, utc())
|
24
|
+
let expected = initDateTime(2, mOct, 2046, 23, 46, 40, utc())
|
25
|
+
check add_gigasecond(birthday) == expected
|
26
|
+
|
27
|
+
test "full time with day roll-over":
|
28
|
+
let birthday = initDateTime(24, mJan, 2015, 23, 59, 59, utc())
|
29
|
+
let expected = initDateTime(3, mOct, 2046, 1, 46, 39, utc())
|
30
|
+
check add_gigasecond(birthday) == expected
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Isogram
|
2
|
+
|
3
|
+
Determine if a word or phrase is an isogram.
|
4
|
+
|
5
|
+
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.
|
6
|
+
|
7
|
+
Examples of isograms:
|
8
|
+
|
9
|
+
- lumberjacks
|
10
|
+
- background
|
11
|
+
- downstream
|
12
|
+
- six-year-old
|
13
|
+
|
14
|
+
The word *isograms*, however, is not an isogram, because the s repeats.
|
15
|
+
## Source
|
16
|
+
|
17
|
+
Wikipedia [https://en.wikipedia.org/wiki/Isogram](https://en.wikipedia.org/wiki/Isogram)
|
18
|
+
|
19
|
+
## Submitting Incomplete Solutions
|
20
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
import isogram
|
4
|
+
|
5
|
+
suite "Isogram":
|
6
|
+
|
7
|
+
test "empty string":
|
8
|
+
check isIsogram("") == true
|
9
|
+
|
10
|
+
test "isogram with only lower case characters":
|
11
|
+
check isIsogram("isogram") == true
|
12
|
+
|
13
|
+
test "word with one duplicated character":
|
14
|
+
check isIsogram("eleven") == false
|
15
|
+
|
16
|
+
test "longest reported english isogram":
|
17
|
+
check isIsogram("subdermatoglyphic") == true
|
18
|
+
|
19
|
+
test "word with duplicated character in mixed case":
|
20
|
+
check isIsogram("Alphabet") == false
|
21
|
+
|
22
|
+
test "hypothetical isogrammic word with hyphen":
|
23
|
+
check isIsogram("thumbscrew-japingly") == true
|
24
|
+
|
25
|
+
test "isogram with duplicated hyphen":
|
26
|
+
check isIsogram("six-year-old") == true
|
27
|
+
|
28
|
+
test "made up name that is an isogram":
|
29
|
+
check isIsogram("Emily Jung Schwartzkopf") == true
|
30
|
+
|
31
|
+
test "duplicated character in the middle":
|
32
|
+
check isIsogram("accentor") == false
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Space Age
|
2
|
+
|
3
|
+
Given an age in seconds, calculate how old someone would be on:
|
4
|
+
|
5
|
+
- Earth: orbital period 365.25 Earth days, or 31557600 seconds
|
6
|
+
- Mercury: orbital period 0.2408467 Earth years
|
7
|
+
- Venus: orbital period 0.61519726 Earth years
|
8
|
+
- Mars: orbital period 1.8808158 Earth years
|
9
|
+
- Jupiter: orbital period 11.862615 Earth years
|
10
|
+
- Saturn: orbital period 29.447498 Earth years
|
11
|
+
- Uranus: orbital period 84.016846 Earth years
|
12
|
+
- Neptune: orbital period 164.79132 Earth years
|
13
|
+
|
14
|
+
So if you were told someone were 1,000,000,000 seconds old, you should
|
15
|
+
be able to say that they're 31.69 Earth-years old.
|
16
|
+
|
17
|
+
If you're wondering why Pluto didn't make the cut, go watch [this
|
18
|
+
youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs).
|
19
|
+
## Source
|
20
|
+
|
21
|
+
Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=01](http://pine.fm/LearnToProgram/?Chapter=01)
|
22
|
+
|
23
|
+
## Submitting Incomplete Solutions
|
24
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import
|
2
|
+
math, tables
|
3
|
+
|
4
|
+
let
|
5
|
+
times = {
|
6
|
+
"Earth": 31558149.76,
|
7
|
+
"Mercury": 7600530.24,
|
8
|
+
"Venus": 19413907.2,
|
9
|
+
"Mars": 59354294.4,
|
10
|
+
"Jupiter": 374335776.0,
|
11
|
+
"Saturn": 929596608.0,
|
12
|
+
"Uranus": 2661041808.0,
|
13
|
+
"Neptune": 5200418592.0
|
14
|
+
}.toTable
|
15
|
+
|
16
|
+
proc age*(planet: string, seconds: int64): float =
|
17
|
+
round(seconds.float / times[planet], 2)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
import space_age
|
4
|
+
|
5
|
+
suite "Space Age":
|
6
|
+
|
7
|
+
test "age on Earth":
|
8
|
+
check age("Earth", 1000000000) == 31.69
|
9
|
+
|
10
|
+
test "age on Mercury":
|
11
|
+
check age("Mercury", 2134835688) == 280.88
|
12
|
+
|
13
|
+
test "age on Venus":
|
14
|
+
check age("Venus", 189839836) == 9.78
|
15
|
+
|
16
|
+
test "age on Mars":
|
17
|
+
check age("Mars", 2329871239) == 39.25
|
18
|
+
|
19
|
+
test "age on Jupiter":
|
20
|
+
check age("Jupiter", 901876382) == 2.41
|
21
|
+
|
22
|
+
test "age on Saturn":
|
23
|
+
check age("Saturn", 3000000000) == 3.23
|
24
|
+
|
25
|
+
test "age on Uranus":
|
26
|
+
check age("Uranus", 3210123456) == 1.21
|
27
|
+
|
28
|
+
test "age on Neptune":
|
29
|
+
check age("Neptune", 8210123456) == 1.58
|
@@ -1,25 +1,25 @@
|
|
1
|
-
import
|
1
|
+
import sequtils
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
tkIsosceles,
|
7
|
-
tkScalene
|
3
|
+
proc valid(a, b, c: int): bool =
|
4
|
+
let greatThenZero = all([a, b, c], proc (x: int): bool = return x > 0)
|
5
|
+
let equalityCheck = (a + b >= c) and (a + c >= b) and (b + c >= a)
|
8
6
|
|
9
|
-
|
10
|
-
let fc = classify(f)
|
11
|
-
if not (fc == fcNormal or fc == fcSubnormal) or f < 0:
|
12
|
-
raise newException(ValueError, "invalid side: " & $f)
|
7
|
+
greatThenZero and equalityCheck
|
13
8
|
|
14
|
-
proc
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
proc is_equilateral*(sides: array[3, int]): bool =
|
10
|
+
let a = sides[0]
|
11
|
+
let b = sides[1]
|
12
|
+
let c = sides[2]
|
13
|
+
valid(a, b, c) and all(sides, proc (x: int): bool = return a == x)
|
14
|
+
|
15
|
+
proc is_isosceles*(sides: array[3, int]): bool =
|
16
|
+
let a = sides[0]
|
17
|
+
let b = sides[1]
|
18
|
+
let c = sides[2]
|
19
|
+
valid(a, b, c) and (a == b or b == c or a == c)
|
20
|
+
|
21
|
+
proc is_scalene*(sides: array[3, int]): bool =
|
22
|
+
let a = sides[0]
|
23
|
+
let b = sides[1]
|
24
|
+
let c = sides[2]
|
25
|
+
valid(a, b, c) and not is_isosceles(sides)
|
@@ -2,64 +2,52 @@ import unittest
|
|
2
2
|
|
3
3
|
import triangle
|
4
4
|
|
5
|
-
|
6
|
-
check kind(2, 2, 2) == tkEquilateral
|
5
|
+
suite "returns true if the triangle is equilateral":
|
7
6
|
|
8
|
-
test "
|
9
|
-
|
7
|
+
test "true if all sides are equal":
|
8
|
+
check is_equilateral([2, 2, 2]) == true
|
10
9
|
|
11
|
-
test "
|
12
|
-
|
10
|
+
test "false if any side is unequal":
|
11
|
+
check is_equilateral([2, 3, 2]) == false
|
13
12
|
|
14
|
-
test "
|
15
|
-
|
13
|
+
test "false if no sides are equal":
|
14
|
+
check is_equilateral([5, 4, 6]) == false
|
16
15
|
|
17
|
-
test "
|
18
|
-
|
16
|
+
test "false if all sides are zero":
|
17
|
+
check is_equilateral([0, 0, 0]) == false
|
19
18
|
|
20
|
-
test "isosceles triangles have in fact exactly two sides equal":
|
21
|
-
check kind(10, 10, 2) == tkIsosceles
|
22
19
|
|
23
|
-
|
24
|
-
check kind(3, 4, 5) == tkScalene
|
20
|
+
suite "returns true if the triangle is isosceles":
|
25
21
|
|
26
|
-
test "
|
27
|
-
|
22
|
+
test "true if last two sides are equal":
|
23
|
+
check is_isosceles([3, 4, 4]) == true
|
28
24
|
|
29
|
-
test "
|
30
|
-
|
25
|
+
test "true if first two sides are equal":
|
26
|
+
check is_isosceles([4, 4, 3]) == true
|
31
27
|
|
32
|
-
test "
|
33
|
-
|
28
|
+
test "true if first and last sides are equal":
|
29
|
+
check is_isosceles([4, 3, 4]) == true
|
34
30
|
|
35
|
-
test "triangles
|
36
|
-
|
37
|
-
discard kind(0, 0, 0)
|
31
|
+
test "is equilateral triangles are also is isosceles":
|
32
|
+
check is_isosceles([4, 4, 4]) == true
|
38
33
|
|
39
|
-
test "
|
40
|
-
|
41
|
-
discard kind(3, 4, -5)
|
34
|
+
test "false if no sides are equal":
|
35
|
+
check is_isosceles([2, 3, 4]) == false
|
42
36
|
|
43
|
-
test "
|
44
|
-
|
45
|
-
discard kind(1, 1, 3)
|
37
|
+
test "violation of triangle inequality not is isosceles":
|
38
|
+
check is_isosceles([1, 1, 3]) == false
|
46
39
|
|
47
|
-
test "triangles violating triangle inequality are illegal 2":
|
48
|
-
expect(ValueError):
|
49
|
-
discard kind(2, 4, 2)
|
50
40
|
|
51
|
-
|
52
|
-
expect(ValueError):
|
53
|
-
discard kind(7, 3, 2)
|
41
|
+
suite "returns true if the triangle is scalene":
|
54
42
|
|
55
|
-
test "
|
56
|
-
|
57
|
-
discard kind(7, 3, NaN)
|
43
|
+
test "true if no sides are equal":
|
44
|
+
check is_scalene([5, 4, 6]) == true
|
58
45
|
|
59
|
-
test "
|
60
|
-
|
61
|
-
discard kind(7, 3, Inf)
|
46
|
+
test "false if all sides are equal":
|
47
|
+
check is_scalene([4, 4, 4]) == false
|
62
48
|
|
63
|
-
test "
|
64
|
-
|
65
|
-
|
49
|
+
test "false if two sides are equal":
|
50
|
+
check is_scalene([4, 4, 3]) == false
|
51
|
+
|
52
|
+
test "violation of triangle inequality not is scalene":
|
53
|
+
check is_scalene([7, 3, 2]) == false
|