trackler 2.0.8.34 → 2.0.8.35

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/c/exercises/phone-number/src/example.c +6 -6
  4. data/tracks/c/exercises/phone-number/test/test_phone_number.c +50 -5
  5. data/tracks/csharp/exercises/beer-song/BeerSong.cs +2 -2
  6. data/tracks/csharp/exercises/beer-song/BeerSongTest.cs +390 -0
  7. data/tracks/csharp/exercises/beer-song/Example.cs +3 -8
  8. data/tracks/csharp/exercises/wordy/Example.cs +3 -3
  9. data/tracks/csharp/exercises/wordy/Wordy.cs +2 -2
  10. data/tracks/csharp/exercises/wordy/WordyTest.cs +35 -35
  11. data/tracks/csharp/generators/Data/CanonicalDataValue.cs +17 -3
  12. data/tracks/csharp/generators/Exercises/BeerSongExercise.cs +33 -0
  13. data/tracks/csharp/generators/Exercises/EqualityExercise.cs +6 -1
  14. data/tracks/csharp/generators/Exercises/FoodChainExercise.cs +1 -1
  15. data/tracks/csharp/generators/Exercises/HelloWorldExercise.cs +9 -0
  16. data/tracks/csharp/generators/Exercises/NthPrimeExercise.cs +7 -8
  17. data/tracks/csharp/generators/Exercises/WordyExercise.cs +20 -0
  18. data/tracks/csharp/generators/Methods/TestMethodOptions.cs +1 -0
  19. data/tracks/elixir/README.md +1 -1
  20. data/tracks/go/config.json +9 -0
  21. data/tracks/go/exercises/accumulate/accumulate.go +5 -0
  22. data/tracks/go/exercises/change/cases_test.go +83 -0
  23. data/tracks/go/exercises/change/change_test.go +48 -0
  24. data/tracks/go/exercises/change/example.go +153 -0
  25. data/tracks/go/exercises/change/example_gen.go +96 -0
  26. data/tracks/java/exercises/beer-song/src/example/java/BeerSong.java +4 -7
  27. data/tracks/java/exercises/beer-song/src/test/java/BeerSongTest.java +15 -7
  28. data/tracks/julia/img/icon.png +0 -0
  29. data/tracks/julia/img/icon.svg +49 -11
  30. data/tracks/objective-c/exercises/bracket-push/BracketPushExample.h +0 -1
  31. data/tracks/objective-c/exercises/bracket-push/BracketPushExample.m +41 -379
  32. data/tracks/objective-c/exercises/bracket-push/BracketPushTest.m +12 -32
  33. data/tracks/objective-c/exercises/sublist/SublistExample.h +8 -1
  34. data/tracks/objective-c/exercises/sublist/SublistExample.m +27 -42
  35. data/tracks/objective-c/exercises/sublist/SublistTest.m +17 -20
  36. data/tracks/python/exercises/say/say_test.py +16 -11
  37. data/tracks/scala/exercises/pangram/src/test/scala/PangramTest.scala +6 -5
  38. data/tracks/swift/exercises/bob/Sources/BobExample.swift +2 -2
  39. data/tracks/swift/exercises/bob/Tests/BobTests/BobTests.swift +8 -8
  40. metadata +11 -3
  41. data/tracks/csharp/exercises/beer-song/BeerTest.cs +0 -22
@@ -1,6 +1,6 @@
1
1
  using System.Linq;
2
2
 
3
- public static class Beer
3
+ public static class BeerSong
4
4
  {
5
5
  public static string Verse(int number)
6
6
  {
@@ -17,11 +17,6 @@ public static string Verse(int number)
17
17
  }
18
18
  }
19
19
 
20
- public static string Sing(int start, int stop)
21
- {
22
- return Enumerable.Range(stop, start - stop + 1)
23
- .Reverse()
24
- .Select(Verse)
25
- .Aggregate("", (acc, verse) => acc + verse + "\n");
26
- }
20
+ public static string Verses(int begin, int end)
21
+ => string.Join("\n", Enumerable.Range(end, begin - end + 1).Reverse().Select(Verse));
27
22
  }
@@ -2,7 +2,7 @@
2
2
  using System.Collections.Generic;
3
3
  using System.Text.RegularExpressions;
4
4
 
