trackler 2.0.6.13 → 2.0.6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/common/TOPICS.txt +1 -0
  3. data/common/exercises/lens-person/metadata.yml +1 -1
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/csharp/exercises/all-your-base/AllYourBaseTest.cs +2 -1
  6. data/tracks/csharp/exercises/markdown/Example.cs +2 -2
  7. data/tracks/csharp/exercises/markdown/Markdown.cs +2 -2
  8. data/tracks/csharp/exercises/markdown/MarkdownTest.cs +4 -4
  9. data/tracks/elixir/.travis.yml +6 -1
  10. data/tracks/go/exercises/queen-attack/example.go +1 -1
  11. data/tracks/go/exercises/queen-attack/queen_attack_test.go +11 -6
  12. data/tracks/haskell/exercises/lens-person/examples/success-standard/package.yaml +0 -1
  13. data/tracks/haskell/exercises/lens-person/examples/success-standard/src/Person.hs +42 -14
  14. data/tracks/java/config.json +13 -1
  15. data/tracks/java/exercises/matrix/build.gradle +17 -0
  16. data/tracks/java/exercises/matrix/src/example/java/Matrix.java +39 -0
  17. data/tracks/java/exercises/matrix/src/main/java/.keep +0 -0
  18. data/tracks/java/exercises/matrix/src/test/java/MatrixTest.java +207 -0
  19. data/tracks/java/exercises/rectangles/build.gradle +17 -0
  20. data/tracks/java/exercises/rectangles/src/example/java/RectangleCounter.java +115 -0
  21. data/tracks/java/exercises/rectangles/src/main/java/RectangleCounter.java +5 -0
  22. data/tracks/java/exercises/rectangles/src/test/java/RectangleCounterTest.java +164 -0
  23. data/tracks/java/exercises/settings.gradle +2 -1
  24. data/tracks/julia/.travis.yml +17 -3
  25. data/tracks/julia/README.md +4 -1
  26. data/tracks/julia/docs/INSTALLATION.md +5 -0
  27. data/tracks/julia/docs/LEARNING.md +7 -0
  28. data/tracks/julia/docs/TESTS.md +5 -0
  29. data/tracks/julia/runtests.jl +32 -0
  30. data/tracks/pascal/exercises/hello-world/uTestHelloWorld.pas +27 -23
  31. data/tracks/python/README.md +1 -1
  32. metadata +11 -3
  33. data/tracks/pascal/img/Delphi-icon.png.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 908196b422992f0a5116328c5efcd82340322c89
4
- data.tar.gz: 88112e4cf238d4590f497bbba04f9cf21087f873
3
+ metadata.gz: b4773a317ee74fec5189add40d22bdb0810d4d5b
4
+ data.tar.gz: efb405ccd313b9bd85d8e49a64f95e73685465a0
5
5
  SHA512:
6
- metadata.gz: 10fb6193269541b0dce8c9f4cd44749a83e06a251cae0a5fcae35b8edc3122aeda761754f08addc071c627c65cb0560c531254737a49b0a81dd24a523e20e1b6
7
- data.tar.gz: 1d5ac6a45f0c7d9bd0c11ebf5f6abbb327b39481f3fad8195ed4bf9dafa13f6d6ef86cdd9bcad93c9330acbe4347fb28013fac11840f88df11fd93e90708270a
6
+ metadata.gz: df8a85473aed5805295b688533608f1bf7018764f6a030987c4a94805266c2996ea55764a039ae12f8dad321455d085af0ea5fbbf6b45f5e7b2f4756916c8506
7
+ data.tar.gz: a832b5beb59c5e7f4c2f72b8d6e7b0ddd681cca16fcb814d9372e98f055f36d0a8bba906e86eb97772de95ce7fab6306d8df3fcf11425d4a9b38dc58e356d9fa
data/common/TOPICS.txt CHANGED
@@ -5,6 +5,7 @@ Callbacks
5
5
  Control-flow (conditionals)
6
6
  Control-flow (loops)
7
7
  Events
8
+ Equality
8
9
  Exception handling
9
10
  Generics
10
11
  Inheritance
@@ -1,5 +1,5 @@
1
1
  ---
2
- blurb: "(Haskell specific) use lenses to update nested records."
2
+ blurb: "Use lenses to update nested records (specific to languages with immutable data)."
3
3
  common:
4
4
  type: focus
5
5
  focus: lenses
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.6.13"
2
+ VERSION = "2.0.6.14"
3
3
  end
@@ -131,6 +131,7 @@ public class AllYourBaseTest
131
131
  Assert.Throws<ArgumentException>(() => Base.Rebase(inputBase, inputDigits, outputBase));
132
132
  }
133
133
 
134
+ [Ignore("Remove to run test")]
134
135
  [Test]
135
136
  public void Negative_digit()
136
137
  {
@@ -155,7 +156,7 @@ public class AllYourBaseTest
155
156
  public void First_base_is_one()
156
157
  {
157
158
  const int inputBase = 1;
158
- var inputDigits = new int[0];
159
+ var inputDigits = new[] { 1, 0, 1, 0, 1, 0 };
159
160
  const int outputBase = 10;
160
161
  Assert.Throws<ArgumentException>(() => Base.Rebase(inputBase, inputDigits, outputBase));
161
162
  }
@@ -14,8 +14,8 @@ public static class Markdown
14
14
  private const string ItalicMarkdown = "_";
15
15
  private const string ListItemMarkdown = "*";
16
16
 
17
- private const string BoldTag = "em";
18
- private const string ItalicTag = "i";
17
+ private const string BoldTag = "strong";
18
+ private const string ItalicTag = "em";
19
19
  private const string ParagraphTag = "p";
20
20
  private const string ListTag = "ul";
21
21
  private const string ListItemTag = "li";
@@ -14,9 +14,9 @@ public static class Markdown
14
14
  return Regex.Replace(markdown, pattern, replacement);
15
15
  }
