trackler 2.0.7.0 → 2.0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/common/exercises/counter/metadata.yml +0 -4
- data/common/exercises/error-handling/metadata.yml +0 -4
- data/common/exercises/etl/canonical-data.json +1 -1
- data/common/exercises/hello-world/canonical-data.json +9 -21
- data/common/exercises/hello-world/description.md +7 -42
- data/common/exercises/hello-world/metadata.yml +1 -1
- data/common/exercises/lens-person/metadata.yml +0 -3
- data/common/exercises/luhn/canonical-data.json +17 -17
- data/common/exercises/nucleotide-codons/metadata.yml +0 -2
- data/common/exercises/react/metadata.yml +0 -2
- data/common/exercises/rectangles/metadata.yml +0 -3
- data/common/exercises/variable-length-quantity/metadata.yml +0 -2
- data/fixtures/tracks/snowflake/config.json +17 -0
- data/fixtures/tracks/snowflake/exercises/snowflake-only/description.md +1 -0
- data/fixtures/tracks/snowflake/exercises/snowflake-only/metadata.yml +4 -0
- data/lib/trackler/description.rb +27 -0
- data/lib/trackler/guaranteed_file.rb +77 -0
- data/lib/trackler/implementations.rb +5 -5
- data/lib/trackler/metadata.rb +27 -0
- data/lib/trackler/null_track.rb +22 -0
- data/lib/trackler/problem.rb +32 -34
- data/lib/trackler/track.rb +1 -1
- data/lib/trackler/version.rb +1 -1
- data/tracks/csharp/exercises/hello-world/Example.cs +2 -5
- data/tracks/csharp/exercises/hello-world/HelloWorldTest.cs +2 -16
- data/tracks/elixir/config.json +7 -0
- data/tracks/elixir/exercises/series/example.exs +13 -0
- data/tracks/elixir/exercises/series/series.exs +11 -0
- data/tracks/elixir/exercises/series/series_test.exs +53 -0
- data/tracks/erlang/README.md +3 -3
- data/tracks/erlang/config.json +15 -11
- data/tracks/erlang/exercises/{binary → all-your-base}/include/exercism.hrl +0 -0
- data/tracks/erlang/exercises/{binary → all-your-base}/rebar.config +0 -0
- data/tracks/erlang/exercises/{trinary/src/trinary.app.src → all-your-base/src/all_your_base.app.src} +2 -2
- data/tracks/erlang/exercises/all-your-base/src/example.erl +33 -0
- data/tracks/erlang/exercises/all-your-base/test/all_your_base_tests.erl +69 -0
- data/tracks/erlang/exercises/hello-world/src/example.erl +4 -4
- data/tracks/erlang/exercises/hello-world/test/hello_world_tests.erl +3 -12
- data/tracks/erlang/exercises/{trinary → rotational-cipher}/include/exercism.hrl +0 -0
- data/tracks/erlang/exercises/{trinary → rotational-cipher}/rebar.config +8 -1
- data/tracks/erlang/exercises/rotational-cipher/src/example.erl +19 -0
- data/tracks/erlang/exercises/{binary/src/binary.app.src → rotational-cipher/src/rotational_cipher.app.src} +2 -2
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +98 -0
- data/tracks/fsharp/exercises/grep/GrepTest.fs +57 -0
- data/tracks/fsharp/exercises/hello-world/Example.fs +1 -1
- data/tracks/fsharp/exercises/hello-world/HelloWorldTest.fs +2 -12
- data/tracks/go/.travis.yml +7 -15
- data/tracks/go/exercises/hello-world/example.go +4 -8
- data/tracks/go/exercises/hello-world/hello_test.go +20 -16
- data/tracks/go/exercises/hello-world/hello_world.go +12 -2
- data/tracks/groovy/exercises/hello-world/Example.groovy +2 -2
- data/tracks/groovy/exercises/hello-world/HelloWorld.groovy +1 -1
- data/tracks/groovy/exercises/hello-world/HelloWorldSpec.groovy +1 -14
- data/tracks/haskell/config.json +6 -0
- data/tracks/haskell/exercises/hello-world/HINTS.md +6 -0
- data/tracks/haskell/exercises/hello-world/examples/success-standard/package.yaml +16 -0
- data/tracks/haskell/exercises/hello-world/examples/success-standard/src/HelloWorld.hs +4 -0
- data/tracks/haskell/exercises/hello-world/package.yaml +19 -0
- data/tracks/haskell/exercises/hello-world/src/HelloWorld.hs +4 -0
- data/tracks/haskell/exercises/hello-world/stack.yaml +1 -0
- data/tracks/haskell/exercises/hello-world/test/Tests.hs +13 -0
- data/tracks/idris/config.json +9 -0
- data/tracks/idris/exercises/leap/Leap.ipkg +5 -0
- data/tracks/idris/exercises/leap/Makefile +23 -0
- data/tracks/idris/exercises/leap/src/Leap.idr +5 -0
- data/tracks/idris/exercises/leap/src/Test/Leap.idr +37 -0
- data/tracks/idris/exercises/leap/src/example.idr +8 -0
- data/tracks/{typescript/exercises → java}/.keep +0 -0
- data/tracks/java/config.json +115 -172
- data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +41 -13
- data/tracks/java/exercises/list-ops/build.gradle +18 -0
- data/tracks/java/exercises/list-ops/src/example/java/ListOps.java +51 -0
- data/tracks/java/exercises/list-ops/src/main/java/.keep +0 -0
- data/tracks/java/exercises/list-ops/src/test/java/ListOpsTest.java +316 -0
- data/tracks/java/exercises/palindrome-products/src/example/java/Palindromes.java +28 -62
- data/tracks/java/exercises/palindrome-products/src/test/java/PalindromesTest.java +26 -83
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/julia/config.json +1 -2
- data/tracks/julia/exercises/hello-world/example.jl +2 -2
- data/tracks/julia/exercises/hello-world/runtests.jl +1 -6
- data/tracks/lua/exercises/TRACK_HINTS.md +8 -0
- data/tracks/lua/exercises/hello-world/example.lua +2 -3
- data/tracks/lua/exercises/hello-world/hello-world.lua +18 -0
- data/tracks/lua/exercises/hello-world/hello-world_spec.lua +6 -12
- data/tracks/ocaml/exercises/phone-number/example.ml +8 -18
- data/tracks/ocaml/exercises/phone-number/phone_number.mli +1 -7
- data/tracks/ocaml/exercises/phone-number/test.ml +24 -23
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +6 -0
- data/tracks/ocaml/tools/test-generator/templates/phone-number/template.ml +21 -0
- data/tracks/pony/config.json +2 -2
- data/tracks/pony/exercises/hello-world/example.pony +1 -2
- data/tracks/pony/exercises/hello-world/test.pony +0 -1
- data/tracks/rust/config.json +0 -1
- data/tracks/rust/exercises/hello-world/example.rs +2 -5
- data/tracks/rust/exercises/hello-world/tests/hello-world.rs +2 -14
- data/tracks/scala/config.json +11 -2
- data/tracks/scala/docs/LEARNING.md +10 -2
- data/tracks/scala/docs/RESOURCES.md +0 -1
- data/tracks/scala/docs/TESTS.md +10 -6
- data/tracks/scala/exercises/rail-fence-cipher/build.sbt +3 -0
- data/tracks/scala/exercises/rail-fence-cipher/example.scala +46 -0
- data/tracks/scala/exercises/rail-fence-cipher/src/main/scala/RailFenceCipher.scala +0 -0
- data/tracks/scala/exercises/rail-fence-cipher/src/test/scala/RailFenceCipherTest.scala +42 -0
- data/tracks/scala/testgen/src/main/scala/RailFenceCipherTestGenerator.scala +59 -0
- data/tracks/typescript/.gitignore +7 -0
- data/tracks/typescript/.travis.yml +18 -1
- data/tracks/typescript/Dangerfile +43 -0
- data/tracks/typescript/Makefile +57 -0
- data/tracks/typescript/README.md +38 -5
- data/tracks/typescript/SETUP.md +24 -0
- data/tracks/typescript/common/package.json +37 -0
- data/tracks/typescript/common/tsconfig.json +21 -0
- data/tracks/typescript/common/tslint.json +127 -0
- data/tracks/typescript/common/yarn.lock +2697 -0
- data/tracks/typescript/config.json +82 -2
- data/tracks/typescript/docs/ABOUT.md +1 -0
- data/tracks/typescript/docs/INSTALLATION.md +17 -0
- data/tracks/typescript/docs/LEARNING.md +8 -0
- data/tracks/typescript/docs/RESOURCES.md +7 -0
- data/tracks/typescript/docs/TESTS.md +36 -0
- data/tracks/typescript/exercises/anagram/anagram.example.ts +23 -0
- data/tracks/typescript/exercises/anagram/anagram.test.ts +82 -0
- data/tracks/typescript/exercises/anagram/package.json +37 -0
- data/tracks/typescript/exercises/anagram/tsconfig.json +21 -0
- data/tracks/typescript/exercises/anagram/tslint.json +127 -0
- data/tracks/typescript/exercises/anagram/yarn.lock +2697 -0
- data/tracks/typescript/exercises/beer-song/beer-song.example.ts +36 -0
- data/tracks/typescript/exercises/beer-song/beer-song.test.ts +360 -0
- data/tracks/typescript/exercises/beer-song/package.json +37 -0
- data/tracks/typescript/exercises/beer-song/tsconfig.json +21 -0
- data/tracks/typescript/exercises/beer-song/tslint.json +127 -0
- data/tracks/typescript/exercises/beer-song/yarn.lock +2697 -0
- data/tracks/typescript/exercises/bob/bob.example.ts +24 -0
- data/tracks/typescript/exercises/bob/bob.test.ts +92 -0
- data/tracks/typescript/exercises/bob/package.json +37 -0
- data/tracks/typescript/exercises/bob/tsconfig.json +21 -0
- data/tracks/typescript/exercises/bob/tslint.json +127 -0
- data/tracks/typescript/exercises/bob/yarn.lock +2697 -0
- data/tracks/typescript/exercises/gigasecond/gigasecond.example.ts +11 -0
- data/tracks/typescript/exercises/gigasecond/gigasecond.test.ts +29 -0
- data/tracks/typescript/exercises/gigasecond/package.json +37 -0
- data/tracks/typescript/exercises/gigasecond/tsconfig.json +21 -0
- data/tracks/typescript/exercises/gigasecond/tslint.json +127 -0
- data/tracks/typescript/exercises/gigasecond/yarn.lock +2697 -0
- data/tracks/typescript/exercises/hamming/hamming.example.ts +19 -0
- data/tracks/typescript/exercises/hamming/hamming.test.ts +39 -0
- data/tracks/typescript/exercises/hamming/package.json +37 -0
- data/tracks/typescript/exercises/hamming/tsconfig.json +21 -0
- data/tracks/typescript/exercises/hamming/tslint.json +127 -0
- data/tracks/typescript/exercises/hamming/yarn.lock +2697 -0
- data/tracks/typescript/exercises/hello-world/hello-world.example.ts +8 -0
- data/tracks/typescript/exercises/hello-world/hello-world.test.ts +17 -0
- data/tracks/typescript/exercises/hello-world/package.json +37 -0
- data/tracks/typescript/exercises/hello-world/tsconfig.json +21 -0
- data/tracks/typescript/exercises/hello-world/tslint.json +127 -0
- data/tracks/typescript/exercises/hello-world/yarn.lock +2697 -0
- data/tracks/typescript/exercises/leap/leap.example.ts +6 -0
- data/tracks/typescript/exercises/leap/leap.test.ts +39 -0
- data/tracks/typescript/exercises/leap/package.json +37 -0
- data/tracks/typescript/exercises/leap/tsconfig.json +21 -0
- data/tracks/typescript/exercises/leap/tslint.json +127 -0
- data/tracks/typescript/exercises/leap/yarn.lock +2697 -0
- data/tracks/typescript/exercises/pangram/package.json +37 -0
- data/tracks/typescript/exercises/pangram/pangram.example.ts +32 -0
- data/tracks/typescript/exercises/pangram/pangram.test.ts +50 -0
- data/tracks/typescript/exercises/pangram/tsconfig.json +21 -0
- data/tracks/typescript/exercises/pangram/tslint.json +127 -0
- data/tracks/typescript/exercises/pangram/yarn.lock +2697 -0
- data/tracks/typescript/exercises/phone-number/package.json +37 -0
- data/tracks/typescript/exercises/phone-number/phone-number.example.ts +21 -0
- data/tracks/typescript/exercises/phone-number/phone-number.test.ts +55 -0
- data/tracks/typescript/exercises/phone-number/tsconfig.json +21 -0
- data/tracks/typescript/exercises/phone-number/tslint.json +127 -0
- data/tracks/typescript/exercises/phone-number/yarn.lock +2697 -0
- data/tracks/typescript/exercises/rna-transcription/package.json +37 -0
- data/tracks/typescript/exercises/rna-transcription/rna-transcription.example.ts +13 -0
- data/tracks/typescript/exercises/rna-transcription/rna-transcription.test.ts +45 -0
- data/tracks/typescript/exercises/rna-transcription/tsconfig.json +21 -0
- data/tracks/typescript/exercises/rna-transcription/tslint.json +127 -0
- data/tracks/typescript/exercises/rna-transcription/yarn.lock +2697 -0
- data/tracks/typescript/exercises/say/package.json +37 -0
- data/tracks/typescript/exercises/say/say.example.ts +95 -0
- data/tracks/typescript/exercises/say/say.test.ts +78 -0
- data/tracks/typescript/exercises/say/tsconfig.json +21 -0
- data/tracks/typescript/exercises/say/tslint.json +127 -0
- data/tracks/typescript/exercises/say/yarn.lock +2697 -0
- data/tracks/typescript/exercises/word-count/package.json +37 -0
- data/tracks/typescript/exercises/word-count/tsconfig.json +21 -0
- data/tracks/typescript/exercises/word-count/tslint.json +127 -0
- data/tracks/typescript/exercises/word-count/word-count.example.ts +16 -0
- data/tracks/typescript/exercises/word-count/word-count.test.ts +65 -0
- data/tracks/typescript/exercises/word-count/yarn.lock +2697 -0
- data/tracks/typescript/exercises/wordy/package.json +37 -0
- data/tracks/typescript/exercises/wordy/tsconfig.json +21 -0
- data/tracks/typescript/exercises/wordy/tslint.json +127 -0
- data/tracks/typescript/exercises/wordy/wordy.example.ts +40 -0
- data/tracks/typescript/exercises/wordy/wordy.test.ts +89 -0
- data/tracks/typescript/exercises/wordy/yarn.lock +2697 -0
- data/tracks/typescript/img/icon.png +0 -0
- data/tracks/typescript/img/icon.svg +10 -0
- metadata +134 -15
- data/tracks/erlang/exercises/binary/src/example.erl +0 -20
- data/tracks/erlang/exercises/binary/test/binary_string_tests.erl +0 -26
- data/tracks/erlang/exercises/trinary/Makefile +0 -10
- data/tracks/erlang/exercises/trinary/src/example.erl +0 -66
- data/tracks/erlang/exercises/trinary/test/trinary_tests.erl +0 -36
- data/tracks/fsharp/exercises/hello-world/HINTS.md +0 -5
@@ -0,0 +1,22 @@
|
|
1
|
+
module Trackler
|
2
|
+
class NullTrack < BasicObject
|
3
|
+
def method_missing(*)
|
4
|
+
# NOOP
|
5
|
+
end
|
6
|
+
|
7
|
+
def respond_to?(*)
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
"<null>"
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
""
|
17
|
+
end
|
18
|
+
|
19
|
+
klass = self
|
20
|
+
define_method(:class) { klass }
|
21
|
+
end
|
22
|
+
end
|
data/lib/trackler/problem.rb
CHANGED
@@ -1,20 +1,28 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require_relative 'metadata'
|
3
|
+
require_relative 'description'
|
4
|
+
require_relative 'null_track'
|
2
5
|
|
3
6
|
module Trackler
|
4
7
|
# Problem is a language-independent definition of an exercise.
|
5
8
|
class Problem
|
6
|
-
attr_reader :slug, :root
|
7
|
-
def initialize(slug, root)
|
9
|
+
attr_reader :slug, :root, :metadata
|
10
|
+
def initialize(slug, root, track = NullTrack.new)
|
8
11
|
@slug = slug
|
9
12
|
@root = root
|
13
|
+
@file_root = File.join(root, 'common', 'exercises', self.slug)
|
14
|
+
@repo_root = "https://github.com/exercism/x-common/blob/master/exercises/%s/" % self.slug
|
15
|
+
|
16
|
+
@metadata = Metadata.for(problem: self, track: track)
|
17
|
+
self.description_object = Description.for(problem: self, track: track)
|
10
18
|
end
|
11
19
|
|
12
20
|
def exists?
|
13
|
-
|
21
|
+
description_object.exists? && metadata.exists?
|
14
22
|
end
|
15
23
|
|
16
24
|
def deprecated?
|
17
|
-
@deprecated ||= File.exists?(
|
25
|
+
@deprecated ||= File.exists?(file_path(deprecation_file_name, @file_root))
|
18
26
|
end
|
19
27
|
|
20
28
|
def active?
|
@@ -26,11 +34,7 @@ module Trackler
|
|
26
34
|
end
|
27
35
|
|
28
36
|
def description
|
29
|
-
|
30
|
-
filename = common_metadata_path(description_path)
|
31
|
-
if File.exists?(filename)
|
32
|
-
@description = File.read(filename)
|
33
|
-
end
|
37
|
+
description_object.to_s
|
34
38
|
end
|
35
39
|
|
36
40
|
def source_markdown
|
@@ -60,61 +64,55 @@ module Trackler
|
|
60
64
|
######
|
61
65
|
|
62
66
|
def description_url
|
63
|
-
|
67
|
+
description_object.url
|
64
68
|
end
|
65
69
|
|
66
70
|
def canonical_data_url
|
67
|
-
repo_url(
|
71
|
+
repo_url(canonical_data_file_name) if File.exists?(file_path(canonical_data_file_name, @file_root))
|
68
72
|
end
|
69
73
|
|
70
74
|
def metadata_url
|
71
|
-
|
75
|
+
metadata.url
|
72
76
|
end
|
73
77
|
|
74
78
|
def blurb
|
75
|
-
metadata
|
79
|
+
metadata.blurb
|
76
80
|
end
|
77
81
|
|
78
82
|
def source
|
79
|
-
metadata
|
83
|
+
metadata.source
|
80
84
|
end
|
81
85
|
|
82
86
|
def source_url
|
83
|
-
metadata
|
87
|
+
metadata.source_url
|
84
88
|
end
|
85
89
|
|
86
90
|
private
|
87
91
|
|
88
|
-
|
89
|
-
"exercises/%s/canonical-data.json" % slug
|
90
|
-
end
|
92
|
+
attr_accessor :description_object
|
91
93
|
|
92
|
-
def
|
93
|
-
"
|
94
|
+
def canonical_data_file_name
|
95
|
+
"canonical-data.json"
|
94
96
|
end
|
95
97
|
|
96
|
-
def
|
97
|
-
"
|
98
|
+
def description_file_name
|
99
|
+
"description.md"
|
98
100
|
end
|
99
101
|
|
100
|
-
def
|
101
|
-
"
|
102
|
+
def metadata_file_name
|
103
|
+
"metadata.yml"
|
102
104
|
end
|
103
105
|
|
104
|
-
def
|
105
|
-
"
|
106
|
+
def deprecation_file_name
|
107
|
+
".deprecated"
|
106
108
|
end
|
107
109
|
|
108
|
-
def
|
109
|
-
|
110
|
-
filename = common_metadata_path(metadata_path)
|
111
|
-
if File.exists?(filename)
|
112
|
-
@metadata = YAML.load(File.read(filename))
|
113
|
-
end
|
110
|
+
def repo_url(filename)
|
111
|
+
@repo_root + filename
|
114
112
|
end
|
115
113
|
|
116
|
-
def
|
117
|
-
File.join(root,
|
114
|
+
def file_path(filename, root = @file_root)
|
115
|
+
File.join(root, filename)
|
118
116
|
end
|
119
117
|
|
120
118
|
def markdown_link(url)
|
data/lib/trackler/track.rb
CHANGED
data/lib/trackler/version.rb
CHANGED
@@ -4,22 +4,8 @@
|
|
4
4
|
public class HelloWorldTest
|
5
5
|
{
|
6
6
|
[Test]
|
7
|
-
public void
|
7
|
+
public void Say_hi()
|
8
8
|
{
|
9
|
-
Assert.That(HelloWorld.Hello(
|
10
|
-
}
|
11
|
-
|
12
|
-
[Ignore("Remove to run test")]
|
13
|
-
[Test]
|
14
|
-
public void Sample_name()
|
15
|
-
{
|
16
|
-
Assert.That(HelloWorld.Hello("Alice"), Is.EqualTo("Hello, Alice!"));
|
17
|
-
}
|
18
|
-
|
19
|
-
[Ignore("Remove to run test")]
|
20
|
-
[Test]
|
21
|
-
public void Other_sample_name()
|
22
|
-
{
|
23
|
-
Assert.That(HelloWorld.Hello("Bob"), Is.EqualTo("Hello, Bob!"));
|
9
|
+
Assert.That(HelloWorld.Hello(), Is.EqualTo("Hello, World!"));
|
24
10
|
}
|
25
11
|
}
|
data/tracks/elixir/config.json
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
defmodule StringSeries do
|
2
|
+
@doc """
|
3
|
+
Given a string `s` and a positive integer `size`, return all substrings
|
4
|
+
of that size. If `size` is greater than the length of `s`, or less than 1,
|
5
|
+
return an empty list.
|
6
|
+
"""
|
7
|
+
@spec slices(s :: String.t(), size :: integer) :: list(String.t())
|
8
|
+
def slices(_s, size) when size < 1, do: []
|
9
|
+
def slices(s, size) do
|
10
|
+
s |> String.graphemes |> Enum.chunk(size, 1) |> Enum.map(&Enum.join/1)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
defmodule StringSeries do
|
2
|
+
@doc """
|
3
|
+
Given a string `s` and a positive integer `size`, return all substrings
|
4
|
+
of that size. If `size` is greater than the length of `s`, or less than 1,
|
5
|
+
return an empty list.
|
6
|
+
"""
|
7
|
+
@spec slices(s :: String.t(), size :: integer) :: list(String.t())
|
8
|
+
def slices(_s, _size) do
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
2
|
+
Code.load_file("series.exs", __DIR__)
|
3
|
+
end
|
4
|
+
|
5
|
+
ExUnit.start
|
6
|
+
ExUnit.configure exclude: :pending, trace: true
|
7
|
+
|
8
|
+
defmodule StringSeriesTest do
|
9
|
+
use ExUnit.Case
|
10
|
+
|
11
|
+
#@tag :pending
|
12
|
+
test "slices of size 1" do
|
13
|
+
assert StringSeries.slices("01234", 1) == ["0", "1", "2", "3", "4"]
|
14
|
+
end
|
15
|
+
|
16
|
+
@tag :pending
|
17
|
+
test "slices of size 2" do
|
18
|
+
assert StringSeries.slices("01234", 2) == ["01", "12", "23", "34"]
|
19
|
+
end
|
20
|
+
|
21
|
+
@tag :pending
|
22
|
+
test "slices of size 3" do
|
23
|
+
assert StringSeries.slices("01234", 3) == ["012", "123", "234"]
|
24
|
+
end
|
25
|
+
|
26
|
+
@tag :pending
|
27
|
+
test "slices of size 4" do
|
28
|
+
assert StringSeries.slices("01234", 4) == ["0123", "1234"]
|
29
|
+
end
|
30
|
+
|
31
|
+
@tag :pending
|
32
|
+
test "slices same size as string" do
|
33
|
+
assert StringSeries.slices("01234", 5) == ["01234"]
|
34
|
+
end
|
35
|
+
|
36
|
+
@tag :pending
|
37
|
+
test "Unicode characters count as a single character" do
|
38
|
+
assert StringSeries.slices("José", 1) == ["J", "o", "s", "é"]
|
39
|
+
assert StringSeries.slices("José", 2) == ["Jo", "os", "sé"]
|
40
|
+
end
|
41
|
+
|
42
|
+
@tag :pending
|
43
|
+
test "slices with size longer than string return empty list" do
|
44
|
+
assert StringSeries.slices("01234", 6) == []
|
45
|
+
end
|
46
|
+
|
47
|
+
@tag :pending
|
48
|
+
test "slices with size zero or negative return empty list" do
|
49
|
+
assert StringSeries.slices("01234", -1) == []
|
50
|
+
assert StringSeries.slices("01234", 0) == []
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
data/tracks/erlang/README.md
CHANGED
@@ -9,7 +9,7 @@ Exercism exercises in Erlang
|
|
9
9
|
For general information about how exercism works, please see the
|
10
10
|
[contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data).
|
11
11
|
|
12
|
-
###
|
12
|
+
### Setting up your system for local development on the track
|
13
13
|
|
14
14
|
Please make sure you have installed erlang/OTP and `rebar3` as
|
15
15
|
described on [Installing Erlang](http://exercism.io/languages/erlang/installing)
|
@@ -41,7 +41,7 @@ compatible with erlang syntax.
|
|
41
41
|
3.3. Change the old erlangified_slug_name on the first line to the new one.
|
42
42
|
3.4. Change the old slug-name on the second line to the new one.
|
43
43
|
3.5. Leave `include/exercism.hrl` untouched.
|
44
|
-
4. Create a testfile/-module in `test`-folder. It is
|
44
|
+
4. Create a testfile/-module in `test`-folder. It is preferred to name
|
45
45
|
it after the erlangified_slug_name and insert the boilerplate code
|
46
46
|
shown below.
|
47
47
|
5. Implement your example in `src/example.erl` and use `example` as
|
@@ -80,7 +80,7 @@ Please make sure, that all tests pass by running
|
|
80
80
|
`escript _test/check-exercises.escript`. Also a run of `bin/configlet`
|
81
81
|
should pass without error message.
|
82
82
|
|
83
|
-
Both
|
83
|
+
Both programs will be run on Travis and a merge is unlikely when
|
84
84
|
tests fail.
|
85
85
|
|
86
86
|
## License
|
data/tracks/erlang/config.json
CHANGED
@@ -84,21 +84,11 @@
|
|
84
84
|
"topics": [],
|
85
85
|
"difficulty": 3
|
86
86
|
},
|
87
|
-
{
|
88
|
-
"slug": "binary",
|
89
|
-
"topics": [],
|
90
|
-
"difficulty": 3
|
91
|
-
},
|
92
87
|
{
|
93
88
|
"slug": "gigasecond",
|
94
89
|
"topics": [],
|
95
90
|
"difficulty": 3
|
96
91
|
},
|
97
|
-
{
|
98
|
-
"slug": "trinary",
|
99
|
-
"topics": [],
|
100
|
-
"difficulty": 3
|
101
|
-
},
|
102
92
|
{
|
103
93
|
"slug": "scrabble-score",
|
104
94
|
"topics": [],
|
@@ -129,6 +119,11 @@
|
|
129
119
|
"topics": [],
|
130
120
|
"difficulty": 4
|
131
121
|
},
|
122
|
+
{
|
123
|
+
"slug": "all-your-base",
|
124
|
+
"topics": [],
|
125
|
+
"difficulty": 4
|
126
|
+
},
|
132
127
|
{
|
133
128
|
"slug": "series",
|
134
129
|
"topics": [],
|
@@ -149,6 +144,11 @@
|
|
149
144
|
"topics": [],
|
150
145
|
"difficulty": 5
|
151
146
|
},
|
147
|
+
{
|
148
|
+
"slug": "rotational-cipher",
|
149
|
+
"topics": [],
|
150
|
+
"difficulty": 5
|
151
|
+
},
|
152
152
|
{
|
153
153
|
"slug": "etl",
|
154
154
|
"topics": [],
|
@@ -186,7 +186,11 @@
|
|
186
186
|
}
|
187
187
|
],
|
188
188
|
"deprecated": [
|
189
|
-
"point-mutations"
|
189
|
+
"point-mutations",
|
190
|
+
"binary",
|
191
|
+
"trinary",
|
192
|
+
"octal",
|
193
|
+
"hexadecimal"
|
190
194
|
],
|
191
195
|
"ignored": [
|
192
196
|
"docs",
|
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
-module(example).
|
2
|
+
-export([convert/3, test_version/0]).
|
3
|
+
|
4
|
+
convert(_Input, SrcBase, _DstBase) when SrcBase < 2 ->
|
5
|
+
{error, invalid_src_base};
|
6
|
+
convert(_Input, _SrcBase, DstBase) when DstBase < 2 ->
|
7
|
+
{error, invalid_dst_base};
|
8
|
+
convert(Input, SrcBase, DstBase) ->
|
9
|
+
case internalize(Input, SrcBase, 0) of
|
10
|
+
{ok, Value} -> externalize(Value, DstBase, []);
|
11
|
+
{error, Reason} -> {error, Reason}
|
12
|
+
end.
|
13
|
+
|
14
|
+
test_version() ->
|
15
|
+
1.
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
internalize([], _, Acc) ->
|
20
|
+
{ok, Acc};
|
21
|
+
internalize([H|_], _Base, _Acc) when H < 0 ->
|
22
|
+
{error, negative};
|
23
|
+
internalize([H|_], Base, _Acc) when H >= Base ->
|
24
|
+
{error, not_in_base};
|
25
|
+
internalize([H|T], Base, Acc) ->
|
26
|
+
internalize(T, Base, Acc * Base + H).
|
27
|
+
|
28
|
+
externalize(0, _Base, Acc) ->
|
29
|
+
{ok, Acc};
|
30
|
+
externalize(Input, Base, Acc) ->
|
31
|
+
Digit = Input rem Base,
|
32
|
+
Input2 = Input div Base,
|
33
|
+
externalize(Input2, Base, [Digit|Acc]).
|
@@ -0,0 +1,69 @@
|
|
1
|
+
-module(all_your_base_tests).
|
2
|
+
|
3
|
+
-define(TESTED_MODULE, (sut(all_your_base))).
|
4
|
+
-define(TEST_VERSION, 1).
|
5
|
+
-include("exercism.hrl").
|
6
|
+
|
7
|
+
single_bit_one_to_decimal_test() ->
|
8
|
+
?assertMatch({ok, [1]}, ?TESTED_MODULE:convert([1], 2, 10)).
|
9
|
+
|
10
|
+
binary_to_single_decimal_test() ->
|
11
|
+
?assertMatch({ok, [5]}, ?TESTED_MODULE:convert([1, 0, 1], 2, 10)).
|
12
|
+
|
13
|
+
single_decimal_to_binary_test() ->
|
14
|
+
?assertMatch({ok, [1, 0, 1]}, ?TESTED_MODULE:convert([5], 10, 2)).
|
15
|
+
|
16
|
+
binary_to_multiple_decimal_test() ->
|
17
|
+
?assertMatch({ok, [4, 2]}, ?TESTED_MODULE:convert([1, 0, 1, 0, 1, 0], 2, 10)).
|
18
|
+
|
19
|
+
decimal_to_binary_test() ->
|
20
|
+
?assertMatch({ok, [1, 0, 1, 0, 1, 0]}, ?TESTED_MODULE:convert([4, 2], 10, 2)).
|
21
|
+
|
22
|
+
trinary_to_hexadecimal_test() ->
|
23
|
+
?assertMatch({ok, [2, 10]}, ?TESTED_MODULE:convert([1, 1, 2, 0], 3, 16)).
|
24
|
+
|
25
|
+
hexadecimal_to_trinary_test() ->
|
26
|
+
?assertMatch({ok, [1, 1, 2, 0]}, ?TESTED_MODULE:convert([2, 10], 16, 3)).
|
27
|
+
|
28
|
+
fifteen_bit_integer_test() ->
|
29
|
+
?assertMatch({ok, [6,10,45]}, ?TESTED_MODULE:convert([3,46,60], 97, 73)).
|
30
|
+
|
31
|
+
empty_list_test() ->
|
32
|
+
?assertMatch({ok, []}, ?TESTED_MODULE:convert([], 2, 10)).
|
33
|
+
|
34
|
+
single_zero_test() ->
|
35
|
+
?assertMatch({ok, []}, ?TESTED_MODULE:convert([0], 10, 2)).
|
36
|
+
|
37
|
+
multiple_zero_test() ->
|
38
|
+
?assertMatch({ok, []}, ?TESTED_MODULE:convert([0, 0, 0], 10, 2)).
|
39
|
+
|
40
|
+
leading_zero_test() ->
|
41
|
+
?assertMatch({ok, [4, 2]}, ?TESTED_MODULE:convert([0, 6, 0], 7, 10)).
|
42
|
+
|
43
|
+
negative_digit_test() ->
|
44
|
+
?assertMatch({error, negative}, ?TESTED_MODULE:convert([1, -1, 1, 0, 1, 0], 2, 10)).
|
45
|
+
|
46
|
+
invalid_positiv_digit_test() ->
|
47
|
+
?assertMatch({error, not_in_base}, ?TESTED_MODULE:convert([1, 2, 1, 0, 1, 0], 2, 10)).
|
48
|
+
|
49
|
+
first_base_is_one_test() ->
|
50
|
+
?assertMatch({error, invalid_src_base}, ?TESTED_MODULE:convert([], 1, 10)).
|
51
|
+
|
52
|
+
second_base_is_one_test() ->
|
53
|
+
?assertMatch({error, invalid_dst_base}, ?TESTED_MODULE:convert([1, 0, 1, 0, 1, 0], 2, 1)).
|
54
|
+
|
55
|
+
first_base_is_zero_test() ->
|
56
|
+
?assertMatch({error, invalid_src_base}, ?TESTED_MODULE:convert([], 0, 10)).
|
57
|
+
|
58
|
+
second_base_is_zero_test() ->
|
59
|
+
?assertMatch({error, invalid_dst_base}, ?TESTED_MODULE:convert([7], 10, 0)).
|
60
|
+
|
61
|
+
first_base_is_negative_test() ->
|
62
|
+
?assertMatch({error, invalid_src_base}, ?TESTED_MODULE:convert([1], -2, 10)).
|
63
|
+
|
64
|
+
second_base_is_negative_test() ->
|
65
|
+
?assertMatch({error, invalid_dst_base}, ?TESTED_MODULE:convert([1], 2, -7)).
|
66
|
+
|
67
|
+
both_bases_are_negative_test() ->
|
68
|
+
{error, Reason} = ?TESTED_MODULE:convert([1], -2, -7),
|
69
|
+
?assert(lists:member(Reason, [invalid_dst_base, invalid_src_base])).
|