5
- public static class WordProblem
5
+ public static class Wordy
6
6
  {
7
7
  private static readonly Regex VariableAndOperatorGroupsRegex =
8
8
  new Regex(string.Format(@"{0} {1} {0}\s*{1}*\s*{0}*", @"(-?\d+)", "(plus|minus|multiplied by|divided by)"));
@@ -14,9 +14,9 @@ public static class WordProblem
14
14
  { "divided by", (x, y) => x / y },
15
15
  };
16
16
 
17
- public static int Solve(string problem)
17
+ public static int Answer(string question)
18
18
  {
19
- var parsedProblem = ParseProblem(problem);
19
+ var parsedProblem = ParseProblem(question);
20
20
  var firstPass = Operations[parsedProblem.Operation1](parsedProblem.X, parsedProblem.Y);
21
21
  if (parsedProblem.Operation2.Length == 0)
22
22
  return firstPass;
@@ -1,8 +1,8 @@
1
1
  using System;
2
2
 
3
- public static class WordProblem
3
+ public static class Wordy
4
4
  {
5
- public static int Solve(string problem)
5
+ public static int Answer(string question)
6
6
  {
7
7
  throw new NotImplementedException("You need to implement this function.");
8
8
  }
@@ -1,101 +1,101 @@
1
- using System;
2
1
  using Xunit;
2
+ using System;
3
3
 
4
- public class WordProblemTest
4
+ public class WordyTest
5
5
  {
6
6
  [Fact]
7
- public void Can_parse_and_solve_addition_problems()
7
+ public void Addition()
8
8
  {
9
- Assert.Equal(2, WordProblem.Solve("What is 1 plus 1?"));
9
+ Assert.Equal(2, Wordy.Answer("What is 1 plus 1?"));
10
10
  }
11
11
 
12
12
  [Fact(Skip = "Remove to run test")]
13
- public void Can_add_double_digit_numbers()
13
+ public void More_addition()
14
14
  {
15
- Assert.Equal(55, WordProblem.Solve("What is 53 plus 2?"));
15
+ Assert.Equal(55, Wordy.Answer("What is 53 plus 2?"));
16
16
  }
17
17
 
18
18
  [Fact(Skip = "Remove to run test")]
19
- public void Can_add_negative_numbers()
19
+ public void Addition_with_negative_numbers()
20
20
  {
21
- Assert.Equal(-11, WordProblem.Solve("What is -1 plus -10?"));
21
+ Assert.Equal(-11, Wordy.Answer("What is -1 plus -10?"));
22
22
  }
23
23
 
24
24
  [Fact(Skip = "Remove to run test")]
25
- public void Can_add_large_numbers()
25
+ public void Large_addition()
26
26
  {
27
- Assert.Equal(45801, WordProblem.Solve("What is 123 plus 45678?"));
27
+ Assert.Equal(45801, Wordy.Answer("What is 123 plus 45678?"));
28
28
  }
29
29
 
30
30
  [Fact(Skip = "Remove to run test")]
31
- public void Can_parse_and_solve_subtraction_problems()
31
+ public void Subtraction()
32
32
  {
33
- Assert.Equal(16, WordProblem.Solve("What is 4 minus -12"));
33
+ Assert.Equal(16, Wordy.Answer("What is 4 minus -12?"));
34
34
  }
35
35
 
36
36
  [Fact(Skip = "Remove to run test")]
37
- public void Can_parse_and_solve_multiplication_problems()
37
+ public void Multiplication()
38
38
  {
39
- Assert.Equal(-75, WordProblem.Solve("What is -3 multiplied by 25?"));
39
+ Assert.Equal(-75, Wordy.Answer("What is -3 multiplied by 25?"));
40
40
  }
41
41
 
42
42
  [Fact(Skip = "Remove to run test")]
43
- public void Can_parse_and_solve_division_problems()
43
+ public void Division()
44
44
  {
45
- Assert.Equal(-11, WordProblem.Solve("What is 33 divided by -3?"));
45
+ Assert.Equal(-11, Wordy.Answer("What is 33 divided by -3?"));
46
46
  }
47
47
 
48
48
  [Fact(Skip = "Remove to run test")]
49
- public void Can_add_twice()
49
+ public void Multiple_additions()
50
50
  {
51
- Assert.Equal(3, WordProblem.Solve("What is 1 plus 1 plus 1?"));
51
+ Assert.Equal(3, Wordy.Answer("What is 1 plus 1 plus 1?"));
52
52
  }
53
53
 
54
54
  [Fact(Skip = "Remove to run test")]
55
- public void Can_add_then_subtract()
55
+ public void Addition_and_subtraction()
56
56
  {
57
- Assert.Equal(8, WordProblem.Solve("What is 1 plus 5 minus -2?"));
57
+ Assert.Equal(8, Wordy.Answer("What is 1 plus 5 minus -2?"));
58
58
  }
59
59
 
60
60
  [Fact(Skip = "Remove to run test")]
61
- public void Can_subtract_twice()
61
+ public void Multiple_subtraction()
62
62
  {
63
- Assert.Equal(3, WordProblem.Solve("What is 20 minus 4 minus 13?"));
63
+ Assert.Equal(3, Wordy.Answer("What is 20 minus 4 minus 13?"));
64
64
  }
65
65
 
66
66
  [Fact(Skip = "Remove to run test")]
67
- public void Can_subtract_then_add()
67
+ public void Subtraction_then_addition()
68
68
  {
69
- Assert.Equal(14, WordProblem.Solve("What is 17 minus 6 plus 3?"));
69
+ Assert.Equal(14, Wordy.Answer("What is 17 minus 6 plus 3?"));
70
70
  }
71
71
 
72
72
  [Fact(Skip = "Remove to run test")]
73
- public void Can_multiply_twice()
73
+ public void Multiple_multiplication()
74
74
  {
75
- Assert.Equal(-12, WordProblem.Solve("What is 2 multiplied by -2 multiplied by 3?"));
75
+ Assert.Equal(-12, Wordy.Answer("What is 2 multiplied by -2 multiplied by 3?"));
76
76
  }
77
77
 
78
78
  [Fact(Skip = "Remove to run test")]
79
- public void Can_add_then_multiply()
79
+ public void Addition_and_multiplication()
80
80
  {
81
- Assert.Equal(-8, WordProblem.Solve("What is -3 plus 7 multiplied by -2?"));
81
+ Assert.Equal(-8, Wordy.Answer("What is -3 plus 7 multiplied by -2?"));
82
82
  }
83
83
 
84
84
  [Fact(Skip = "Remove to run test")]
85
- public void Can_divide_twice()
85
+ public void Multiple_division()
86
86
  {
87
- Assert.Equal(2, WordProblem.Solve("What is -12 divided by 2 divided by -3?"));
87
+ Assert.Equal(2, Wordy.Answer("What is -12 divided by 2 divided by -3?"));
88
88
  }
89
89
 
90
90
  [Fact(Skip = "Remove to run test")]
91
- public void Cubed_is_too_advanced()
91
+ public void Unknown_operation()
92
92
  {
93
- Assert.Throws<ArgumentException>(() => WordProblem.Solve("What is 53 cubed?"));
93
+ Assert.Throws<ArgumentException>(() => Wordy.Answer("What is 52 cubed?"));
94
94
  }
95
95
 
96
96
  [Fact(Skip = "Remove to run test")]
97
- public void Irrelevant_problems_are_not_valid()
97
+ public void Non_math_question()
98
98
  {
99
- Assert.Throws<ArgumentException>(() => WordProblem.Solve("Who is the president of the United States?"));
99
+ Assert.Throws<ArgumentException>(() => Wordy.Answer("Who is the President of the United States?"));
100
100
  }
101
- }
101
+ }
@@ -1,10 +1,24 @@
1
- using Newtonsoft.Json.Linq;
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using Newtonsoft.Json.Linq;
2
4
 
3
5
  namespace Generators.Data
4
6
  {
5
7
  public static class CanonicalDataValue
6
8
  {
7
- public static string StringArrayToString(object expected)
8
- => string.Join("\\n\"+\n\"", ((JArray) expected).Values<string>());
9
+ public static string ExpectedToMultiLineString(object expected)
10
+ {
11
+ switch (expected)
12
+ {
13
+ case IEnumerable<string> enumerable:
14
+ return string.Join("\\n\"+\n\"", enumerable);
15
+ case JArray jarray:
16
+ return ExpectedToMultiLineString(((JArray) expected).Values<string>());
17
+ case string str:
18
+ return ExpectedToMultiLineString(str.Split('\n'));
19
+ default:
20
+ throw new ArgumentException("Cannot convert expected value to multil-ine string.");
21
+ }
22
+ }
9
23
  }
10
24
  }
@@ -0,0 +1,33 @@
1
+ using Generators.Data;
2
+ using Generators.Methods;
3
+
4
+ namespace Generators.Exercises
5
+ {
6
+ public class BeerSongExercise : EqualityExercise
7
+ {
8
+ public BeerSongExercise() : base("beer-song")
9
+ {
10
+ }
11
+
12
+ protected override TestMethodData CreateTestMethodData(CanonicalData canonicalData, CanonicalDataCase canonicalDataCase, int index)
13
+ {
14
+ var testMethodData = base.CreateTestMethodData(canonicalData, canonicalDataCase, index);
15
+
16
+ testMethodData.Options.UseVariableForExpected = true;
17
+ testMethodData.Options.FormatExpected = true;
18
+
19
+ testMethodData.CanonicalDataCase.Expected = CanonicalDataValue.ExpectedToMultiLineString(testMethodData.CanonicalDataCase.Expected);
20
+
21
+ if (testMethodData.CanonicalDataCase.Property == "verse")
22
+ testMethodData.Options.InputProperty = "number";
23
+ else
24
+ testMethodData.CanonicalDataCase.Input = new[]
25
+ {
26
+ testMethodData.CanonicalDataCase.Data["beginning"],
27
+ testMethodData.CanonicalDataCase.Data["end"]
28
+ };
29
+
30
+ return testMethodData;
31
+ }
32
+ }
33
+ }
@@ -9,6 +9,11 @@ protected EqualityExercise(string name) : base(name)
9
9
  }