16
16
 
17
- private static string Parse__(string markdown) => Parse(markdown, "__", "em");
17
+ private static string Parse__(string markdown) => Parse(markdown, "__", "strong");
18
18
 
19
- private static string Parse_(string markdown) => Parse(markdown, "_", "i");
19
+ private static string Parse_(string markdown) => Parse(markdown, "_", "em");
20
20
 
21
21
  private static string ParseText(string markdown, bool list)
22
22
  {
@@ -14,7 +14,7 @@ public class MarkdownTest
14
14
  public void Parsing_italics()
15
15
  {
16
16
  var input = "_This will be italic_";
17
- var expected = "<p><i>This will be italic</i></p>";
17
+ var expected = "<p><em>This will be italic</em></p>";
18
18
  Assert.That(Markdown.Parse(input), Is.EqualTo(expected));
19
19
  }
20
20
 
@@ -22,7 +22,7 @@ public class MarkdownTest
22
22
  public void Parsing_bold_text()
23
23
  {
24
24
  var input = "__This will be bold__";
25
- var expected = "<p><em>This will be bold</em></p>";
25
+ var expected = "<p><strong>This will be bold</strong></p>";
26
26
  Assert.That(Markdown.Parse(input), Is.EqualTo(expected));
27
27
  }
28
28
 
@@ -30,7 +30,7 @@ public class MarkdownTest
30
30
  public void Mixed_normal_italics_and_bold_text()
31
31
  {
32
32
  var input = "This will _be_ __mixed__";
33
- var expected = "<p>This will <i>be</i> <em>mixed</em></p>";
33
+ var expected = "<p>This will <em>be</em> <strong>mixed</strong></p>";
34
34
  Assert.That(Markdown.Parse(input), Is.EqualTo(expected));
35
35
  }
36
36
 
@@ -70,7 +70,7 @@ public class MarkdownTest
70
70
  public void With_a_little_bit_of_everything()
71
71
  {
72
72
  var input = "# Header!\n* __Bold Item__\n* _Italic Item_";
73
- var expected = "<h1>Header!</h1><ul><li><em>Bold Item</em></li><li><i>Italic Item</i></li></ul>";
73
+ var expected = "<h1>Header!</h1><ul><li><strong>Bold Item</strong></li><li><em>Italic Item</em></li></ul>";
74
74
  Assert.That(Markdown.Parse(input), Is.EqualTo(expected));
75
75
  }
76
76
  }
@@ -1,10 +1,15 @@
1
- ---
2
1
  language: elixir
3
2
  elixir:
4
3
  - 1.3.2
4
+ - 1.4.0-rc.1
5
+
5
6
  otp_release:
6
7
  - 19.0
7
8
 
9
+ matrix:
10
+ allow_failures:
11
+ - elixir: 1.4.0-rc.1
12
+
8
13
  script:
9
14
  - bin/fetch-configlet
10
15
  - bin/configlet .
@@ -2,7 +2,7 @@ package queenattack
2
2
 
3
3
  import "fmt"
4
4
 
5
- const testVersion = 1
5
+ const testVersion = 2
6
6
 
