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.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/common/exercises/counter/metadata.yml +0 -4
  4. data/common/exercises/error-handling/metadata.yml +0 -4
  5. data/common/exercises/etl/canonical-data.json +1 -1
  6. data/common/exercises/hello-world/canonical-data.json +9 -21
  7. data/common/exercises/hello-world/description.md +7 -42
  8. data/common/exercises/hello-world/metadata.yml +1 -1
  9. data/common/exercises/lens-person/metadata.yml +0 -3
  10. data/common/exercises/luhn/canonical-data.json +17 -17
  11. data/common/exercises/nucleotide-codons/metadata.yml +0 -2
  12. data/common/exercises/react/metadata.yml +0 -2
  13. data/common/exercises/rectangles/metadata.yml +0 -3
  14. data/common/exercises/variable-length-quantity/metadata.yml +0 -2
  15. data/fixtures/tracks/snowflake/config.json +17 -0
  16. data/fixtures/tracks/snowflake/exercises/snowflake-only/description.md +1 -0
  17. data/fixtures/tracks/snowflake/exercises/snowflake-only/metadata.yml +4 -0
  18. data/lib/trackler/description.rb +27 -0
  19. data/lib/trackler/guaranteed_file.rb +77 -0
  20. data/lib/trackler/implementations.rb +5 -5
  21. data/lib/trackler/metadata.rb +27 -0
  22. data/lib/trackler/null_track.rb +22 -0
  23. data/lib/trackler/problem.rb +32 -34
  24. data/lib/trackler/track.rb +1 -1
  25. data/lib/trackler/version.rb +1 -1
  26. data/tracks/csharp/exercises/hello-world/Example.cs +2 -5
  27. data/tracks/csharp/exercises/hello-world/HelloWorldTest.cs +2 -16
  28. data/tracks/elixir/config.json +7 -0
  29. data/tracks/elixir/exercises/series/example.exs +13 -0
  30. data/tracks/elixir/exercises/series/series.exs +11 -0
  31. data/tracks/elixir/exercises/series/series_test.exs +53 -0
  32. data/tracks/erlang/README.md +3 -3
  33. data/tracks/erlang/config.json +15 -11
  34. data/tracks/erlang/exercises/{binary → all-your-base}/include/exercism.hrl +0 -0
  35. data/tracks/erlang/exercises/{binary → all-your-base}/rebar.config +0 -0
  36. data/tracks/erlang/exercises/{trinary/src/trinary.app.src → all-your-base/src/all_your_base.app.src} +2 -2
  37. data/tracks/erlang/exercises/all-your-base/src/example.erl +33 -0
  38. data/tracks/erlang/exercises/all-your-base/test/all_your_base_tests.erl +69 -0
  39. data/tracks/erlang/exercises/hello-world/src/example.erl +4 -4
  40. data/tracks/erlang/exercises/hello-world/test/hello_world_tests.erl +3 -12
  41. data/tracks/erlang/exercises/{trinary → rotational-cipher}/include/exercism.hrl +0 -0
  42. data/tracks/erlang/exercises/{trinary → rotational-cipher}/rebar.config +8 -1
  43. data/tracks/erlang/exercises/rotational-cipher/src/example.erl +19 -0
  44. data/tracks/erlang/exercises/{binary/src/binary.app.src → rotational-cipher/src/rotational_cipher.app.src} +2 -2
  45. data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +98 -0
  46. data/tracks/fsharp/exercises/grep/GrepTest.fs +57 -0
  47. data/tracks/fsharp/exercises/hello-world/Example.fs +1 -1
  48. data/tracks/fsharp/exercises/hello-world/HelloWorldTest.fs +2 -12
  49. data/tracks/go/.travis.yml +7 -15
  50. data/tracks/go/exercises/hello-world/example.go +4 -8
  51. data/tracks/go/exercises/hello-world/hello_test.go +20 -16
  52. data/tracks/go/exercises/hello-world/hello_world.go +12 -2
  53. data/tracks/groovy/exercises/hello-world/Example.groovy +2 -2
  54. data/tracks/groovy/exercises/hello-world/HelloWorld.groovy +1 -1
  55. data/tracks/groovy/exercises/hello-world/HelloWorldSpec.groovy +1 -14
  56. data/tracks/haskell/config.json +6 -0
  57. data/tracks/haskell/exercises/hello-world/HINTS.md +6 -0
  58. data/tracks/haskell/exercises/hello-world/examples/success-standard/package.yaml +16 -0
  59. data/tracks/haskell/exercises/hello-world/examples/success-standard/src/HelloWorld.hs +4 -0
  60. data/tracks/haskell/exercises/hello-world/package.yaml +19 -0
  61. data/tracks/haskell/exercises/hello-world/src/HelloWorld.hs +4 -0
  62. data/tracks/haskell/exercises/hello-world/stack.yaml +1 -0
  63. data/tracks/haskell/exercises/hello-world/test/Tests.hs +13 -0
  64. data/tracks/idris/config.json +9 -0
  65. data/tracks/idris/exercises/leap/Leap.ipkg +5 -0
  66. data/tracks/idris/exercises/leap/Makefile +23 -0
  67. data/tracks/idris/exercises/leap/src/Leap.idr +5 -0
  68. data/tracks/idris/exercises/leap/src/Test/Leap.idr +37 -0
  69. data/tracks/idris/exercises/leap/src/example.idr +8 -0
  70. data/tracks/{typescript/exercises → java}/.keep +0 -0
  71. data/tracks/java/config.json +115 -172
  72. data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +41 -13
  73. data/tracks/java/exercises/list-ops/build.gradle +18 -0
  74. data/tracks/java/exercises/list-ops/src/example/java/ListOps.java +51 -0
  75. data/tracks/java/exercises/list-ops/src/main/java/.keep +0 -0
  76. data/tracks/java/exercises/list-ops/src/test/java/ListOpsTest.java +316 -0
  77. data/tracks/java/exercises/palindrome-products/src/example/java/Palindromes.java +28 -62
  78. data/tracks/java/exercises/palindrome-products/src/test/java/PalindromesTest.java +26 -83
  79. data/tracks/java/exercises/settings.gradle +1 -0
  80. data/tracks/julia/config.json +1 -2
  81. data/tracks/julia/exercises/hello-world/example.jl +2 -2
  82. data/tracks/julia/exercises/hello-world/runtests.jl +1 -6
  83. data/tracks/lua/exercises/TRACK_HINTS.md +8 -0
  84. data/tracks/lua/exercises/hello-world/example.lua +2 -3
  85. data/tracks/lua/exercises/hello-world/hello-world.lua +18 -0
  86. data/tracks/lua/exercises/hello-world/hello-world_spec.lua +6 -12
  87. data/tracks/ocaml/exercises/phone-number/example.ml +8 -18
  88. data/tracks/ocaml/exercises/phone-number/phone_number.mli +1 -7
  89. data/tracks/ocaml/exercises/phone-number/test.ml +24 -23
  90. data/tracks/ocaml/tools/test-generator/src/special_cases.ml +6 -0
  91. data/tracks/ocaml/tools/test-generator/templates/phone-number/template.ml +21 -0
  92. data/tracks/pony/config.json +2 -2
  93. data/tracks/pony/exercises/hello-world/example.pony +1 -2
  94. data/tracks/pony/exercises/hello-world/test.pony +0 -1
  95. data/tracks/rust/config.json +0 -1
  96. data/tracks/rust/exercises/hello-world/example.rs +2 -5
  97. data/tracks/rust/exercises/hello-world/tests/hello-world.rs +2 -14
  98. data/tracks/scala/config.json +11 -2
  99. data/tracks/scala/docs/LEARNING.md +10 -2
  100. data/tracks/scala/docs/RESOURCES.md +0 -1
  101. data/tracks/scala/docs/TESTS.md +10 -6
  102. data/tracks/scala/exercises/rail-fence-cipher/build.sbt +3 -0
  103. data/tracks/scala/exercises/rail-fence-cipher/example.scala +46 -0
  104. data/tracks/scala/exercises/rail-fence-cipher/src/main/scala/RailFenceCipher.scala +0 -0
  105. data/tracks/scala/exercises/rail-fence-cipher/src/test/scala/RailFenceCipherTest.scala +42 -0
  106. data/tracks/scala/testgen/src/main/scala/RailFenceCipherTestGenerator.scala +59 -0
  107. data/tracks/typescript/.gitignore +7 -0
  108. data/tracks/typescript/.travis.yml +18 -1
  109. data/tracks/typescript/Dangerfile +43 -0
  110. data/tracks/typescript/Makefile +57 -0
  111. data/tracks/typescript/README.md +38 -5
  112. data/tracks/typescript/SETUP.md +24 -0
  113. data/tracks/typescript/common/package.json +37 -0
  114. data/tracks/typescript/common/tsconfig.json +21 -0
  115. data/tracks/typescript/common/tslint.json +127 -0
  116. data/tracks/typescript/common/yarn.lock +2697 -0
  117. data/tracks/typescript/config.json +82 -2
  118. data/tracks/typescript/docs/ABOUT.md +1 -0
  119. data/tracks/typescript/docs/INSTALLATION.md +17 -0
  120. data/tracks/typescript/docs/LEARNING.md +8 -0
  121. data/tracks/typescript/docs/RESOURCES.md +7 -0
  122. data/tracks/typescript/docs/TESTS.md +36 -0
  123. data/tracks/typescript/exercises/anagram/anagram.example.ts +23 -0
  124. data/tracks/typescript/exercises/anagram/anagram.test.ts +82 -0
  125. data/tracks/typescript/exercises/anagram/package.json +37 -0
  126. data/tracks/typescript/exercises/anagram/tsconfig.json +21 -0
  127. data/tracks/typescript/exercises/anagram/tslint.json +127 -0
  128. data/tracks/typescript/exercises/anagram/yarn.lock +2697 -0
  129. data/tracks/typescript/exercises/beer-song/beer-song.example.ts +36 -0
  130. data/tracks/typescript/exercises/beer-song/beer-song.test.ts +360 -0
  131. data/tracks/typescript/exercises/beer-song/package.json +37 -0
  132. data/tracks/typescript/exercises/beer-song/tsconfig.json +21 -0
  133. data/tracks/typescript/exercises/beer-song/tslint.json +127 -0
  134. data/tracks/typescript/exercises/beer-song/yarn.lock +2697 -0
  135. data/tracks/typescript/exercises/bob/bob.example.ts +24 -0
  136. data/tracks/typescript/exercises/bob/bob.test.ts +92 -0
  137. data/tracks/typescript/exercises/bob/package.json +37 -0
  138. data/tracks/typescript/exercises/bob/tsconfig.json +21 -0
  139. data/tracks/typescript/exercises/bob/tslint.json +127 -0
  140. data/tracks/typescript/exercises/bob/yarn.lock +2697 -0
  141. data/tracks/typescript/exercises/gigasecond/gigasecond.example.ts +11 -0
  142. data/tracks/typescript/exercises/gigasecond/gigasecond.test.ts +29 -0
  143. data/tracks/typescript/exercises/gigasecond/package.json +37 -0
  144. data/tracks/typescript/exercises/gigasecond/tsconfig.json +21 -0
  145. data/tracks/typescript/exercises/gigasecond/tslint.json +127 -0
  146. data/tracks/typescript/exercises/gigasecond/yarn.lock +2697 -0
  147. data/tracks/typescript/exercises/hamming/hamming.example.ts +19 -0
  148. data/tracks/typescript/exercises/hamming/hamming.test.ts +39 -0
  149. data/tracks/typescript/exercises/hamming/package.json +37 -0
  150. data/tracks/typescript/exercises/hamming/tsconfig.json +21 -0
  151. data/tracks/typescript/exercises/hamming/tslint.json +127 -0
  152. data/tracks/typescript/exercises/hamming/yarn.lock +2697 -0
  153. data/tracks/typescript/exercises/hello-world/hello-world.example.ts +8 -0
  154. data/tracks/typescript/exercises/hello-world/hello-world.test.ts +17 -0
  155. data/tracks/typescript/exercises/hello-world/package.json +37 -0
  156. data/tracks/typescript/exercises/hello-world/tsconfig.json +21 -0
  157. data/tracks/typescript/exercises/hello-world/tslint.json +127 -0
  158. data/tracks/typescript/exercises/hello-world/yarn.lock +2697 -0
  159. data/tracks/typescript/exercises/leap/leap.example.ts +6 -0
  160. data/tracks/typescript/exercises/leap/leap.test.ts +39 -0
  161. data/tracks/typescript/exercises/leap/package.json +37 -0
  162. data/tracks/typescript/exercises/leap/tsconfig.json +21 -0
  163. data/tracks/typescript/exercises/leap/tslint.json +127 -0
  164. data/tracks/typescript/exercises/leap/yarn.lock +2697 -0
  165. data/tracks/typescript/exercises/pangram/package.json +37 -0
  166. data/tracks/typescript/exercises/pangram/pangram.example.ts +32 -0
  167. data/tracks/typescript/exercises/pangram/pangram.test.ts +50 -0
  168. data/tracks/typescript/exercises/pangram/tsconfig.json +21 -0
  169. data/tracks/typescript/exercises/pangram/tslint.json +127 -0
  170. data/tracks/typescript/exercises/pangram/yarn.lock +2697 -0
  171. data/tracks/typescript/exercises/phone-number/package.json +37 -0
  172. data/tracks/typescript/exercises/phone-number/phone-number.example.ts +21 -0
  173. data/tracks/typescript/exercises/phone-number/phone-number.test.ts +55 -0
  174. data/tracks/typescript/exercises/phone-number/tsconfig.json +21 -0
  175. data/tracks/typescript/exercises/phone-number/tslint.json +127 -0
  176. data/tracks/typescript/exercises/phone-number/yarn.lock +2697 -0
  177. data/tracks/typescript/exercises/rna-transcription/package.json +37 -0
  178. data/tracks/typescript/exercises/rna-transcription/rna-transcription.example.ts +13 -0
  179. data/tracks/typescript/exercises/rna-transcription/rna-transcription.test.ts +45 -0
  180. data/tracks/typescript/exercises/rna-transcription/tsconfig.json +21 -0
  181. data/tracks/typescript/exercises/rna-transcription/tslint.json +127 -0
  182. data/tracks/typescript/exercises/rna-transcription/yarn.lock +2697 -0
  183. data/tracks/typescript/exercises/say/package.json +37 -0
  184. data/tracks/typescript/exercises/say/say.example.ts +95 -0
  185. data/tracks/typescript/exercises/say/say.test.ts +78 -0
  186. data/tracks/typescript/exercises/say/tsconfig.json +21 -0
  187. data/tracks/typescript/exercises/say/tslint.json +127 -0
  188. data/tracks/typescript/exercises/say/yarn.lock +2697 -0
  189. data/tracks/typescript/exercises/word-count/package.json +37 -0
  190. data/tracks/typescript/exercises/word-count/tsconfig.json +21 -0
  191. data/tracks/typescript/exercises/word-count/tslint.json +127 -0
  192. data/tracks/typescript/exercises/word-count/word-count.example.ts +16 -0
  193. data/tracks/typescript/exercises/word-count/word-count.test.ts +65 -0
  194. data/tracks/typescript/exercises/word-count/yarn.lock +2697 -0
  195. data/tracks/typescript/exercises/wordy/package.json +37 -0
  196. data/tracks/typescript/exercises/wordy/tsconfig.json +21 -0
  197. data/tracks/typescript/exercises/wordy/tslint.json +127 -0
  198. data/tracks/typescript/exercises/wordy/wordy.example.ts +40 -0
  199. data/tracks/typescript/exercises/wordy/wordy.test.ts +89 -0
  200. data/tracks/typescript/exercises/wordy/yarn.lock +2697 -0
  201. data/tracks/typescript/img/icon.png +0 -0
  202. data/tracks/typescript/img/icon.svg +10 -0
  203. metadata +134 -15
  204. data/tracks/erlang/exercises/binary/src/example.erl +0 -20
  205. data/tracks/erlang/exercises/binary/test/binary_string_tests.erl +0 -26
  206. data/tracks/erlang/exercises/trinary/Makefile +0 -10
  207. data/tracks/erlang/exercises/trinary/src/example.erl +0 -66
  208. data/tracks/erlang/exercises/trinary/test/trinary_tests.erl +0 -36
  209. 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