10
10
 
11
11
  protected override TestMethod CreateTestMethod(TestMethodData testMethodData)
12
- => CreateEqualityTestMethod(testMethodData);
12
+ {
13
+ if (testMethodData.Options.ThrowExceptionWhenExpectedValueEquals(testMethodData.CanonicalDataCase.Expected))
14
+ return CreateExceptionTestMethod(testMethodData);
15
+
16
+ return CreateEqualityTestMethod(testMethodData);
17
+ }
13
18
  }
14
19
  }
@@ -14,7 +14,7 @@ protected override TestMethodData CreateTestMethodData(CanonicalData canonicalDa
14
14
  var testMethodData = base.CreateTestMethodData(canonicalData, canonicalDataCase, index);
15
15
 
16
16
  testMethodData.Options.UseVariableForExpected = true;
17
- testMethodData.CanonicalDataCase.Expected = CanonicalDataValue.StringArrayToString(canonicalDataCase.Expected);
17
+ testMethodData.CanonicalDataCase.Expected = CanonicalDataValue.ExpectedToMultiLineString(testMethodData.CanonicalDataCase.Expected);
18
18
 
19
19
  if (testMethodData.CanonicalDataCase.Data.ContainsKey("end verse"))
20
20
  testMethodData.CanonicalDataCase.Input = new[] { testMethodData.CanonicalDataCase.Data["start verse"], testMethodData.CanonicalDataCase.Data["end verse"] };
@@ -0,0 +1,9 @@
1
+ namespace Generators.Exercises
2
+ {
3
+ public class HelloWorldExercise : EqualityExercise
4
+ {
5
+ public HelloWorldExercise() : base("hello-world")
6
+ {
7
+ }
8
+ }
9
+ }
@@ -1,4 +1,5 @@
1
1
  using System;
2
+ using Generators.Data;
2
3
  using Generators.Methods;
3
4
 
4
5
  namespace Generators.Exercises
@@ -9,15 +10,13 @@ public NthPrimeExercise() : base("nth-prime")
9
10
  {
10
11
  }
11
12
 
12
- protected override TestMethod CreateTestMethod(TestMethodData testMethodData)
13
+ protected override TestMethodOptions CreateTestMethodOptions(CanonicalData canonicalData, CanonicalDataCase canonicalDataCase, int index)
13
14
  {
14
- if (testMethodData.CanonicalDataCase.Expected is bool b && !b)
15
- {
16
- testMethodData.Options.ExceptionType = typeof(ArgumentOutOfRangeException);
17
- return CreateExceptionTestMethod(testMethodData);
18
- }
15
+ var testMethodOptions = base.CreateTestMethodOptions(canonicalData, canonicalDataCase, index);
16
+ testMethodOptions.ExceptionType = typeof(ArgumentOutOfRangeException);
17
+ testMethodOptions.ThrowExceptionWhenExpectedValueEquals = x => x is bool;
19
18
 
20
- return CreateEqualityTestMethod(testMethodData);
21
- }
19
+ return testMethodOptions;
20
+ }
22
21
  }