7
7
  func CanQueenAttack(w, b string) (attack bool, err error) {
8
8
  if err = valSq(w); err != nil {
@@ -5,25 +5,30 @@ import "testing"
5
5
  // Arguments to CanQueenAttack are in algebraic notation.
6
6
  // See http://en.wikipedia.org/wiki/Algebraic_notation_(chess)
7
7
 
8
- const targetTestVersion = 1
8
+ const targetTestVersion = 2
9
9
 
10
10
  var tests = []struct {
11
11
  w, b string
12
12
  attack bool
13
13
  ok bool
14
14
  }{
15
- {"b4", "b4", false, false}, // same square
16
- {"a8", "b9", false, false}, // off board
15
+ {"b4", "b4", false, false}, // same square
16
+ {"a8", "b9", false, false}, // off board
17
+ {"a0", "b1", false, false},
18
+ {"g3", "i5", false, false},
17
19
  {"here", "there", false, false}, // invalid
18
20
  {"", "", false, false},
19
21
 
20
22
  {"b3", "d7", false, true}, // no attack
21
- {"b4", "b7", true, true}, // same file
22
- {"e4", "b4", true, true}, // same rank
23
- {"a1", "f6", true, true}, // common diagonals
23
+ {"a1", "f8", false, true},
24
+ {"b4", "b7", true, true}, // same file
25
+ {"e4", "b4", true, true}, // same rank
26
+ {"a1", "f6", true, true}, // common diagonals
24
27
  {"a6", "b7", true, true},
25
28
  {"d1", "f3", true, true},
26
29
  {"f1", "a6", true, true},
30
+ {"a1", "h8", true, true},
31
+ {"a8", "h1", true, true},
27
32
  }
28
33
 
29
34
  func TestTestVersion(t *testing.T) {
@@ -8,7 +8,6 @@ library:
8
8
  exposed-modules: Person
9
9
  source-dirs: src
10
10
  dependencies:
11
- - lens
12
11
 
13
12
  tests:
14
13
  test:
@@ -1,9 +1,10 @@
1
- {-# LANGUAGE TemplateHaskell #-}
1
+ {-# LANGUAGE Rank2Types #-}
2
2
 
3
3
  module Person where
4
4
 
5
- import Control.Lens
6
- import Data.Time.Calendar
5
+ import Control.Applicative (Const(..), getConst)
6
+ import Data.Functor.Identity (Identity(..), runIdentity)
7
+ import Data.Time.Calendar (Day, toGregorian, fromGregorian)
7
8
 
8
9
  data Person = Person {
9
10
  _name :: Name,
@@ -36,17 +37,44 @@ data Gregorian = Gregorian {
36
37
  _day :: Int
37
38
  }
38
39
 
39
- makeLenses ''Person
40
- makeLenses ''Name
41
- makeLenses ''Born
42
- makeLenses ''Address
43
- makeLenses ''Gregorian
40
+ type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
41
+ type Lens' s a = Lens s s a a
42
+ type Getting s a = (a -> Const a a) -> s -> Const a s
43
+ type Setting s t a b = (a -> Identity b) -> s -> Identity t
44
44
 
45
- gregorianDay :: Iso' Gregorian Day
46
- gregorianDay = iso toDay fromDay
47
- where
48
- toDay (Gregorian y m d) = fromGregorian y m d
49
- fromDay d' = let (y, m, d) = toGregorian d' in Gregorian y m d
45
+ lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
46
+ lens sa sbt afb s = fmap (sbt s) (afb (sa s))
47
+
48
+ view :: Getting s a -> s -> a
49
+ view l = getConst . l Const
50
+
51
+ over :: Setting s t a b -> (a -> b) -> s -> t
52
+ over l f = runIdentity . l (Identity . f)
53
+
54
+ set :: Setting s t a b -> b -> s -> t
55
+ set l v = over l (const v)
56
+
57
+ -- boilerplate lenses:
58
+
59
+ born :: Lens' Person Born
60
+ born = lens _born (\p b -> p { _born = b })
61
+
62
+ address :: Lens' Person Address
63
+ address = lens _address (\p a -> p { _address = a })
64
+
65
+ bornAt :: Lens' Born Address
66
+ bornAt = lens _bornAt (\b a -> b { _bornAt = a })
67
+
68
+ bornOn :: Lens' Born Day
69
+ bornOn = lens _bornOn (\b d -> b { _bornOn = d })
70
+
71
+ street :: Lens' Address String
72
+ street = lens _street (\a s -> a { _street = s })
73
+
74
+ month :: Lens' Day Int
75
+ month = lens getMonth setMonth
76
+ where getMonth day = let (_, m, _) = toGregorian day in m
77
+ setMonth day m = let (y, _, d) = toGregorian day in fromGregorian y m d
50
78
 
51
79
  bornStreet :: Born -> String
52
80
  bornStreet = view (bornAt . street)
@@ -55,7 +83,7 @@ setCurrentStreet :: String -> Person -> Person
55
83
  setCurrentStreet = set (address . street)
56
84
 
57
85
  setBirthMonth :: Int -> Person -> Person
58
- setBirthMonth = set (born . bornOn . from gregorianDay . month)
86
+ setBirthMonth = set (born . bornOn . month)
59
87
 
60
88
  renameStreets :: (String -> String) -> Person -> Person
61
89
  renameStreets f = over birthStreet f . over currentStreet f
@@ -55,7 +55,9 @@
55
55
  "wordy",
56
56
  "palindrome-products",
57
57
  "twelve-days",
58
- "sublist"
58
+ "sublist",
59
+ "rectangles",
60
+ "matrix"
59
61
  ],
60
62
  "exercises": [
61
63
  {
@@ -317,6 +319,16 @@
317
319
  "slug": "sublist",
318
320
  "difficulty": 1,
319
321
  "topics": []
322
+ },
323
+ {
324
+ "slug": "rectangles",
325
+ "difficulty": 1,
326
+ "topics": []
327
+ },
328
+ {
329
+ "slug": "matrix",
330
+ "difficulty": 1,
331
+ "topics": []
320
332
  }
321
333
  ],
322
334
  "deprecated": [
@@ -0,0 +1,17 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+ test {
13
+ testLogging {
14
+ exceptionFormat = 'full'
15
+ events = ["passed", "failed", "skipped"]
16
+ }
17
+ }
@@ -0,0 +1,39 @@
1
+ import java.util.regex.Pattern;
2
+
3
+ public class Matrix {
4
+ private int[][] matrix;
5
+ private static Pattern spacePattern = Pattern.compile(" ");
6
+ private static Pattern newlinePattern = Pattern.compile("\\n");
7
+
8
+ public Matrix(String matrixAsString) {
9
+ String[] rows = newlinePattern.split(matrixAsString);
10
+ matrix = new int[rows.length][];
11
+ for (int i = 0; i < rows.length; i++) {
12
+ String[] columnValues = spacePattern.split(rows[i]);
13
+ matrix[i] = new int[columnValues.length];
14
+ for (int j = 0; j < columnValues.length; j++) {
15
+ matrix[i][j] = Integer.parseInt(columnValues[j]);
16
+ }
17
+ }
18
+ }
19
+
20
+ public int[] getRow(int rowNumber) {
21
+ return matrix[rowNumber];
22
+ }
23
+
24
+ public int[] getColumn(int columnNumber) {
25
+ int[] column = new int[matrix.length];
26
+ for(int i = 0; i < matrix.length; i++) {
27
+ column[i] = matrix[i][columnNumber];
28
+ }
29
+ return column;
30
+ }
31
+
32
+ public int getRowsCount() {
33
+ return matrix.length;
34
+ }
35
+
36
+ public int getColumnsCount() {
37
+ return matrix[0].length;
38
+ }
39
+ }
File without changes
@@ -0,0 +1,207 @@
1
+ import org.junit.Ignore;
2
+ import org.junit.Test;
3
+ import org.junit.experimental.runners.Enclosed;
4
+ import org.junit.runner.RunWith;
5
+ import org.junit.runners.Parameterized;
6
+
7
+ import java.util.Arrays;
8
+ import java.util.Collection;
9
+
10
+ import static org.junit.Assert.assertArrayEquals;
11
+ import static org.junit.Assert.assertEquals;
12
+
13
+ @RunWith(Enclosed.class)
14
+ public class MatrixTest {
15
+
16
+ @RunWith(Parameterized.class)
17
+ public static class CountRowsTest {
18
+ private Matrix matrix;
19
+ private int numberOfRows;
20
+
21
+ @Parameterized.Parameters(name = "{index}: expected matrix constructed with string \n\"{0}\" to have {1} row(s).")
22
+ public static Collection<Object[]> data() {
23
+ return Arrays.asList(new Object[][]{
24
+ {"0", 1},
25
+ {"0 1", 1},
26
+ { "0\n"
27
+ + "1", 2},
28
+ { "0 1\n"
29
+ + "2 3", 2},
30
+ { "0 1 2\n"
31
+ + "3 4 5\n"
32
+ + "6 7 8", 3}
33
+ });
34
+ }
35
+
36
+ public CountRowsTest(String matrixAsString, int numberOfRows) {
37
+ this.matrix = new Matrix(matrixAsString);
38
+ this.numberOfRows = numberOfRows;
39
+ }
40
+
41
+ @Test
42
+ public void countRowsTest() {
43
+ assertEquals(numberOfRows, matrix.getRowsCount());
44
+ }
45
+ }
46
+
47
+ @Ignore
48
+ @RunWith(Parameterized.class)
49
+ public static class CountColumnsTest {
50
+ private Matrix matrix;
51
+ private int numberOfColumns;
52
+
53
+ @Parameterized.Parameters(name = "{index}: expected matrix constructed with string \n\"{0}\" to have {1} column(s).")
54
+ public static Collection<Object[]> data() {
55
+ return Arrays.asList(new Object[][]{
56
+ {"0", 1},
57
+ {"0 1", 2},
58
+ { "0\n"
59
+ + "1", 1},
60
+ { "0 1\n"
61
+ + "2 3", 2},
62
+ { "0 1 2\n"
63
+ + "3 4 5\n"
64
+ + "6 7 8", 3}
65
+ });
66
+ }
67
+
68
+ public CountColumnsTest(String matrixAsString, int numberOfColumns) {
69
+ this.matrix = new Matrix(matrixAsString);
70
+ this.numberOfColumns = numberOfColumns;
71
+ }
72
+
73
+ @Test
74
+ public void countColumnsTest() {
75
+ assertEquals(numberOfColumns, matrix.getColumnsCount());
76
+ }
77
+ }
78
+
79
+ @Ignore
80
+ @RunWith(Parameterized.class)
81
+ public static class GetFirstRowTest {
82
+ private Matrix matrix;
83
+ private int[] firstRow;
84
+
85
+ @Parameterized.Parameters(name = "{index}: checking first row of matrix constructed with string \n\"{0}\".")
86
+ public static Collection<Object[]> data() {
87
+ return Arrays.asList(new Object[][]{
88
+ {"0", new int[] {0}},
89
+ {"0 1", new int[] {0, 1}},
90
+ { "0\n"
91
+ + "1", new int[] {0}},
92
+ { "0 1\n"
93
+ + "2 3", new int[] {0, 1}},
94
+ { "0 1 2\n"
95
+ + "3 4 5\n"
96
+ + "6 7 8", new int[] {0, 1, 2}}
97
+ });
98
+ }
99
+
100
+ public GetFirstRowTest(String matrixAsString, int[] firstRow) {
101
+ this.matrix = new Matrix(matrixAsString);
102
+ this.firstRow = firstRow;
103
+ }
104
+
105
+ @Test
106
+ public void getFirstRowTest() {
107
+ assertArrayEquals(firstRow, matrix.getRow(0));
108
+ }
109
+ }
110
+
111
+ @Ignore
112
+ @RunWith(Parameterized.class)
113
+ public static class GetLastRowTest {
114
+ private Matrix matrix;
115
+ private int[] lastRow;
116
+
117
+ @Parameterized.Parameters(name = "{index}: checking last row of matrix constructed with string \n\"{0}\".")
118
+ public static Collection<Object[]> data() {
119
+ return Arrays.asList(new Object[][]{
120
+ {"0", new int[] {0}},
121
+ {"0 1", new int[] {0, 1}},
122
+ { "0\n"
123
+ + "1", new int[] {1}},
124
+ { "0 1\n"
125
+ + "2 3", new int[] {2, 3}},
126
+ { "0 1 2\n"
127
+ + "3 4 5\n"
128
+ + "6 7 8", new int[] {6, 7, 8}}
129
+ });
130
+ }
131
+
132
+ public GetLastRowTest(String matrixAsString, int[] lastRow) {
133
+ this.matrix = new Matrix(matrixAsString);
134
+ this.lastRow = lastRow;
135
+ }
136
+
137
+ @Test
138
+ public void getLastRowTest() {
139
+ assertArrayEquals(lastRow, matrix.getRow(matrix.getRowsCount() - 1));
140
+ }
141
+ }
142
+
143
+ @Ignore
144
+ @RunWith(Parameterized.class)
145
+ public static class GetFirstColumnTest {
146
+ private Matrix matrix;
147
+ private int[] firstColumn;
148
+
149
+ @Parameterized.Parameters(name = "{index}: checking first column of matrix constructed with string \n\"{0}\".")
150
+ public static Collection<Object[]> data() {
151
+ return Arrays.asList(new Object[][]{
152
+ {"0", new int[] {0}},
153
+ {"0 1", new int[] {0}},
154
+ { "0\n"
155
+ + "1", new int[] {0, 1}},
156
+ { "0 1\n"
157
+ + "2 3", new int[] {0, 2}},
158
+ { "0 1 2\n"
159
+ + "3 4 5\n"
160
+ + "6 7 8", new int[] {0, 3, 6}}
161
+ });
162
+ }
163
+
164
+ public GetFirstColumnTest(String matrixAsString, int[] firstColumn) {
165
+ this.matrix = new Matrix(matrixAsString);
166
+ this.firstColumn = firstColumn;
167
+ }
168
+
169
+ @Test
170
+ public void getFirstColumnTest() {
171
+ assertArrayEquals(firstColumn, matrix.getColumn(0));
172
+ }
173
+ }
174
+
175
+
176
+ @Ignore
177
+ @RunWith(Parameterized.class)
178
+ public static class GetLastColumnTest {
179
+ private Matrix matrix;
180
+ private int[] lastColumn;
181
+
182
+ @Parameterized.Parameters(name = "{index}: checking last column of matrix constructed with string \n\"{0}\".")
183
+ public static Collection<Object[]> data() {
184
+ return Arrays.asList(new Object[][]{
185
+ {"0", new int[] {0}},
186
+ {"0 1", new int[] {1}},
187
+ { "0\n"
188
+ + "1", new int[] {0, 1}},
189
+ { "0 1\n"
190
+ + "2 3", new int[] {1, 3}},
191
+ { "0 1 2\n"
192
+ + "3 4 5\n"
193
+ + "6 7 8", new int[] {2, 5, 8}}
194
+ });
195
+ }
196
+
197
+ public GetLastColumnTest(String matrixAsString, int[] lastColumn) {
198
+ this.matrix = new Matrix(matrixAsString);
199
+ this.lastColumn = lastColumn;
200
+ }
201
+
202
+ @Test
203
+ public void getLastColumnTest() {
204
+ assertArrayEquals(lastColumn, matrix.getColumn(matrix.getColumnsCount() - 1));
205
+ }
206
+ }
207
+ }
@@ -0,0 +1,17 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+ test {
13
+ testLogging {
14
+ exceptionFormat = 'full'
15
+ events = ["passed", "failed", "skipped"]
16
+ }
17
+ }
@@ -0,0 +1,115 @@
1
+ import static java.util.Arrays.copyOfRange;
2
+ import static java.util.Arrays.stream;
3
+
4
+ final class RectangleCounter {
5
+
6
+ int countRectangles(final String[] rawGrid) {
7
+ final int nRows = rawGrid.length;
8
+ if (nRows == 0) return 0;
9
+
10
+ final int nCols = rawGrid[0].length();
11
+ if (nCols == 0) return 0;
12
+
13
+ return new Grid(nRows, nCols, rawGrid).countRectangles();
14
+ }
15
+
16
+ private static final class Grid {
17
+
18
+ private enum Entry {
19
+ CORNER,
20
+ HLINE,
21
+ VLINE,
22
+ SPACE;
23
+
24
+ private static Entry fromChar(final char rawGridEntry) {
25
+ switch (rawGridEntry) {
26
+ case '+': return CORNER;
27
+ case '-': return HLINE;
28
+ case '|': return VLINE;
29
+ case ' ': return SPACE;
30
+ default: throw new IllegalStateException("Grid entry " + rawGridEntry + " not recognized.");
31
+ }
32
+ }
33
+ }
34
+
35
+ private int nRows, nCols;
36
+ private final Entry[][] entries;
37
+
38
+ private Grid(final int nRows, final int nCols, final String[] rawGrid) {
39
+ this.nRows = nRows;
40
+ this.nCols = nCols;
41
+ this.entries = new Entry[nRows][nCols];
42
+
43
+ for (int nRow = 0; nRow < nRows; nRow++) {
44
+ for (int nCol = 0; nCol < nCols; nCol++) {
45
+ entries[nRow][nCol] = Entry.fromChar(rawGrid[nRow].charAt(nCol));
46
+ }
47
+ }
48
+ }
49
+
50
+ private int countRectangles() {
51
+ int result = 0;
52
+
53
+ for (int topRow = 0; topRow < nRows - 1; topRow++) {
54
+
55
+ for (int leftCol = 0; leftCol < nCols - 1; leftCol++) {
56
+
57
+ // Only check rectangles that lie below/to the right of our current coordinate:
58
+ for (int bottomRow = topRow + 1; bottomRow < nRows; bottomRow++) {
59
+
60
+ for (int rightCol = leftCol + 1; rightCol < nCols; rightCol++) {
61
+
62
+ if (formsRectangle(topRow, bottomRow, leftCol, rightCol)) {
63
+ result++;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ return result;
71
+ }
72
+
73
+ private boolean formsRectangle(
74
+ final int topRow,
75
+ final int bottomRow,
76
+ final int leftCol,
77
+ final int rightCol) {
78
+
79
+ return entries[topRow][leftCol].equals(Entry.CORNER)
80
+ && entries[topRow][rightCol].equals(Entry.CORNER)
81
+ && entries[bottomRow][leftCol].equals(Entry.CORNER)
82
+ && entries[bottomRow][rightCol].equals(Entry.CORNER)
83
+ && isHorizontalLineSegment(topRow, leftCol, rightCol)
84
+ && isHorizontalLineSegment(bottomRow, leftCol, rightCol)
85
+ && isVerticalLineSegment(leftCol, topRow, bottomRow)
86
+ && isVerticalLineSegment(rightCol, topRow, bottomRow);
87
+ }
88
+
89
+ private boolean isHorizontalLineSegment(final int row, final int leftCol, final int rightCol) {
90
+ return stream(copyOfRange(getRow(row), leftCol, rightCol))
91
+ .allMatch(entry -> entry.equals(Entry.HLINE) || entry.equals(Entry.CORNER));
92
+ }
93
+
94
+ private boolean isVerticalLineSegment(final int col, final int topRow, final int bottomRow) {
95
+ return stream(copyOfRange(getCol(col), topRow, bottomRow))
96
+ .allMatch(entry -> entry.equals(Entry.VLINE) || entry.equals(Entry.CORNER));
97
+ }
98
+
99
+ private Entry[] getRow(final int number) {
100
+ return entries[number];
101
+ }
102
+
103
+ private Entry[] getCol(final int number) {
104
+ final Entry[] result = new Entry[nRows];
105
+
106
+ for (int nRow = 0; nRow < nRows; nRow++) {
107
+ result[nRow] = entries[nRow][number];
108
+ }
109
+
110
+ return result;
111
+ }
112
+
113
+ }
114
+
115
+ }
@@ -0,0 +1,5 @@
1
+ final class RectangleCounter {
2
+
3
+
4
+
5
+ }
@@ -0,0 +1,164 @@
1
+ import org.junit.Before;
2
+ import org.junit.Ignore;
3
+ import org.junit.Test;
4
+
5
+ import static org.junit.Assert.assertEquals;
6
+
7
+ public final class RectangleCounterTest {
8
+
9
+ private RectangleCounter rectangleCounter;
10
+
11
+ @Before
12
+ public void setUp() {
13
+ rectangleCounter = new RectangleCounter();
14
+ }
15
+
16
+ @Test
17
+ public void testInputWithNoColumnsContainsNoRectangles() {
18
+ String[] inputGrid = new String[]{};
19
+
20
+ assertEquals(0, rectangleCounter.countRectangles(inputGrid));
21
+ }
22
+
23
+ @Ignore
24
+ @Test
25
+ public void testNonTrivialInputWithNoRectangles() {
26
+ String[] inputGrid = new String[]{" "};
27
+
28
+ assertEquals(0, rectangleCounter.countRectangles(inputGrid));
29
+ }
30
+
31
+ @Ignore
32
+ @Test
33
+ public void testInputWithOneRectangle() {
34
+ String[] inputGrid = new String[]{
35
+ "+-+",
36
+ "| |",
37
+ "+-+"
38
+ };
39
+
40
+ assertEquals(1, rectangleCounter.countRectangles(inputGrid));
41
+ }
42
+
43
+ @Ignore
44
+ @Test
45
+ public void testInputWithTwoRectanglesWithoutSharedEdges() {
46
+ String[] inputGrid = new String[]{
47
+ " +-+",
48
+ " | |",
49
+ "+-+-+",
50
+ "| | ",
51
+ "+-+ "
52
+ };
53
+
54
+ assertEquals(2, rectangleCounter.countRectangles(inputGrid));
55
+ }
56
+
57
+ @Ignore
58
+ @Test
59
+ public void testInputWithFiveRectanglesWithSharedEdges() {
60
+ String[] inputGrid = new String[]{
61
+ " +-+",
62
+ " | |",
63
+ "+-+-+",
64
+ "| | |",
65
+ "+-+-+"
66
+ };
67
+
68
+ assertEquals(5, rectangleCounter.countRectangles(inputGrid));
69
+ }
70
+
71
+ @Ignore
72
+ @Test
73
+ public void testThatRectangleOfHeightOneIsCounted() {
74
+ String[] inputGrid = new String[]{
75
+ "+--+",
76
+ "+--+"
77
+ };
78
+
79
+ assertEquals(1, rectangleCounter.countRectangles(inputGrid));
80
+ }
81
+
82
+ @Ignore
83
+ @Test
84
+ public void testThatRectangleOfWidthOneIsCounted() {
85
+ String[] inputGrid = new String[]{
86
+ "++",
87
+ "||",
88
+ "++"
89
+ };
90
+
91
+ assertEquals(1, rectangleCounter.countRectangles(inputGrid));
92
+ }
93
+
94
+ @Ignore
95
+ @Test
96
+ public void testThatOneByOneSquareIsCounted() {
97
+ String[] inputGrid = new String[]{
98
+ "++",
99
+ "++"
100
+ };
101
+
102
+ assertEquals(1, rectangleCounter.countRectangles(inputGrid));
103
+ }
104
+
105
+ @Ignore
106
+ @Test
107
+ public void testThatIncompleteRectanglesAreNotCounted() {
108
+ String[] inputGrid = new String[]{
109
+ " +-+",
110
+ " |",
111
+ "+-+-+",
112
+ "| | -",
113
+ "+-+-+"
114
+ };
115
+
116
+ assertEquals(1, rectangleCounter.countRectangles(inputGrid));
117
+ }
118
+
119
+ @Ignore
120
+ @Test
121
+ public void testThatRectanglesOfDifferentSizesAreAllCounted() {
122
+ String[] inputGrid = new String[]{
123
+ "+------+----+",
124
+ "| | |",
125
+ "+---+--+ |",
126
+ "| | |",
127
+ "+---+-------+"
128
+ };
129
+
130
+ assertEquals(3, rectangleCounter.countRectangles(inputGrid));
131
+ }
132
+
133
+ @Ignore
134
+ @Test
135
+ public void testThatIntersectionsWithoutCornerCharacterDoNotCountAsRectangleCorners() {
136
+ String[] inputGrid = new String[]{
137
+ "+------+----+",
138
+ "| | |",
139
+ "+------+ |",
140
+ "| | |",
141
+ "+---+-------+"
142
+ };
143
+
144
+ assertEquals(2, rectangleCounter.countRectangles(inputGrid));
145
+ }
146
+
147
+ @Ignore
148
+ @Test
149
+ public void testLargeInputWithManyRectangles() {
150
+ String[] inputGrid = new String[]{
151
+ "+---+--+----+",
152
+ "| +--+----+",
153
+ "+---+--+ |",
154
+ "| +--+----+",
155
+ "+---+--+--+-+",
156
+ "+---+--+--+-+",
157
+ "+------+ | |",
158
+ " +-+"
159
+ };
160
+
161
+ assertEquals(60, rectangleCounter.countRectangles(inputGrid));
162
+ }
163
+
164
+ }
@@ -34,6 +34,7 @@ include 'phone-number'
34
34
  include 'pig-latin'
35
35
  include 'queen-attack'
36
36
  include 'raindrops'
37
+ include 'rectangles'
37
38
  include 'rna-transcription'
38
39
  include 'robot-name'
39
40
  include 'robot-simulator'
@@ -54,4 +55,4 @@ include 'trinary'
54
55
  include 'word-count'
55
56
  include 'wordy'
56
57
  include 'twelve-days'
57
-
58
+ include 'matrix'
@@ -1,5 +1,19 @@
1
- language: bash
1
+ language: julia
2
+
3
+ os:
4
+ - linux
5
+ - osx
6
+
7
+ julia:
8
+ - release
9
+ - nightly
10
+ - 0.5
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - julia: nightly
2
15
 
3
16
  script:
4
- - bin/fetch-configlet
5
- - bin/configlet .
17
+ - julia runtests.jl
18
+ - ./bin/fetch-configlet
19
+ - ./bin/configlet .
@@ -14,7 +14,7 @@ Please see the [contributing guide](https://github.com/exercism/x-common/blob/ma
14
14
 
15
15
  A pool of exercises can be found in the [x-Common repo](https://github.com/exercism/x-common).
16
16
 
17
- Exercises for the Julia track go in the `exercises` directory and should follow the following filename conventions:
17
+ Exercises for the Julia track go in the `exercises` directory and should follow the following filename conventions:
18
18
 
19
19
  `exercises/<slug>/<slug>.jl` Skeleton for the function that is called by the test suite. Provide (abstract) parameter and return types to ensure compatibility with the test suite.
20
20
 
@@ -25,3 +25,6 @@ Exercises for the Julia track go in the `exercises` directory and should follow
25
25
  Replace `<slug>` with the exercise slug of the exercise you're working on.
26
26
 
27
27
  See [Issue #2](https://github.com/exercism/xjulia/issues/2) for discussion on the structure.
28
+
29
+ ### Testing the example solutions
30
+ Test your example solutions by running `julia runtests.jl` in the project directory. Specify exercise slugs as arguments to run only certain exercises: `julia runtests.jl <slug>`.
@@ -0,0 +1,5 @@
1
+ To install Julia on your system follow the instructions on the [Julia Language Downloads page](http://julialang.org/downloads/).
2
+
3
+ For a local installation, it is recommended to use [Juno](http://junolab.org/). It's an IDE based on Atom and offers a powerful text editor as well as additional features for developing in Julia. Just follow the instructions on their website.
4
+
5
+ A simple way to get started with Julia without the need of a local installation is [JuliaBox](http://junolab.org/), which is an online IDE based on Jupyter notebooks. You just access it from your browser, login and you can start solving exercises.
@@ -0,0 +1,7 @@
1
+ # Learning Julia From Scratch
2
+
3
+ Exercism assumes that you already have some knowledge about the Julia language to the point where you understand the basic concept of a function and know the syntax reasonably well. The Julia language website contains a regularly updated [list of learning resources](http://julialang.org/learning/). This is the go-to place when looking for books and tutorials on Julia.
4
+
5
+ For examples on what to do with Julia as well as more specific tutorials, check out [juliabloggers.com](http://www.juliabloggers.com/).
6
+
7
+ Please note: Julia is a rather young and still rapidly evolving language and as such, examples from books or tutorials written for older versions of Julia may not work anymore without (small) adjustments.
@@ -0,0 +1,5 @@
1
+ # Running the tests
2
+ Place yourself in the directory where the exercise has been fetched and run:
3
+ ```bash
4
+ julia runtests.jl
5
+ ```
@@ -0,0 +1,32 @@
1
+ using Base.Test
2
+
3
+ for (root, dirs, files) in walkdir("exercises")
4
+ for exercise in dirs
5
+ # Allow only testing specified execises
6
+ if !isempty(ARGS) && !(exercise in ARGS)
7
+ continue
8
+ end
9
+
10
+ exercise_path = joinpath("exercises", exercise)
11
+
12
+ # Create temporary directory
13
+ temp_path = mktempdir(root)
14
+
15
+ # Copy tests & example to the temporary directory
16
+ cp(joinpath(exercise_path, "example.jl"), joinpath(temp_path, "$exercise.jl"))
17
+ cp(joinpath(exercise_path, "runtests.jl"), joinpath(temp_path, "runtests.jl"))
18
+
19
+ # Run the tests
20
+ result = @testset "$exercise example" begin
21
+ include(joinpath(temp_path, "runtests.jl"))
22
+ end
23
+
24
+ # Delete the temporary directory
25
+ rm(temp_path, recursive=true)
26
+
27
+ # Print test output (this is the default behaviour for older versions of Julia)
28
+ if VERSION > v"0.6.0-dev"
29
+ Base.Test.print_test_results(result)
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,30 @@
1
+ //*****************************************************************************
2
+ // You got an error, which is exactly as it should be.
3
+ // This is the first step in the Test-Driven Development
4
+ // (TDD) process.
5
+ //
6
+ // The most important part of the error is
7
+ //
8
+ // "cannot compile"
9
+ //
10
+ // It's looking for a file named uHelloWorld.pas that doesn't exist.
11
+ //
12
+ // To fix the error, create a unit file named uHelloWorld.pas
13
+ // in the same directory as the file uTestHelloWorld.pas.
14
+ //
15
+ // The beginning of the new unit file should contain a unit statement:
16
+ //
17
+ // unit uHelloWorld;
18
+ //
19
+ // The new unit should contain Interface, Implementation, and End. statements.
20
+ //
21
+ // Hint: Delphi will take care of all this if you instruct it to add a new unit
22
+ // to your project. Be sure to save the new unit as uHelloWorld.pas before
23
+ // trying to compile again.
24
+ //
25
+ // For more guidance as you work on this exercise, see
26
+ // GETTING_STARTED.md.
27
+ //*****************************************************************************
1
28
  unit uTestHelloWorld;
2
29
 
3
30
  interface
@@ -39,26 +66,3 @@ end;
39
66
  initialization
40
67
  TDUnitX.RegisterTestFixture(HelloWorldTest);
41
68
  end.
42
-
43
- (*
44
- *****************************************************
45
- You got an error, which is exactly as it should be.
46
- This is the first step in the Test-Driven Development
47
- (TDD) process.
48
-
49
- The most important part of the error is
50
-
51
- "cannot compile"
52
-
53
- It's looking for a file named uHelloWorld.pas that doesn't
54
- exist yet.
55
-
56
- To fix the error, create an empty file named uHelloWorld.pas
57
- in the same directory as the uTestHelloWorld.pas file.
58
-
59
- Then run the test again.
60
-
61
- For more guidance as you work on this exercise, see
62
- GETTING_STARTED.md.
63
- *****************************************************
64
- *)
@@ -1,6 +1,6 @@
1
1
  # xPython
2
2
 
3
- [![Build Status](https://travis-ci.org/exercism/xpython.png?branch=master)](https://travis-ci.org/exercism/xpython) [![Requirements Status](https://requires.io/github/exercism/xpython/requirements.svg?branch=master)](https://requires.io/github/exercism/xpython/requirements/?branch=master)
3
+ [![Build Status](https://travis-ci.org/exercism/xpython.svg?branch=master)](https://travis-ci.org/exercism/xpython) [![Requirements Status](https://requires.io/github/exercism/xpython/requirements.svg?branch=master)](https://requires.io/github/exercism/xpython/requirements/?branch=master)
4
4
  [![Join the chat at https://gitter.im/exercism/xpython](https://badges.gitter.im/exercism/xpython.svg)](https://gitter.im/exercism/xpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
5
 
6
6
  Exercism exercises in Python
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.6.13
4
+ version: 2.0.6.14
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-01-18 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -3669,6 +3669,10 @@ files:
3669
3669
  - tracks/java/exercises/luhn/src/example/java/Luhn.java
3670
3670
  - tracks/java/exercises/luhn/src/main/java/.keep
3671
3671
  - tracks/java/exercises/luhn/src/test/java/LuhnTest.java
3672
+ - tracks/java/exercises/matrix/build.gradle
3673
+ - tracks/java/exercises/matrix/src/example/java/Matrix.java
3674
+ - tracks/java/exercises/matrix/src/main/java/.keep
3675
+ - tracks/java/exercises/matrix/src/test/java/MatrixTest.java
3672
3676
  - tracks/java/exercises/meetup/build.gradle
3673
3677
  - tracks/java/exercises/meetup/src/example/java/Meetup.java
3674
3678
  - tracks/java/exercises/meetup/src/example/java/MeetupSchedule.java
@@ -3728,6 +3732,10 @@ files:
3728
3732
  - tracks/java/exercises/raindrops/src/example/java/Raindrops.java
3729
3733
  - tracks/java/exercises/raindrops/src/main/java/.keep
3730
3734
  - tracks/java/exercises/raindrops/src/test/java/RaindropsTest.java
3735
+ - tracks/java/exercises/rectangles/build.gradle
3736
+ - tracks/java/exercises/rectangles/src/example/java/RectangleCounter.java
3737
+ - tracks/java/exercises/rectangles/src/main/java/RectangleCounter.java
3738
+ - tracks/java/exercises/rectangles/src/test/java/RectangleCounterTest.java
3731
3739
  - tracks/java/exercises/rna-transcription/build.gradle
3732
3740
  - tracks/java/exercises/rna-transcription/src/example/java/RnaTranscription.java
3733
3741
  - tracks/java/exercises/rna-transcription/src/main/java/.keep
@@ -3999,6 +4007,7 @@ files:
3999
4007
  - tracks/julia/docs/TESTS.md
4000
4008
  - tracks/julia/exercises/.keep
4001
4009
  - tracks/julia/img/.keep
4010
+ - tracks/julia/runtests.jl
4002
4011
  - tracks/kotlin/.git
4003
4012
  - tracks/kotlin/.gitignore
4004
4013
  - tracks/kotlin/.travis.yml
@@ -5199,7 +5208,6 @@ files:
5199
5208
  - tracks/pascal/exercises/saddle-points/uSaddlePointsExample.pas
5200
5209
  - tracks/pascal/exercises/saddle-points/uSaddlePointsTests.pas
5201
5210
  - tracks/pascal/img/.keep
5202
- - tracks/pascal/img/Delphi-icon.png.keep
5203
5211
  - tracks/pascal/img/icon.png
5204
5212
  - tracks/perl5/.git
5205
5213
  - tracks/perl5/.gitignore
Binary file