trackler 2.0.8.1 → 2.0.8.2
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/tracks/fsharp/exercises/list-ops/Example.fs +5 -5
- data/tracks/fsharp/exercises/list-ops/ListOpsTest.fs +2 -2
- data/tracks/go/exercises/TRACK_HINTS.md +6 -2
- data/tracks/go/exercises/series/asktoomuch_test.go +4 -4
- data/tracks/go/exercises/series/example.go +2 -0
- data/tracks/go/exercises/series/first_test.go +3 -3
- data/tracks/go/exercises/series/series_test.go +10 -2
- data/tracks/java/exercises/pangram/src/test/java/PangramsTest.java +6 -0
- data/tracks/javascript/exercises/robot-simulator/example.js +8 -1
- data/tracks/javascript/exercises/robot-simulator/robot-simulator.spec.js +4 -4
- data/tracks/julia/docs/ABOUT.md +12 -0
- data/tracks/julia/docs/INSTALLATION.md +2 -0
- data/tracks/julia/docs/RESOURCES.md +6 -0
- data/tracks/ocaml/exercises/hello-world/example.ml +1 -4
- data/tracks/ocaml/exercises/hello-world/hello_world.ml +1 -2
- data/tracks/ocaml/exercises/hello-world/hello_world.mli +2 -10
- data/tracks/ocaml/exercises/hello-world/test.ml +1 -3
- data/tracks/ocaml/exercises/luhn/test.ml +14 -14
- data/tracks/ocaml/tools/test-generator/src/parser.ml +2 -1
- data/tracks/ocaml/tools/test-generator/templates/hello-world/template.ml +1 -1
- data/tracks/python/.travis.yml +1 -0
- data/tracks/python/config.json +25 -0
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +82 -0
- data/tracks/python/exercises/all-your-base/example.py +23 -0
- data/tracks/python/exercises/grep/example.py +57 -0
- data/tracks/python/exercises/grep/grep_test.py +225 -0
- data/tracks/python/exercises/linked-list/example.py +14 -0
- data/tracks/python/exercises/linked-list/linked_list.py +2 -1
- data/tracks/python/exercises/linked-list/linked_list_test.py +18 -0
- data/tracks/python/exercises/word-search/example.py +57 -0
- data/tracks/python/exercises/word-search/word_search.py +27 -0
- data/tracks/python/exercises/word-search/word_search_test.py +84 -0
- data/tracks/python/requirements-travis.txt +1 -1
- data/tracks/python/test/check-exercises.py +44 -19
- data/tracks/scala/config.json +9 -0
- data/tracks/scala/exercises/perfect-numbers/build.sbt +3 -0
- data/tracks/scala/exercises/perfect-numbers/example.scala +24 -0
- data/tracks/scala/exercises/perfect-numbers/src/main/scala/PerfectNumbers.scala +0 -0
- data/tracks/scala/exercises/perfect-numbers/src/test/scala/PerfectNumbersTest.scala +62 -0
- data/tracks/typescript/Makefile +8 -0
- metadata +13 -2
@@ -0,0 +1,27 @@
|
|
1
|
+
class Point(object):
|
2
|
+
def __init__(self, x, y):
|
3
|
+
self.x = x
|
4
|
+
self.y = y
|
5
|
+
|
6
|
+
def __repr__(self):
|
7
|
+
return 'Point({}:{})'.format(self.x, self.y)
|
8
|
+
|
9
|
+
def __add__(self, other):
|
10
|
+
return Point(self.x + other.x, self.y + other.y)
|
11
|
+
|
12
|
+
def __sub__(self, other):
|
13
|
+
return Point(self.x - other.x, self.y - other.y)
|
14
|
+
|
15
|
+
def __eq__(self, other):
|
16
|
+
return self.x == other.x and self.y == other.y
|
17
|
+
|
18
|
+
def __ne__(self, other):
|
19
|
+
return not(self == other)
|
20
|
+
|
21
|
+
|
22
|
+
class WordSearch(object):
|
23
|
+
def __init__(self, puzzle):
|
24
|
+
pass
|
25
|
+
|
26
|
+
def search(self, word):
|
27
|
+
return None
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
from word_search import WordSearch, Point
|
4
|
+
|
5
|
+
|
6
|
+
class WordSearchTests(unittest.TestCase):
|
7
|
+
|
8
|
+
@classmethod
|
9
|
+
def setUpClass(self):
|
10
|
+
puzzle = ('jefblpepre\n'
|
11
|
+
'camdcimgtc\n'
|
12
|
+
'oivokprjsm\n'
|
13
|
+
'pbwasqroua\n'
|
14
|
+
'rixilelhrs\n'
|
15
|
+
'wolcqlirpc\n'
|
16
|
+
'screeaumgr\n'
|
17
|
+
'alxhpburyi\n'
|
18
|
+
'jalaycalmp\n'
|
19
|
+
'clojurermt')
|
20
|
+
self.example = WordSearch(puzzle)
|
21
|
+
|
22
|
+
def test_horizontal_words_left_to_right(self):
|
23
|
+
self.assertEqual(
|
24
|
+
self.example.search('clojure'),
|
25
|
+
(Point(0, 9), Point(6, 9))
|
26
|
+
)
|
27
|
+
|
28
|
+
def test_horizontal_words_right_to_left(self):
|
29
|
+
self.assertEqual(
|
30
|
+
self.example.search('elixir'),
|
31
|
+
(Point(5, 4), Point(0, 4))
|
32
|
+
)
|
33
|
+
|
34
|
+
def test_vertical_words_top_to_bottom(self):
|
35
|
+
self.assertEqual(
|
36
|
+
self.example.search('ecmascript'),
|
37
|
+
(Point(9, 0), Point(9, 9))
|
38
|
+
)
|
39
|
+
|
40
|
+
def test_vertical_words_bottom_to_top(self):
|
41
|
+
self.assertEqual(
|
42
|
+
self.example.search('rust'),
|
43
|
+
(Point(8, 4), Point(8, 1))
|
44
|
+
)
|
45
|
+
|
46
|
+
def test_diagonal_words_top_left_to_bottom_right(self):
|
47
|
+
self.assertEqual(
|
48
|
+
self.example.search('java'),
|
49
|
+
(Point(0, 0), Point(3, 3))
|
50
|
+
)
|
51
|
+
|
52
|
+
def test_diagonal_upper_bottom_right_to_top_left(self):
|
53
|
+
self.assertEqual(
|
54
|
+
self.example.search('lua'),
|
55
|
+
(Point(7, 8), Point(5, 6))
|
56
|
+
)
|
57
|
+
|
58
|
+
def test_diagonal_upper_bottom_left_to_top_right(self):
|
59
|
+
self.assertEqual(
|
60
|
+
self.example.search('lisp'),
|
61
|
+
(Point(2, 5), Point(5, 2))
|
62
|
+
)
|
63
|
+
|
64
|
+
def test_diagonal_upper_top_right_to_bottom_left(self):
|
65
|
+
self.assertEqual(
|
66
|
+
self.example.search('ruby'),
|
67
|
+
(Point(7, 5), Point(4, 8))
|
68
|
+
)
|
69
|
+
|
70
|
+
def test_words_that_are_not_in_the_puzzle(self):
|
71
|
+
self.assertIsNone(self.example.search('haskell'))
|
72
|
+
|
73
|
+
def test_search_differently_sized_puzzles(self):
|
74
|
+
puzzle = ('qwertyuiopz\n'
|
75
|
+
'luamsicrexe\n'
|
76
|
+
'abcdefghijk')
|
77
|
+
self.assertEqual(
|
78
|
+
WordSearch(puzzle).search('exercism'),
|
79
|
+
(Point(10, 1), Point(3, 1))
|
80
|
+
)
|
81
|
+
|
82
|
+
|
83
|
+
if __name__ == '__main__':
|
84
|
+
unittest.main()
|
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
|
+
from __future__ import print_function
|
3
|
+
|
2
4
|
import os
|
3
5
|
import ast
|
4
6
|
import imp
|
@@ -7,11 +9,13 @@ import shutil
|
|
7
9
|
import subprocess
|
8
10
|
import sys
|
9
11
|
import tempfile
|
12
|
+
import json
|
10
13
|
|
11
14
|
|
12
|
-
def check_assignment(name, test_file
|
15
|
+
def check_assignment(name, test_file):
|
13
16
|
# Returns the exit code of the tests
|
14
17
|
workdir = tempfile.mkdtemp(name)
|
18
|
+
example_name = modname_heuristic(test_file)
|
15
19
|
try:
|
16
20
|
test_file_out = os.path.join(workdir, os.path.basename(test_file))
|
17
21
|
shutil.copyfile(test_file, test_file_out)
|
@@ -49,29 +53,50 @@ def is_module_missing(modname):
|
|
49
53
|
return False
|
50
54
|
|
51
55
|
|
52
|
-
def
|
53
|
-
|
56
|
+
def load_config():
|
57
|
+
try:
|
58
|
+
with open('./config.json') as json_file:
|
59
|
+
data = json.load(json_file)
|
60
|
+
except IOError:
|
61
|
+
print('FAIL: config.json file not found')
|
62
|
+
raise SystemExit(1)
|
63
|
+
|
64
|
+
try:
|
65
|
+
problems = [entry['slug'] for entry in data['exercises']]
|
66
|
+
deprecated_problems = data['deprecated']
|
67
|
+
except KeyError:
|
68
|
+
print('FAIL: config.json has an incorrect format')
|
69
|
+
raise SystemExit(1)
|
70
|
+
|
71
|
+
return problems, deprecated_problems
|
54
72
|
|
55
73
|
|
56
74
|
def main():
|
57
|
-
if len(sys.argv)
|
58
|
-
|
59
|
-
|
60
|
-
check_assignment(assignment_name(test_file), test_file,
|
61
|
-
modname_heuristic(test_file))
|
75
|
+
if len(sys.argv) >= 2:
|
76
|
+
# test specific exercises
|
77
|
+
exercises = [exercise.strip('/') for exercise in sys.argv[1:]]
|
62
78
|
else:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
if
|
71
|
-
print('
|
72
|
-
|
79
|
+
# load exercises from config-file
|
80
|
+
exercises, _ = load_config()
|
81
|
+
|
82
|
+
failures = []
|
83
|
+
for exercise in exercises:
|
84
|
+
test_file = glob.glob('./exercises/{}/*_test.py'.format(exercise))
|
85
|
+
print('# ', exercise)
|
86
|
+
if not test_file:
|
87
|
+
print('FAIL: File with test cases not found')
|
88
|
+
failures.append('{} (FileNotFound)'.format(exercise))
|
73
89
|
else:
|
74
|
-
|
90
|
+
if check_assignment(exercise, test_file[0]):
|
91
|
+
failures.append('{} (TestFailed)'.format(exercise))
|
92
|
+
print('')
|
93
|
+
|
94
|
+
if failures:
|
95
|
+
print('FAILURES: ', ', '.join(failures))
|
96
|
+
raise SystemExit(1)
|
97
|
+
else:
|
98
|
+
print('SUCCESS!')
|
99
|
+
|
75
100
|
|
76
101
|
if __name__ == '__main__':
|
77
102
|
main()
|
data/tracks/scala/config.json
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
import NumberType.NumberType
|
2
|
+
|
3
|
+
object PerfectNumbers {
|
4
|
+
def classify(n: Int): NumberType = {
|
5
|
+
val sumOfFactors
|
6
|
+
= (1 until n)
|
7
|
+
.foldLeft(0)((acc, i) => if (n % i == 0) acc + i else acc)
|
8
|
+
|
9
|
+
if (sumOfFactors < n)
|
10
|
+
NumberType.Deficient
|
11
|
+
else if (sumOfFactors > n)
|
12
|
+
NumberType.Abundant
|
13
|
+
else
|
14
|
+
NumberType.Perfect
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
object NumberType extends Enumeration {
|
19
|
+
type NumberType = Value
|
20
|
+
|
21
|
+
val Perfect = Value("Perfect")
|
22
|
+
val Abundant = Value("Abundant")
|
23
|
+
val Deficient = Value("Deficient")
|
24
|
+
}
|
File without changes
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import org.scalatest.{FlatSpec, Matchers}
|
2
|
+
|
3
|
+
class PerfectNumbersTest extends FlatSpec with Matchers {
|
4
|
+
it should "handle deficient - 3" in {
|
5
|
+
PerfectNumbers.classify(3) should be (NumberType.Deficient)
|
6
|
+
}
|
7
|
+
|
8
|
+
it should "handle deficient - 7" in {
|
9
|
+
pending
|
10
|
+
PerfectNumbers.classify(7) should be (NumberType.Deficient)
|
11
|
+
}
|
12
|
+
|
13
|
+
it should "handle deficient - 13" in {
|
14
|
+
pending
|
15
|
+
PerfectNumbers.classify(13) should be (NumberType.Deficient)
|
16
|
+
}
|
17
|
+
|
18
|
+
it should "handle deficient - 33550337" in {
|
19
|
+
pending
|
20
|
+
PerfectNumbers.classify(33550337) should be (NumberType.Deficient)
|
21
|
+
}
|
22
|
+
|
23
|
+
it should "handle perfect - 6" in {
|
24
|
+
pending
|
25
|
+
PerfectNumbers.classify(6) should be (NumberType.Perfect)
|
26
|
+
}
|
27
|
+
|
28
|
+
it should "handle perfect - 28" in {
|
29
|
+
pending
|
30
|
+
PerfectNumbers.classify(28) should be (NumberType.Perfect)
|
31
|
+
}
|
32
|
+
|
33
|
+
it should "handle perfect - 33550336" in {
|
34
|
+
pending
|
35
|
+
PerfectNumbers.classify(33550336) should be (NumberType.Perfect)
|
36
|
+
}
|
37
|
+
|
38
|
+
it should "handle perfect - 496" in {
|
39
|
+
pending
|
40
|
+
PerfectNumbers.classify(496) should be (NumberType.Perfect)
|
41
|
+
}
|
42
|
+
|
43
|
+
it should "handle abundant - 12" in {
|
44
|
+
pending
|
45
|
+
PerfectNumbers.classify(12) should be (NumberType.Abundant)
|
46
|
+
}
|
47
|
+
|
48
|
+
it should "handle abundant - 18" in {
|
49
|
+
pending
|
50
|
+
PerfectNumbers.classify(18) should be (NumberType.Abundant)
|
51
|
+
}
|
52
|
+
|
53
|
+
it should "handle abundant - 20" in {
|
54
|
+
pending
|
55
|
+
PerfectNumbers.classify(20) should be (NumberType.Abundant)
|
56
|
+
}
|
57
|
+
|
58
|
+
it should "handle abundant - 33550335" in {
|
59
|
+
pending
|
60
|
+
PerfectNumbers.classify(33550335) should be (NumberType.Abundant)
|
61
|
+
}
|
62
|
+
}
|
data/tracks/typescript/Makefile
CHANGED
@@ -44,7 +44,11 @@ moveAllIntoCommonDir:
|
|
44
44
|
moveCommonIntoSubDir:
|
45
45
|
@for assignment in $(ASSIGNMENTS); do ASSIGNMENT=$$assignment $(MAKE) moveAssigmentToSub || exit 1; done
|
46
46
|
|
47
|
+
<<<<<<< HEAD
|
47
48
|
all: replacePackageFileFromCommonToSubFolders
|
49
|
+
=======
|
50
|
+
all: replacePackageFilesFromCommonToSubFolders
|
51
|
+
>>>>>>> f5528ecd7751462ac6590cc77304a7ac2489c895
|
48
52
|
|
49
53
|
copyPackageFilesToSubFolder:
|
50
54
|
@cp ./common/package.json exercises/$(ASSIGNMENT)/package.json
|
@@ -52,6 +56,10 @@ copyPackageFilesToSubFolder:
|
|
52
56
|
@cp ./common/tslint.json exercises/$(ASSIGNMENT)/tslint.json
|
53
57
|
@cp ./common/yarn.lock exercises/$(ASSIGNMENT)/yarn.lock
|
54
58
|
|
59
|
+
<<<<<<< HEAD
|
55
60
|
replacePackageFileFromCommonToSubFolders:
|
61
|
+
=======
|
62
|
+
replacePackageFilesFromCommonToSubFolders:
|
63
|
+
>>>>>>> f5528ecd7751462ac6590cc77304a7ac2489c895
|
56
64
|
@for assignment in $(ASSIGNMENTS); do ASSIGNMENT=$$assignment $(MAKE) copyPackageFilesToSubFolder || exit 1; done
|
57
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.8.
|
4
|
+
version: 2.0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -6108,6 +6108,8 @@ files:
|
|
6108
6108
|
- tracks/python/exercises/accumulate/example.py
|
6109
6109
|
- tracks/python/exercises/acronym/acronym_test.py
|
6110
6110
|
- tracks/python/exercises/acronym/example.py
|
6111
|
+
- tracks/python/exercises/all-your-base/all_your_base_test.py
|
6112
|
+
- tracks/python/exercises/all-your-base/example.py
|
6111
6113
|
- tracks/python/exercises/allergies/allergies_test.py
|
6112
6114
|
- tracks/python/exercises/allergies/example.py
|
6113
6115
|
- tracks/python/exercises/anagram/anagram_test.py
|
@@ -6145,6 +6147,8 @@ files:
|
|
6145
6147
|
- tracks/python/exercises/grade-school/grade_school_test.py
|
6146
6148
|
- tracks/python/exercises/grains/example.py
|
6147
6149
|
- tracks/python/exercises/grains/grains_test.py
|
6150
|
+
- tracks/python/exercises/grep/example.py
|
6151
|
+
- tracks/python/exercises/grep/grep_test.py
|
6148
6152
|
- tracks/python/exercises/hamming/example.py
|
6149
6153
|
- tracks/python/exercises/hamming/hamming_test.py
|
6150
6154
|
- tracks/python/exercises/hello-world/example.py
|
@@ -6252,6 +6256,9 @@ files:
|
|
6252
6256
|
- tracks/python/exercises/twelve-days/twelve_days_test.py
|
6253
6257
|
- tracks/python/exercises/word-count/example.py
|
6254
6258
|
- tracks/python/exercises/word-count/word_count_test.py
|
6259
|
+
- tracks/python/exercises/word-search/example.py
|
6260
|
+
- tracks/python/exercises/word-search/word_search.py
|
6261
|
+
- tracks/python/exercises/word-search/word_search_test.py
|
6255
6262
|
- tracks/python/exercises/wordy/example.py
|
6256
6263
|
- tracks/python/exercises/wordy/wordy_test.py
|
6257
6264
|
- tracks/python/exercises/zebra-puzzle/example.py
|
@@ -7240,6 +7247,10 @@ files:
|
|
7240
7247
|
- tracks/scala/exercises/pascals-triangle/example.scala
|
7241
7248
|
- tracks/scala/exercises/pascals-triangle/src/main/scala/.keep
|
7242
7249
|
- tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala
|
7250
|
+
- tracks/scala/exercises/perfect-numbers/build.sbt
|
7251
|
+
- tracks/scala/exercises/perfect-numbers/example.scala
|
7252
|
+
- tracks/scala/exercises/perfect-numbers/src/main/scala/PerfectNumbers.scala
|
7253
|
+
- tracks/scala/exercises/perfect-numbers/src/test/scala/PerfectNumbersTest.scala
|
7243
7254
|
- tracks/scala/exercises/phone-number/HINTS.md
|
7244
7255
|
- tracks/scala/exercises/phone-number/build.sbt
|
7245
7256
|
- tracks/scala/exercises/phone-number/example.scala
|