@@ -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
- !!description && !!metadata
21
+ description_object.exists? && metadata.exists?
14
22
  end
15
23
 
16
24
  def deprecated?
17
- @deprecated ||= File.exists?(common_metadata_path(deprecation_indicator_path))
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
- return @description unless @description.nil?
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
- repo_url(description_path)
67
+ description_object.url
64
68
  end
65
69
 
66
70
  def canonical_data_url
67
- repo_url(canonical_data_path) if File.exists?(common_metadata_path(canonical_data_path))
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
- repo_url(metadata_path)
75
+ metadata.url
72
76
  end
73
77
 
74
78
  def blurb
75
- metadata['blurb'].to_s.strip
79
+ metadata.blurb
76
80
  end
77
81
 
78
82
  def source
79
- metadata['source'].to_s.strip
83
+ metadata.source
80
84
  end
81
85
 
82
86
  def source_url
83
- metadata['source_url'].to_s.strip
87
+ metadata.source_url
84
88
  end
85
89
 
86
90
  private
87
91
 
88
- def canonical_data_path
89
- "exercises/%s/canonical-data.json" % slug
90
- end
92
+ attr_accessor :description_object
91
93
 
92
- def metadata_path
93
- "exercises/%s/metadata.yml" % slug
94
+ def canonical_data_file_name
95
+ "canonical-data.json"
94
96
  end