23
22
  }
@@ -0,0 +1,20 @@
1
+ using Generators.Data;
2
+ using Generators.Methods;
3
+
4
+ namespace Generators.Exercises
5
+ {
6
+ public class WordyExercise : EqualityExercise
7
+ {
8
+ public WordyExercise() : base("wordy")
9
+ {
10
+ }
11
+
12
+ protected override TestMethodOptions CreateTestMethodOptions(CanonicalData canonicalData, CanonicalDataCase canonicalDataCase, int index)
13
+ {
14
+ var testMethodOptions = base.CreateTestMethodOptions(canonicalData, canonicalDataCase, index);
15
+ testMethodOptions.ThrowExceptionWhenExpectedValueEquals = x => x is bool;
16
+
17
+ return testMethodOptions;
18
+ }
19
+ }
20
+ }
@@ -10,5 +10,6 @@ public class TestMethodOptions
10
10
  public bool UseVariableForExpected { get; set; } = false;
11
11
  public Type ExceptionType { get; set; } = typeof(ArgumentException);
12
12
  public TestedMethodType TestedMethodType { get; set; } = TestedMethodType.Static;
13
+ public Func<object, bool> ThrowExceptionWhenExpectedValueEquals { get; set; } = (x) => false;
13
14
  }
14
15
  }
