trackler 2.2.1.10 → 2.2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/CONTRIBUTING.md +1 -1
- data/problem-specifications/TOPICS.txt +1 -0
- data/problem-specifications/exercises/accumulate/description.md +0 -3
- data/problem-specifications/exercises/hamming/canonical-data.json +3 -3
- data/problem-specifications/exercises/house/canonical-data.json +322 -0
- data/problem-specifications/exercises/palindrome-products/description.md +2 -2
- data/problem-specifications/exercises/simple-cipher/description.md +1 -1
- data/tracks/bash/config.json +0 -11
- data/tracks/cpp/docs/ABOUT.md +12 -37
- data/tracks/csharp/config.json +37 -0
- data/tracks/csharp/config/maintainers.json +10 -0
- data/tracks/csharp/docs/ABOUT.md +1 -1
- data/tracks/csharp/docs/RESOURCES.md +2 -2
- data/tracks/csharp/exercises/Exercises.All.sln +50 -8
- data/tracks/csharp/exercises/Exercises.Default.sln +50 -8
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.cs +9 -0
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.csproj +18 -0
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjectureTest.cs +43 -0
- data/tracks/csharp/exercises/collatz-conjecture/Example.cs +30 -0
- data/tracks/csharp/exercises/collatz-conjecture/README.md +38 -0
- data/tracks/csharp/exercises/diamond/Diamond.cs +1 -1
- data/tracks/csharp/exercises/diamond/Diamond.csproj +3 -1
- data/tracks/csharp/exercises/diamond/DiamondTest.cs +39 -21
- data/tracks/csharp/exercises/diamond/Example.cs +2 -2
- data/tracks/csharp/exercises/diamond/HINTS.md +3 -1
- data/tracks/csharp/exercises/spiral-matrix/Example.cs +40 -0
- data/tracks/csharp/exercises/spiral-matrix/README.md +36 -0
- data/tracks/csharp/exercises/spiral-matrix/SpiralMatrix.cs +9 -0
- data/tracks/csharp/exercises/spiral-matrix/SpiralMatrix.csproj +18 -0
- data/tracks/csharp/exercises/spiral-matrix/SpiralMatrixTest.cs +78 -0
- data/tracks/csharp/exercises/two-fer/Example.cs +16 -0
- data/tracks/csharp/exercises/two-fer/README.md +25 -0
- data/tracks/csharp/exercises/two-fer/TwoFer.cs +9 -0
- data/tracks/csharp/exercises/two-fer/TwoFer.csproj +18 -0
- data/tracks/csharp/exercises/two-fer/TwoFerTest.cs +24 -0
- data/tracks/dart/README.md +1 -1
- data/tracks/dart/docs/EXERCISE_README_INSERT.md +9 -0
- data/tracks/dart/docs/INSTALLATION.md +13 -0
- data/tracks/dart/docs/LEARNING.md +6 -0
- data/tracks/dart/docs/RESOURCES.md +7 -0
- data/tracks/dart/docs/TESTS.md +133 -0
- data/tracks/delphi/docs/ABOUT.md +18 -5
- data/tracks/delphi/docs/Getting_Started_Guide.md +930 -0
- data/tracks/delphi/exercises/hamming/uHammingExample.pas +1 -1
- data/tracks/delphi/exercises/hamming/uHammingTests.pas +15 -15
- data/tracks/ecmascript/.travis.yml +2 -1
- data/tracks/ecmascript/Makefile +19 -8
- data/tracks/ecmascript/config.json +16 -0
- data/tracks/ecmascript/exercises/accumulate/package.json +5 -5
- data/tracks/ecmascript/exercises/acronym/package.json +5 -5
- data/tracks/ecmascript/exercises/all-your-base/package.json +5 -5
- data/tracks/ecmascript/exercises/allergies/package.json +5 -5
- data/tracks/ecmascript/exercises/alphametics/package.json +5 -5
- data/tracks/ecmascript/exercises/anagram/package.json +5 -5
- data/tracks/ecmascript/exercises/atbash-cipher/package.json +5 -5
- data/tracks/ecmascript/exercises/beer-song/package.json +5 -5
- data/tracks/ecmascript/exercises/binary-search-tree/package.json +5 -5
- data/tracks/ecmascript/exercises/binary-search/package.json +5 -5
- data/tracks/ecmascript/exercises/binary/package.json +5 -5
- data/tracks/ecmascript/exercises/bob/package.json +5 -5
- data/tracks/ecmascript/exercises/bracket-push/package.json +5 -5
- data/tracks/ecmascript/exercises/circular-buffer/package.json +5 -5
- data/tracks/ecmascript/exercises/clock/package.json +5 -5
- data/tracks/ecmascript/exercises/connect/package.json +5 -5
- data/tracks/ecmascript/exercises/crypto-square/package.json +5 -5
- data/tracks/ecmascript/exercises/custom-set/package.json +5 -5
- data/tracks/ecmascript/exercises/diamond/package.json +5 -5
- data/tracks/ecmascript/exercises/difference-of-squares/package.json +5 -5
- data/tracks/ecmascript/exercises/diffie-hellman/package.json +5 -5
- data/tracks/ecmascript/exercises/etl/package.json +5 -5
- data/tracks/ecmascript/exercises/flatten-array/package.json +5 -5
- data/tracks/ecmascript/exercises/food-chain/package.json +5 -5
- data/tracks/ecmascript/exercises/gigasecond/package.json +5 -5
- data/tracks/ecmascript/exercises/grade-school/package.json +5 -5
- data/tracks/ecmascript/exercises/grains/package.json +5 -5
- data/tracks/ecmascript/exercises/hamming/package.json +5 -5
- data/tracks/ecmascript/exercises/hello-world/package.json +5 -5
- data/tracks/ecmascript/exercises/hexadecimal/package.json +5 -5
- data/tracks/ecmascript/exercises/isogram/package.json +5 -5
- data/tracks/ecmascript/exercises/kindergarten-garden/package.json +5 -5
- data/tracks/ecmascript/exercises/largest-series-product/package.json +5 -5
- data/tracks/ecmascript/exercises/leap/package.json +5 -5
- data/tracks/ecmascript/exercises/linked-list/package.json +5 -5
- data/tracks/ecmascript/exercises/list-ops/package.json +5 -5
- data/tracks/ecmascript/exercises/luhn/package.json +5 -5
- data/tracks/ecmascript/exercises/matrix/package.json +5 -5
- data/tracks/ecmascript/exercises/meetup/package.json +5 -5
- data/tracks/ecmascript/exercises/minesweeper/package.json +5 -5
- data/tracks/ecmascript/exercises/nth-prime/package.json +5 -5
- data/tracks/ecmascript/exercises/ocr-numbers/package.json +5 -5
- data/tracks/ecmascript/exercises/octal/package.json +5 -5
- data/tracks/ecmascript/exercises/palindrome-products/package.json +5 -5
- data/tracks/ecmascript/exercises/pangram/package.json +5 -5
- data/tracks/ecmascript/exercises/pascals-triangle/package.json +5 -5
- data/tracks/ecmascript/exercises/perfect-numbers/package.json +5 -5
- data/tracks/ecmascript/exercises/phone-number/package.json +5 -5
- data/tracks/ecmascript/exercises/pig-latin/package.json +5 -5
- data/tracks/ecmascript/exercises/prime-factors/package.json +5 -5
- data/tracks/ecmascript/exercises/pythagorean-triplet/package.json +5 -5
- data/tracks/ecmascript/exercises/queen-attack/package.json +5 -5
- data/tracks/ecmascript/exercises/raindrops/package.json +5 -5
- data/tracks/ecmascript/exercises/rna-transcription/package.json +5 -5
- data/tracks/ecmascript/exercises/robot-name/package.json +5 -5
- data/tracks/ecmascript/exercises/robot-simulator/package.json +5 -5
- data/tracks/ecmascript/exercises/roman-numerals/package.json +5 -5
- data/tracks/ecmascript/exercises/run-length-encoding/README.md +59 -0
- data/tracks/ecmascript/exercises/run-length-encoding/example.js +13 -0
- data/tracks/ecmascript/exercises/run-length-encoding/package.json +69 -0
- data/tracks/ecmascript/exercises/run-length-encoding/run-length-encoding.spec.js +59 -0
- data/tracks/ecmascript/exercises/saddle-points/package.json +5 -5
- data/tracks/ecmascript/exercises/say/package.json +5 -5
- data/tracks/ecmascript/exercises/scrabble-score/package.json +5 -5
- data/tracks/ecmascript/exercises/secret-handshake/package.json +5 -5
- data/tracks/ecmascript/exercises/series/package.json +5 -5
- data/tracks/ecmascript/exercises/sieve/package.json +5 -5
- data/tracks/ecmascript/exercises/simple-cipher/package.json +5 -5
- data/tracks/ecmascript/exercises/space-age/package.json +5 -5
- data/tracks/ecmascript/exercises/strain/package.json +5 -5
- data/tracks/ecmascript/exercises/sublist/package.json +5 -5
- data/tracks/ecmascript/exercises/sum-of-multiples/package.json +5 -5
- data/tracks/ecmascript/exercises/triangle/package.json +5 -5
- data/tracks/ecmascript/exercises/trinary/package.json +5 -5
- data/tracks/ecmascript/exercises/twelve-days/package.json +6 -5
- data/tracks/ecmascript/exercises/two-bucket/package.json +5 -5
- data/tracks/ecmascript/exercises/word-count/package.json +5 -5
- data/tracks/ecmascript/exercises/wordy/package.json +5 -5
- data/tracks/ecmascript/package.json +5 -5
- data/tracks/ecmascript/yarn.lock +403 -152
- data/tracks/elixir/docs/ABOUT.md +7 -20
- data/tracks/erlang/docs/ABOUT.md +4 -6
- data/tracks/fsharp/config.json +2 -1
- data/tracks/fsharp/docs/ABOUT.md +6 -2
- data/tracks/gnu-apl/.gitignore +4 -0
- data/tracks/gnu-apl/.travis.yml +5 -0
- data/tracks/gnu-apl/LICENSE +21 -0
- data/tracks/gnu-apl/README.md +67 -0
- data/tracks/gnu-apl/bin/fetch-configlet +32 -0
- data/tracks/gnu-apl/config.json +15 -0
- data/tracks/{scala/exercises/binary-search/src/main/scala/BinarySearch.scala → gnu-apl/config/exercise-readme-insert.md} +0 -0
- data/tracks/gnu-apl/config/exercise-readme.go.tmpl +16 -0
- data/tracks/gnu-apl/config/maintainers.json +6 -0
- data/tracks/gnu-apl/docs/ABOUT.md +0 -0
- data/tracks/gnu-apl/docs/INSTALLATION.md +0 -0
- data/tracks/gnu-apl/docs/LEARNING.md +0 -0
- data/tracks/gnu-apl/docs/RESOURCES.md +0 -0
- data/tracks/gnu-apl/docs/TESTS.md +0 -0
- data/tracks/gnu-apl/img/.keep +0 -0
- data/tracks/go/docs/ABOUT.md +4 -2
- data/tracks/go/exercises/pangram/example.go +1 -1
- data/tracks/go/exercises/pangram/pangram.go +1 -1
- data/tracks/go/exercises/pangram/pangram_test.go +1 -3
- data/tracks/groovy/README.md +2 -0
- data/tracks/groovy/config.json +25 -20
- data/tracks/groovy/docs/ABOUT.md +10 -3
- data/tracks/groovy/exercises/difference-of-squares/DifferenceOfSquares.groovy +19 -0
- data/tracks/groovy/exercises/difference-of-squares/{SquaresSpec.groovy → DifferenceOfSquaresSpec.groovy} +3 -3
- data/tracks/groovy/exercises/difference-of-squares/Example.groovy +1 -1
- data/tracks/groovy/exercises/hamming/Hamming.groovy +7 -0
- data/tracks/groovy/exercises/leap/Example.groovy +2 -2
- data/tracks/groovy/exercises/leap/Leap.groovy +11 -0
- data/tracks/groovy/exercises/leap/LeapSpec.groovy +4 -4
- data/tracks/groovy/exercises/nth-prime/Example.groovy +1 -1
- data/tracks/groovy/exercises/nth-prime/NthPrime.groovy +7 -0
- data/tracks/groovy/exercises/nth-prime/{PrimeSpec.groovy → NthPrimeSpec.groovy} +6 -6
- data/tracks/groovy/exercises/phone-number/PhoneNumber.groovy +17 -0
- data/tracks/groovy/exercises/raindrops/Raindrops.groovy +7 -0
- data/tracks/groovy/exercises/rna-transcription/Example.groovy +1 -1
- data/tracks/groovy/exercises/rna-transcription/RnaTranscription.groovy +7 -0
- data/tracks/groovy/exercises/rna-transcription/{ComplementSpec.groovy → RnaTranscriptionSpec.groovy} +2 -2
- data/tracks/groovy/exercises/robot-name/Example.groovy +2 -2
- data/tracks/groovy/exercises/robot-name/RobotName.groovy +9 -0
- data/tracks/groovy/exercises/robot-name/{RobotSpec.groovy → RobotNameSpec.groovy} +6 -6
- data/tracks/groovy/exercises/roman-numerals/Example.groovy +2 -2
- data/tracks/groovy/exercises/roman-numerals/RomanNumerals.groovy +7 -0
- data/tracks/groovy/exercises/roman-numerals/{RomanSpec.groovy → RomanNumeralsSpec.groovy} +2 -2
- data/tracks/groovy/exercises/word-count/Example.groovy +2 -2
- data/tracks/groovy/exercises/word-count/{Phrase.groovy → WordCount.groovy} +2 -2
- data/tracks/groovy/exercises/word-count/WordCountSpec.groovy +47 -0
- data/tracks/java/config.json +84 -74
- data/tracks/java/docs/ABOUT.md +11 -5
- data/tracks/java/exercises/house/README.md +124 -0
- data/tracks/java/exercises/house/build.gradle +18 -0
- data/tracks/java/exercises/house/src/example/java/House.java +55 -0
- data/tracks/java/exercises/house/src/main/java/.keep +0 -0
- data/tracks/java/exercises/house/src/test/java/HouseTest.java +341 -0
- data/tracks/java/exercises/minesweeper/src/example/java/MinesweeperBoard.java +3 -3
- data/tracks/java/exercises/series/src/test/java/SeriesTest.java +6 -5
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/two-fer/src/test/java/TwoferTest.java +9 -0
- data/tracks/javascript/exercises/circular-buffer/circular-buffer.spec.js +8 -0
- data/tracks/javascript/exercises/simple-cipher/README.md +1 -1
- data/tracks/kotlin/docs/ABOUT.md +7 -10
- data/tracks/lisp/.travis.yml +26 -11
- data/tracks/purescript/docs/ABOUT.md +16 -0
- data/tracks/r/config.json +1 -1
- data/tracks/r/config/maintainers.json +9 -9
- data/tracks/r/docs/ABOUT.md +9 -11
- data/tracks/r/docs/snippet.txt +10 -0
- data/tracks/ruby/docs/ABOUT.md +5 -5
- data/tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb +1 -2
- data/tracks/ruby/exercises/space-age/.meta/generator/space_age_case.rb +1 -2
- data/tracks/ruby/exercises/sum-of-multiples/.meta/generator/sum_of_multiples_case.rb +1 -1
- data/tracks/ruby/lib/generator/exercise_case.rb +15 -0
- data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +42 -28
- data/tracks/scala/exercises/binary-search/example.scala +1 -1
- data/tracks/scala/exercises/binary-search/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/binary-search/src/test/scala/BinarySearchTest.scala +13 -22
- data/tracks/scala/exercises/bowling/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +30 -17
- data/tracks/scala/exercises/change/src/test/scala/ChangeTest.scala +14 -4
- data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +6 -4
- data/tracks/scala/exercises/food-chain/example.scala +4 -2
- data/tracks/scala/exercises/food-chain/src/test/scala/FoodChainTest.scala +170 -59
- data/tracks/scala/exercises/luhn/example.scala +9 -21
- data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +46 -10
- data/tracks/scala/testgen/src/main/scala/AlphametricsTestGenerator.scala +42 -0
- data/tracks/scala/testgen/src/main/scala/BinarySearchTestGenerator.scala +32 -42
- data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +22 -7
- data/tracks/scala/testgen/src/main/scala/ChangeTestGenerator.scala +37 -0
- data/tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala +25 -20
- data/tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala +13 -2
- data/tracks/scala/testgen/src/main/scala/LuhnTestGenerator.scala +15 -0
- data/tracks/scala/testgen/src/main/scala/TestBuilder.scala +10 -0
- data/tracks/sml/.travis.yml +9 -2
- data/tracks/sml/Makefile +42 -0
- data/tracks/sml/docs/EXERCISE_README_INSERT.md +21 -5
- data/tracks/sml/docs/RESOURCES.md +1 -1
- data/tracks/sml/docs/TESTS.md +2 -2
- metadata +67 -17
- data/tracks/bash/exercises/word-count/README.md +0 -24
- data/tracks/bash/exercises/word-count/example.awk +0 -12
- data/tracks/bash/exercises/word-count/example.sh +0 -21
- data/tracks/dart/.github/PULL_REQUEST_TEMPLATE.md +0 -23
- data/tracks/ecmascript/.babelrc +0 -3
- data/tracks/groovy/exercises/roman-numerals/Roman.groovy +0 -33
- data/tracks/groovy/exercises/word-count/PhraseSpec.groovy +0 -47
- data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +0 -11
@@ -1,4 +1,4 @@
|
|
1
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
2
|
|
3
3
|
<PropertyGroup>
|
4
4
|
<OutputType>Exe</OutputType>
|
@@ -10,6 +10,8 @@
|
|
10
10
|
</ItemGroup>
|
11
11
|
|
12
12
|
<ItemGroup>
|
13
|
+
<PackageReference Include="FsCheck" Version="2.9.0" />
|
14
|
+
<PackageReference Include="FsCheck.Xunit" Version="2.9.0" />
|
13
15
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
14
16
|
<PackageReference Include="xunit" Version="2.2.0" />
|
15
17
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
@@ -1,21 +1,28 @@
|
|
1
|
-
using
|
2
|
-
using
|
1
|
+
using Xunit;
|
2
|
+
using FsCheck.Xunit;
|
3
|
+
using FsCheck;
|
4
|
+
using System;
|
3
5
|
using System.Linq;
|
4
|
-
using Xunit;
|
5
6
|
|
6
7
|
public class DiamondTest
|
7
8
|
{
|
8
9
|
public static readonly char[] AllLetters = GetLetterRange('A', 'Z');
|
9
|
-
public static readonly IEnumerable<object[]> Letters = AllLetters.Select(letter => new[] { (object)letter });
|
10
|
-
private static char[] GetLetterRange(char min, char max) => Enumerable.Range(min, max - min + 1).Select(i => (char) i).ToArray();
|
11
10
|
private static string[] Rows(string x) => x.Split(new[] { '\n' }, StringSplitOptions.None);
|
12
11
|
|
13
12
|
private static string LeadingSpaces(string x) => x.Substring(0, x.IndexOfAny(AllLetters));
|
14
13
|
private static string TrailingSpaces(string x) => x.Substring(x.LastIndexOfAny(AllLetters) + 1);
|
14
|
+
private static char[] GetLetterRange(char min, char max) => Enumerable.Range(min, max - min + 1).Select(i => (char)i).ToArray();
|
15
15
|
|
16
|
-
[
|
17
|
-
|
18
|
-
|
16
|
+
[DiamondProperty]
|
17
|
+
public void Diamond_is_not_empty(char letter)
|
18
|
+
{
|
19
|
+
var actual = Diamond.Make(letter);
|
20
|
+
|
21
|
+
Assert.NotEmpty(actual);
|
22
|
+
}
|
23
|
+
|
24
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
25
|
+
public void First_row_contains_a(char letter)
|
19
26
|
{
|
20
27
|
var actual = Diamond.Make(letter);
|
21
28
|
var rows = Rows(actual);
|
@@ -24,21 +31,19 @@ public void First_row_contains_A(char letter)
|
|
24
31
|
Assert.Equal("A", firstRowCharacters);
|
25
32
|
}
|
26
33
|
|
27
|
-
[
|
28
|
-
[MemberData(nameof(Letters))]
|
34
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
29
35
|
public void All_rows_must_have_symmetric_contour(char letter)
|
30
36
|
{
|
31
37
|
var actual = Diamond.Make(letter);
|
32
38
|
var rows = Rows(actual);
|
33
39
|
|
34
|
-
Assert.All(rows, row =>
|
40
|
+
Assert.All(rows, row =>
|
35
41
|
{
|
36
42
|
Assert.Equal(LeadingSpaces(row), TrailingSpaces(row));
|
37
43
|
});
|
38
44
|
}
|
39
45
|
|
40
|
-
[
|
41
|
-
[MemberData(nameof(Letters))]
|
46
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
42
47
|
public void Top_of_figure_has_letters_in_correct_order(char letter)
|
43
48
|
{
|
44
49
|
var actual = Diamond.Make(letter);
|
@@ -46,11 +51,11 @@ public void Top_of_figure_has_letters_in_correct_order(char letter)
|
|
46
51
|
|
47
52
|
var expected = GetLetterRange('A', letter);
|
48
53
|
var firstNonSpaceLetters = rows.Take(expected.Length).Select(row => row.Trim()[0]);
|
54
|
+
|
49
55
|
Assert.Equal(firstNonSpaceLetters, expected);
|
50
56
|
}
|
51
57
|
|
52
|
-
[
|
53
|
-
[MemberData(nameof(Letters))]
|
58
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
54
59
|
public void Figure_is_symmetric_around_the_horizontal_axis(char letter)
|
55
60
|
{
|
56
61
|
var actual = Diamond.Make(letter);
|
@@ -62,8 +67,7 @@ public void Figure_is_symmetric_around_the_horizontal_axis(char letter)
|
|
62
67
|
Assert.Equal(bottom, top);
|
63
68
|
}
|
64
69
|
|
65
|
-
[
|
66
|
-
[MemberData(nameof(Letters))]
|
70
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
67
71
|
public void Diamond_has_square_shape(char letter)
|
68
72
|
{
|
69
73
|
var actual = Diamond.Make(letter);
|
@@ -77,8 +81,7 @@ public void Diamond_has_square_shape(char letter)
|
|
77
81
|
});
|
78
82
|
}
|
79
83
|
|
80
|
-
[
|
81
|
-
[MemberData(nameof(Letters))]
|
84
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
82
85
|
public void All_rows_except_top_and_bottom_have_two_identical_letters(char letter)
|
83
86
|
{
|
84
87
|
var actual = Diamond.Make(letter);
|
@@ -93,8 +96,7 @@ public void All_rows_except_top_and_bottom_have_two_identical_letters(char lette
|
|
93
96
|
});
|
94
97
|
}
|
95
98
|
|
96
|
-
[
|
97
|
-
[MemberData(nameof(Letters))]
|
99
|
+
[DiamondProperty(Skip = "Remove to run test")]
|
98
100
|
public void Bottom_left_corner_spaces_are_triangle(char letter)
|
99
101
|
{
|
100
102
|
var actual = Diamond.Make(letter);
|
@@ -107,4 +109,20 @@ public void Bottom_left_corner_spaces_are_triangle(char letter)
|
|
107
109
|
|
108
110
|
Assert.Equal(expected, spaceCounts);
|
109
111
|
}
|
112
|
+
}
|
113
|
+
|
114
|
+
public class DiamondPropertyAttribute : PropertyAttribute
|
115
|
+
{
|
116
|
+
public DiamondPropertyAttribute()
|
117
|
+
{
|
118
|
+
Arbitrary = new[] { typeof(LettersOnlyStringArbitrary) };
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
public static class LettersOnlyStringArbitrary
|
123
|
+
{
|
124
|
+
public static Arbitrary<char> Chars()
|
125
|
+
{
|
126
|
+
return Arb.Default.Char().Filter(x => x >= 'A' && x <= 'Z');
|
127
|
+
}
|
110
128
|
}
|
@@ -22,8 +22,8 @@ private static string MakeLine(int letterCount, Tuple<char, int> rowLetter)
|
|
22
22
|
var letter = rowLetter.Item1;
|
23
23
|
var row = rowLetter.Item2;
|
24
24
|
var outerSpaces = "".PadRight(letterCount - row - 1);
|
25
|
-
var innerSpaces = "".PadRight(row == 0 ? 0 : row*2 - 1);
|
25
|
+
var innerSpaces = "".PadRight(row == 0 ? 0 : row * 2 - 1);
|
26
26
|
|
27
27
|
return letter == 'A' ? $"{outerSpaces}{letter}{outerSpaces}" : $"{outerSpaces}{letter}{innerSpaces}{letter}{outerSpaces}";
|
28
28
|
}
|
29
|
-
}
|
29
|
+
}
|
@@ -6,4 +6,6 @@ The tests in this exercise are different from your usual tests. Normally, a test
|
|
6
6
|
|
7
7
|
For this exercise, the tests all verify a property of the diamond shape your code should be producing. Furthermore, all tests check if the property they test holds for all valid input letters ('A' to 'Z').
|
8
8
|
|
9
|
-
|
9
|
+
In order to facilitate propery-based testing, the tests in this exercise leverage the [FsCheck](https://www.nuget.org/packages/FsCheck) and [FsCheck.Xunit](https://packages.nuget.org/packages/FsCheck.Xunit/2.2.0) packages. To learn more about FsCheck, the documentation on the framework can be found [here](https://fscheck.github.io/FsCheck/).
|
10
|
+
|
11
|
+
If you would like more information on property-based testing, see [this article](http://www.erikschierboom.com/2016/02/22/property-based-testing/).
|
@@ -0,0 +1,40 @@
|
|
1
|
+
public static class SpiralMatrix
|
2
|
+
{
|
3
|
+
public static int[,] GetMatrix(int size)
|
4
|
+
{
|
5
|
+
var spiral = new int[size, size];
|
6
|
+
int numbersToPlace = size * size;
|
7
|
+
|
8
|
+
int currentSpiralValue = 1;
|
9
|
+
int firstPivot = 0, secondPivot = size - 1;
|
10
|
+
|
11
|
+
while (currentSpiralValue <= numbersToPlace)
|
12
|
+
{
|
13
|
+
for (int i = firstPivot; i <= secondPivot; i++)
|
14
|
+
{
|
15
|
+
spiral[firstPivot, i] = currentSpiralValue++;
|
16
|
+
}
|
17
|
+
|
18
|
+
for (int j = firstPivot + 1; j <= secondPivot; j++)
|
19
|
+
{
|
20
|
+
spiral[j, secondPivot] = currentSpiralValue++;
|
21
|
+
}
|
22
|
+
|
23
|
+
for (int i = secondPivot - 1; i >= firstPivot; i--)
|
24
|
+
{
|
25
|
+
spiral[secondPivot, i] = currentSpiralValue++;
|
26
|
+
}
|
27
|
+
|
28
|
+
for (int j = secondPivot - 1; j >= firstPivot + 1; j--)
|
29
|
+
{
|
30
|
+
spiral[j, firstPivot] = currentSpiralValue++;
|
31
|
+
}
|
32
|
+
|
33
|
+
firstPivot++;
|
34
|
+
secondPivot--;
|
35
|
+
}
|
36
|
+
|
37
|
+
return spiral;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Spiral Matrix
|
2
|
+
|
3
|
+
Given the size, return a square matrix of numbers in spiral order.
|
4
|
+
|
5
|
+
The matrix should be filled with natural numbers, starting from 1
|
6
|
+
in the top-left corner, increasing in an inward, clockwise spiral order,
|
7
|
+
like these examples:
|
8
|
+
|
9
|
+
##### Spiral matrix of size 3
|
10
|
+
|
11
|
+
```plain
|
12
|
+
1 2 3
|
13
|
+
8 9 4
|
14
|
+
7 6 5
|
15
|
+
```
|
16
|
+
|
17
|
+
##### Spiral matrix of size 4
|
18
|
+
|
19
|
+
```plain
|
20
|
+
1 2 3 4
|
21
|
+
12 13 14 5
|
22
|
+
11 16 15 6
|
23
|
+
10 9 8 7
|
24
|
+
```
|
25
|
+
|
26
|
+
### Submitting Exercises
|
27
|
+
|
28
|
+
Note that, when trying to submit an exercise, make sure the exercise file that you're submitting is in the `exercism/csharp/<exerciseName>` directory.
|
29
|
+
|
30
|
+
For example, if you're submitting `bob.cs` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/csharp/bob/bob.cs`.
|
31
|
+
|
32
|
+
## Source
|
33
|
+
Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension. [https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/](https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/)
|
34
|
+
|
35
|
+
## Submitting Incomplete Solutions
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
|
+
|
3
|
+
<PropertyGroup>
|
4
|
+
<OutputType>Exe</OutputType>
|
5
|
+
<TargetFramework>netcoreapp1.1</TargetFramework>
|
6
|
+
</PropertyGroup>
|
7
|
+
|
8
|
+
<ItemGroup>
|
9
|
+
<Compile Remove="Example.cs" />
|
10
|
+
</ItemGroup>
|
11
|
+
|
12
|
+
<ItemGroup>
|
13
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
|
14
|
+
<PackageReference Include="xunit" Version="2.2.0" />
|
15
|
+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
16
|
+
</ItemGroup>
|
17
|
+
|
18
|
+
</Project>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
public class SpiralMatrixTest
|
6
|
+
{
|
7
|
+
[Fact]
|
8
|
+
public void Empty_spiral()
|
9
|
+
{
|
10
|
+
var spiral = new int[,] { };
|
11
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(0));
|
12
|
+
}
|
13
|
+
|
14
|
+
[Fact(Skip = "Remove to run test")]
|
15
|
+
public void Trivial_spiral()
|
16
|
+
{
|
17
|
+
var spiral = new int[,]
|
18
|
+
{
|
19
|
+
{ 1 }
|
20
|
+
};
|
21
|
+
|
22
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(1));
|
23
|
+
}
|
24
|
+
|
25
|
+
[Fact(Skip = "Remove to run test")]
|
26
|
+
public void Spiral_of_size_2()
|
27
|
+
{
|
28
|
+
var spiral = new int[,]
|
29
|
+
{
|
30
|
+
{ 1, 2 },
|
31
|
+
{ 4, 3 }
|
32
|
+
};
|
33
|
+
|
34
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(2));
|
35
|
+
}
|
36
|
+
|
37
|
+
[Fact(Skip = "Remove to run test")]
|
38
|
+
public void Spiral_of_size_3()
|
39
|
+
{
|
40
|
+
var spiral = new int[,]
|
41
|
+
{
|
42
|
+
{ 1, 2, 3 },
|
43
|
+
{ 8, 9, 4 },
|
44
|
+
{ 7, 6, 5 }
|
45
|
+
};
|
46
|
+
|
47
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(3));
|
48
|
+
}
|
49
|
+
|
50
|
+
[Fact(Skip = "Remove to run test")]
|
51
|
+
public void Spiral_of_size_4()
|
52
|
+
{
|
53
|
+
var spiral = new int[,]
|
54
|
+
{
|
55
|
+
{ 1, 2, 3, 4 },
|
56
|
+
{ 12, 13, 14, 5 },
|
57
|
+
{ 11, 16, 15, 6 },
|
58
|
+
{ 10, 9, 8, 7}
|
59
|
+
};
|
60
|
+
|
61
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(4));
|
62
|
+
}
|
63
|
+
|
64
|
+
[Fact(Skip = "Remove to run test")]
|
65
|
+
public void Spiral_of_size_5()
|
66
|
+
{
|
67
|
+
var spiral = new int[,]
|
68
|
+
{
|
69
|
+
{ 1, 2, 3, 4, 5 },
|
70
|
+
{ 16, 17, 18, 19, 6 },
|
71
|
+
{ 15, 24, 25, 20, 7 },
|
72
|
+
{ 14, 23, 22, 21, 8 },
|
73
|
+
{ 13, 12, 11, 10, 9 }
|
74
|
+
};
|
75
|
+
|
76
|
+
Assert.Equal(spiral, SpiralMatrix.GetMatrix(5));
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
using System;
|
2
|
+
using System.Collections.Generic;
|
3
|
+
using System.Text;
|
4
|
+
|
5
|
+
public static class TwoFer
|
6
|
+
{
|
7
|
+
public static string GetResponse(string input = null)
|
8
|
+
{
|
9
|
+
if(string.IsNullOrWhiteSpace(input))
|
10
|
+
{
|
11
|
+
return "One for you, one for me.";
|
12
|
+
}
|
13
|
+
|
14
|
+
return string.Format("One for {0}, one for me.", input);
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Two Fer
|
2
|
+
|
3
|
+
Create a sentence of the form "One for X, one for me."
|
4
|
+
|
5
|
+
`Two-fer` or `2-fer` is short for two for one. One for you and one for me.
|
6
|
+
|
7
|
+
```plain
|
8
|
+
"One for X, one for me."
|
9
|
+
```
|
10
|
+
|
11
|
+
When X is a name or "you".
|
12
|
+
|
13
|
+
If the given name is "Alice", the result should be "One for Alice, one for me." If no name is given, the result should be "One for you, one for me."
|
14
|
+
|
15
|
+
### Submitting Exercises
|
16
|
+
|
17
|
+
Note that, when trying to submit an exercise, make sure the exercise file that you're submitting is in the `exercism/csharp/<exerciseName>` directory.
|
18
|
+
|
19
|
+
For example, if you're submitting `bob.cs` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/csharp/bob/bob.cs`.
|
20
|
+
|
21
|
+
## Source
|
22
|
+
This is an exercise to introduce users to basic programming constructs, just after Hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
|
23
|
+
|
24
|
+
## Submitting Incomplete Solutions
|
25
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
|
+
|
3
|
+
<PropertyGroup>
|
4
|
+
<OutputType>Exe</OutputType>
|
5
|
+
<TargetFramework>netcoreapp1.1</TargetFramework>
|
6
|
+
</PropertyGroup>
|
7
|
+
|
8
|
+
<ItemGroup>
|
9
|
+
<Compile Remove="Example.cs" />
|
10
|
+
</ItemGroup>
|
11
|
+
|
12
|
+
<ItemGroup>
|
13
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
14
|
+
<PackageReference Include="xunit" Version="2.2.0" />
|
15
|
+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
16
|
+
</ItemGroup>
|
17
|
+
|
18
|
+
</Project>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
public class TwoFerTest
|
6
|
+
{
|
7
|
+
[Fact]
|
8
|
+
public void No_name_given()
|
9
|
+
{
|
10
|
+
Assert.Equal("One for you, one for me.", TwoFer.GetResponse());
|
11
|
+
}
|
12
|
+
|
13
|
+
[Fact(Skip = "Remove to run test")]
|
14
|
+
public void Name_is_given()
|
15
|
+
{
|
16
|
+
Assert.Equal("One for Alice, one for me.", TwoFer.GetResponse("Alice"));
|
17
|
+
}
|
18
|
+
|
19
|
+
[Fact(Skip = "Remove to run test")]
|
20
|
+
public void Another_name_is_given()
|
21
|
+
{
|
22
|
+
Assert.Equal("One for Bob, one for me.", TwoFer.GetResponse("Bob"));
|
23
|
+
}
|
24
|
+
}
|