95
97
 
96
- def description_path
97
- "exercises/%s/description.md" % slug
98
+ def description_file_name
99
+ "description.md"
98
100
  end
99
101
 
100
- def deprecation_indicator_path
101
- "exercises/%s/.deprecated" % slug
102
+ def metadata_file_name
103
+ "metadata.yml"
102
104
  end
103
105
 
104
- def repo_url(path)
105
- "https://github.com/exercism/x-common/blob/master/#{path}" unless path.nil?
106
+ def deprecation_file_name
107
+ ".deprecated"
106
108
  end
107
109
 
108
- def metadata
109
- return @metadata unless @metadata.nil?
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 common_metadata_path(path)
117
- File.join(root, "common", path)
114
+ def file_path(filename, root = @file_root)
115
+ File.join(root, filename)
118
116
  end
119
117
 
120
118
  def markdown_link(url)
@@ -44,7 +44,7 @@ module Trackler
44
44
  end
45
45
 
46
46
  def implementations
47
- @implementations ||= Implementations.new(id, repository, active_slugs, root)
47
+ @implementations ||= Implementations.new(repository, active_slugs, root, self)
48
48
  end
49
49
 
50
50
  def problems
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.7.0"
2
+ VERSION = "2.0.8.1"
3
3
  end
@@ -1,7 +1,4 @@
1
- public class HelloWorld
1
+ public static class HelloWorld
2
2
  {
3
- public static string Hello(string name)
4
- {
5
- return $"Hello, {name ?? "World"}!";
6
- }
3
+ public static string Hello() => "Hello, World!";
7
4
  }