@@ -7,7 +7,7 @@ Exercism Exercises in Elixir
7
7
 
8
8
  The exercises currently target Elixir 1.3.2 and Erlang/OTP 19. Detailed installation instructions can be found at [http://elixir-lang.org/install.html](http://elixir-lang.org/install.html).
9
9
 
10
- ##Contributing
10
+ ## Contributing
11
11
 
12
12
  Thank you so much for contributing! :tada:
13
13
 
@@ -496,6 +496,15 @@
496
496
  "difficulty": 1,
497
497
  "slug": "forth",
498
498
  "topics": []
499
+ },
500
+ {
501
+ "difficulty": 1,
502
+ "slug": "change",
503
+ "topics": [
504
+ "Control-flow (loops)",
505
+ "Arrays",
506
+ "Algorithms"
507
+ ]
499
508
  }
500
509
  ]
501
510
  }
@@ -0,0 +1,5 @@
1
+ package accumulate
2
+
3
+ const testVersion = 1
4
+
5
+ func Accumulate([]string, func(string) string) []string
@@ -0,0 +1,83 @@
1
+ package change
2
+
3
+ // Source: exercism/x-common
4
+ // Commit: 3d8b5b3 change: Fix canonical-data.json formatting
5
+
6
+ var testCases = []struct {
7
+ description string
8
+ coins []int
9
+ target int
10
+ valid bool // true => no error, false => error expected
11
+ expectedChange []int // when .valid == true, the expected change coins
12
+ }{
13
+ {
14
+ "single coin change",
15
+ []int{1, 5, 10, 25, 100},
16
+ 25,
17
+ true,
18
+ []int{25},
19
+ },
20
+ {
21
+ "multiple coin change",
22
+ []int{1, 5, 10, 25, 100},
23
+ 15,
24
+ true,
25
+ []int{5, 10},
26
+ },
27
+ {
28
+ "change with Lilliputian Coins",
29
+ []int{1, 4, 15, 20, 50},
30
+ 23,
31
+ true,
32
+ []int{4, 4, 15},
33
+ },
34
+ {
35
+ "change with Lower Elbonia Coins",
36
+ []int{1, 5, 10, 21, 25},
37
+ 63,
38
+ true,
39
+ []int{21, 21, 21},
40
+ },
41
+ {
42
+ "large target values",
43
+ []int{1, 2, 5, 10, 20, 50, 100},
44
+ 999,
45
+ true,
46
+ []int{2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100},
47
+ },
48
+ {
49
+ "possible change without unit coins available",
50
+ []int{2, 5, 10, 20, 50},
51
+ 21,
52
+ true,
53
+ []int{2, 2, 2, 5, 10},
54
+ },
55
+ {
56
+ "no coins make 0 change",
57
+ []int{1, 5, 10, 21, 25},
58
+ 0,
59
+ true,
60
+ []int{},
61
+ },
62
+ {
63
+ "error testing for change smaller than the smallest of coins",
64
+ []int{5, 10},
65
+ 3,
66
+ false,
67
+ []int(nil),
68
+ },
69
+ {
70
+ "error if no combination can add up to target",
71
+ []int{5, 10},
72
+ 94,
73
+ false,
74
+ []int(nil),
75
+ },
76
+ {
77
+ "cannot find negative change values",
78
+ []int{1, 2, 5},
79
+ -5,
80
+ false,
81
+ []int(nil),
82
+ },
83
+ }