trackler 2.0.8.34 → 2.0.8.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/exercises/phone-number/src/example.c +6 -6
- data/tracks/c/exercises/phone-number/test/test_phone_number.c +50 -5
- data/tracks/csharp/exercises/beer-song/BeerSong.cs +2 -2
- data/tracks/csharp/exercises/beer-song/BeerSongTest.cs +390 -0
- data/tracks/csharp/exercises/beer-song/Example.cs +3 -8
- data/tracks/csharp/exercises/wordy/Example.cs +3 -3
- data/tracks/csharp/exercises/wordy/Wordy.cs +2 -2
- data/tracks/csharp/exercises/wordy/WordyTest.cs +35 -35
- data/tracks/csharp/generators/Data/CanonicalDataValue.cs +17 -3
- data/tracks/csharp/generators/Exercises/BeerSongExercise.cs +33 -0
- data/tracks/csharp/generators/Exercises/EqualityExercise.cs +6 -1
- data/tracks/csharp/generators/Exercises/FoodChainExercise.cs +1 -1
- data/tracks/csharp/generators/Exercises/HelloWorldExercise.cs +9 -0
- data/tracks/csharp/generators/Exercises/NthPrimeExercise.cs +7 -8
- data/tracks/csharp/generators/Exercises/WordyExercise.cs +20 -0
- data/tracks/csharp/generators/Methods/TestMethodOptions.cs +1 -0
- data/tracks/elixir/README.md +1 -1
- data/tracks/go/config.json +9 -0
- data/tracks/go/exercises/accumulate/accumulate.go +5 -0
- data/tracks/go/exercises/change/cases_test.go +83 -0
- data/tracks/go/exercises/change/change_test.go +48 -0
- data/tracks/go/exercises/change/example.go +153 -0
- data/tracks/go/exercises/change/example_gen.go +96 -0
- data/tracks/java/exercises/beer-song/src/example/java/BeerSong.java +4 -7
- data/tracks/java/exercises/beer-song/src/test/java/BeerSongTest.java +15 -7
- data/tracks/julia/img/icon.png +0 -0
- data/tracks/julia/img/icon.svg +49 -11
- data/tracks/objective-c/exercises/bracket-push/BracketPushExample.h +0 -1
- data/tracks/objective-c/exercises/bracket-push/BracketPushExample.m +41 -379
- data/tracks/objective-c/exercises/bracket-push/BracketPushTest.m +12 -32
- data/tracks/objective-c/exercises/sublist/SublistExample.h +8 -1
- data/tracks/objective-c/exercises/sublist/SublistExample.m +27 -42
- data/tracks/objective-c/exercises/sublist/SublistTest.m +17 -20
- data/tracks/python/exercises/say/say_test.py +16 -11
- data/tracks/scala/exercises/pangram/src/test/scala/PangramTest.scala +6 -5
- data/tracks/swift/exercises/bob/Sources/BobExample.swift +2 -2
- data/tracks/swift/exercises/bob/Tests/BobTests/BobTests.swift +8 -8
- metadata +11 -3
- 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
|
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
|
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
|
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
|
17
|
+
public static int Answer(string question)
|
18
18
|
{
|
19
|
-
var parsedProblem = ParseProblem(
|
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,101 +1,101 @@
|
|
1
|
-
using System;
|
2
1
|
using Xunit;
|
2
|
+
using System;
|
3
3
|
|
4
|
-
public class
|
4
|
+
public class WordyTest
|
5
5
|
{
|
6
6
|
[Fact]
|
7
|
-
public void
|
7
|
+
public void Addition()
|
8
8
|
{
|
9
|
-
Assert.Equal(2,
|
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
|
13
|
+
public void More_addition()
|
14
14
|
{
|
15
|
-
Assert.Equal(55,
|
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
|
19
|
+
public void Addition_with_negative_numbers()
|
20
20
|
{
|
21
|
-
Assert.Equal(-11,
|
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
|
25
|
+
public void Large_addition()
|
26
26
|
{
|
27
|
-
Assert.Equal(45801,
|
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
|
31
|
+
public void Subtraction()
|
32
32
|
{
|
33
|
-
Assert.Equal(16,
|
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
|
37
|
+
public void Multiplication()
|
38
38
|
{
|
39
|
-
Assert.Equal(-75,
|
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
|
43
|
+
public void Division()
|
44
44
|
{
|
45
|
-
Assert.Equal(-11,
|
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
|
49
|
+
public void Multiple_additions()
|
50
50
|
{
|
51
|
-
Assert.Equal(3,
|
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
|
55
|
+
public void Addition_and_subtraction()
|
56
56
|
{
|
57
|
-
Assert.Equal(8,
|
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
|
61
|
+
public void Multiple_subtraction()
|
62
62
|
{
|
63
|
-
Assert.Equal(3,
|
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
|
67
|
+
public void Subtraction_then_addition()
|
68
68
|
{
|
69
|
-
Assert.Equal(14,
|
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
|
73
|
+
public void Multiple_multiplication()
|
74
74
|
{
|
75
|
-
Assert.Equal(-12,
|
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
|
79
|
+
public void Addition_and_multiplication()
|
80
80
|
{
|
81
|
-
Assert.Equal(-8,
|
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
|
85
|
+
public void Multiple_division()
|
86
86
|
{
|
87
|
-
Assert.Equal(2,
|
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
|
91
|
+
public void Unknown_operation()
|
92
92
|
{
|
93
|
-
Assert.Throws<ArgumentException>(() =>
|
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
|
97
|
+
public void Non_math_question()
|
98
98
|
{
|
99
|
-
Assert.Throws<ArgumentException>(() =>
|
99
|
+
Assert.Throws<ArgumentException>(() => Wordy.Answer("Who is the President of the United States?"));
|
100
100
|
}
|
101
|
-
}
|
101
|
+
}
|
@@ -1,10 +1,24 @@
|
|
1
|
-
using
|
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
|
8
|
-
|
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
|
-
|
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.
|
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"] };
|
@@ -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
|
13
|
+
protected override TestMethodOptions CreateTestMethodOptions(CanonicalData canonicalData, CanonicalDataCase canonicalDataCase, int index)
|
13
14
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
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
|
}
|
data/tracks/elixir/README.md
CHANGED
@@ -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
|
|
data/tracks/go/config.json
CHANGED
@@ -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
|
+
}
|