@@ -4,22 +4,8 @@
4
4
  public class HelloWorldTest
5
5
  {
6
6
  [Test]
7
- public void No_name()
7
+ public void Say_hi()
8
8
  {
9
- Assert.That(HelloWorld.Hello(null), Is.EqualTo("Hello, World!"));
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
  }
@@ -59,6 +59,13 @@
59
59
  "topics": [
60
60
  ]
61
61
  },
62
+ {
63
+ "slug": "series",
64
+ "difficulty": 2,
65
+ "topics": [
66
+ "string processing"
67
+ ]
68
+ },
62
69
  {
63
70
  "slug": "raindrops",
64
71
  "difficulty": 2,
@@ -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
+
@@ -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
- ### Seting up your system for local development on the track
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 prefered to name
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 programms will be run on travis and a merge is unlikely when
83
+ Both programs will be run on Travis and a merge is unlikely when
84
84
  tests fail.
85
85
 
86
86
  ## License
@@ -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",
@@ -1,5 +1,5 @@
1
- {application, trinary,
2
- [{description, "exercism.io - trinary"},
1
+ {application, all_your_base,
2
+ [{description, "exercism.io - all-your-base"},
3
3
  {vsn, "git"},
4
4
  {modules, []},
5
5
  {registered, []},
@@ -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])).