Skip to content

Commit 0ca68d6

Browse files
exercises: update to latest version
1 parent d91288c commit 0ca68d6

File tree

21 files changed

+259
-80
lines changed

21 files changed

+259
-80
lines changed

exercises/alphametics/AlphameticsTest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.2.0 of the canonical data.
1+
// This file was auto-generated based on version 1.3.0 of the canonical data.
22

33
using System;
44
using System.Collections.Generic;
@@ -31,6 +31,19 @@ public void Leading_zero_solution_is_invalid()
3131
Assert.Throws<ArgumentException>(() => Alphametics.Solve("ACA + DD == BD"));
3232
}
3333

34+
[Fact(Skip = "Remove to run test")]
35+
public void Puzzle_with_two_digits_final_carry()
36+
{
37+
var actual = Alphametics.Solve("A + A + A + A + A + A + A + A + A + A + A + B == BCC");
38+
var expected = new Dictionary<char, int>
39+
{
40+
['A'] = 9,
41+
['B'] = 1,
42+
['C'] = 0
43+
};
44+
Assert.Equal(expected, actual);
45+
}
46+
3447
[Fact(Skip = "Remove to run test")]
3548
public void Puzzle_with_four_letters()
3649
{

exercises/atbash-cipher/AtbashCipherTest.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.1.0 of the canonical data.
1+
// This file was auto-generated based on version 1.2.0 of the canonical data.
22

33
using Xunit;
44

@@ -75,4 +75,16 @@ public void Decode_all_the_letters()
7575
{
7676
Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AtbashCipher.Decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"));
7777
}
78+
79+
[Fact(Skip = "Remove to run test")]
80+
public void Decode_with_too_many_spaces()
81+
{
82+
Assert.Equal("exercism", AtbashCipher.Decode("vc vix r hn"));
83+
}
84+
85+
[Fact(Skip = "Remove to run test")]
86+
public void Decode_with_no_spaces()
87+
{
88+
Assert.Equal("anobstacleisoftenasteppingstone", AtbashCipher.Decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv"));
89+
}
7890
}

exercises/bracket-push/BracketPushTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.3.0 of the canonical data.
1+
// This file was auto-generated based on version 1.4.0 of the canonical data.
22

33
using Xunit;
44

@@ -95,6 +95,13 @@ public void Paired_and_wrong_nested_brackets()
9595
Assert.False(BracketPush.IsPaired(value));
9696
}
9797

98+
[Fact(Skip = "Remove to run test")]
99+
public void Paired_and_incomplete_brackets()
100+
{
101+
var value = "{}[";
102+
Assert.False(BracketPush.IsPaired(value));
103+
}
104+
98105
[Fact(Skip = "Remove to run test")]
99106
public void Math_expression()
100107
{

exercises/grep/GrepTest.cs

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.1.0 of the canonical data.
1+
// This file was auto-generated based on version 1.2.0 of the canonical data.
22

33
using System;
44
using System.IO;
@@ -139,6 +139,34 @@ public void One_file_no_matches_various_flags()
139139
Assert.Equal(expected, Grep.Match(pattern, flags, files));
140140
}
141141

142+
[Fact(Skip = "Remove to run test")]
143+
public void One_file_one_match_file_flag_takes_precedence_over_line_flag()
144+
{
145+
var pattern = "ten";
146+
var flags = "-n -l";
147+
var files = new[] { "iliad.txt" };
148+
var expected = "iliad.txt";
149+
Assert.Equal(expected, Grep.Match(pattern, flags, files));
150+
}
151+
152+
[Fact(Skip = "Remove to run test")]
153+
public void One_file_several_matches_inverted_and_match_entire_lines_flags()
154+
{
155+
var pattern = "Illustrious into Ades premature,";
156+
var flags = "-x -v";
157+
var files = new[] { "iliad.txt" };
158+
var expected =
159+
"Achilles sing, O Goddess! Peleus' son;\n" +
160+
"His wrath pernicious, who ten thousand woes\n" +
161+
"Caused to Achaia's host, sent many a soul\n" +
162+
"And Heroes gave (so stood the will of Jove)\n" +
163+
"To dogs and to all ravening fowls a prey,\n" +
164+
"When fierce dispute had separated once\n" +
165+
"The noble Chief Achilles from the son\n" +
166+
"Of Atreus, Agamemnon, King of men.";
167+
Assert.Equal(expected, Grep.Match(pattern, flags, files));
168+
}
169+
142170
[Fact(Skip = "Remove to run test")]
143171
public void Multiple_files_one_match_no_flags()
144172
{
@@ -251,6 +279,51 @@ public void Multiple_files_no_matches_various_flags()
251279
Assert.Equal(expected, Grep.Match(pattern, flags, files));
252280
}
253281

282+
[Fact(Skip = "Remove to run test")]
283+
public void Multiple_files_several_matches_file_flag_takes_precedence_over_line_number_flag()
284+
{
285+
var pattern = "who";
286+
var flags = "-n -l";
287+
var files = new[] { "iliad.txt", "midsummer-night.txt", "paradise-lost.txt" };
288+
var expected =
289+
"iliad.txt\n" +
290+
"paradise-lost.txt";
291+
Assert.Equal(expected, Grep.Match(pattern, flags, files));
292+
}
293+
294+
[Fact(Skip = "Remove to run test")]
295+
public void Multiple_files_several_matches_inverted_and_match_entire_lines_flags()
296+
{
297+
var pattern = "Illustrious into Ades premature,";
298+
var flags = "-x -v";
299+
var files = new[] { "iliad.txt", "midsummer-night.txt", "paradise-lost.txt" };
300+
var expected =
301+
"iliad.txt:Achilles sing, O Goddess! Peleus' son;\n" +
302+
"iliad.txt:His wrath pernicious, who ten thousand woes\n" +
303+
"iliad.txt:Caused to Achaia's host, sent many a soul\n" +
304+
"iliad.txt:And Heroes gave (so stood the will of Jove)\n" +
305+
"iliad.txt:To dogs and to all ravening fowls a prey,\n" +
306+
"iliad.txt:When fierce dispute had separated once\n" +
307+
"iliad.txt:The noble Chief Achilles from the son\n" +
308+
"iliad.txt:Of Atreus, Agamemnon, King of men.\n" +
309+
"midsummer-night.txt:I do entreat your grace to pardon me.\n" +
310+
"midsummer-night.txt:I know not by what power I am made bold,\n" +
311+
"midsummer-night.txt:Nor how it may concern my modesty,\n" +
312+
"midsummer-night.txt:In such a presence here to plead my thoughts;\n" +
313+
"midsummer-night.txt:But I beseech your grace that I may know\n" +
314+
"midsummer-night.txt:The worst that may befall me in this case,\n" +
315+
"midsummer-night.txt:If I refuse to wed Demetrius.\n" +
316+
"paradise-lost.txt:Of Mans First Disobedience, and the Fruit\n" +
317+
"paradise-lost.txt:Of that Forbidden Tree, whose mortal tast\n" +
318+
"paradise-lost.txt:Brought Death into the World, and all our woe,\n" +
319+
"paradise-lost.txt:With loss of Eden, till one greater Man\n" +
320+
"paradise-lost.txt:Restore us, and regain the blissful Seat,\n" +
321+
"paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n" +
322+
"paradise-lost.txt:Of Oreb, or of Sinai, didst inspire\n" +
323+
"paradise-lost.txt:That Shepherd, who first taught the chosen Seed";
324+
Assert.Equal(expected, Grep.Match(pattern, flags, files));
325+
}
326+
254327
private const string IliadFileName = "iliad.txt";
255328
private const string IliadContents =
256329
"Achilles sing, O Goddess! Peleus' son;\n" +

exercises/leap/LeapTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.3.0 of the canonical data.
1+
// This file was auto-generated based on version 1.4.0 of the canonical data.
22

33
using Xunit;
44

@@ -27,4 +27,10 @@ public void Year_divisible_by_400_is_leap_year()
2727
{
2828
Assert.True(Leap.IsLeapYear(2000));
2929
}
30+
31+
[Fact(Skip = "Remove to run test")]
32+
public void Year_divisible_by_200_not_divisible_by_400_is_common_year()
33+
{
34+
Assert.False(Leap.IsLeapYear(1800));
35+
}
3036
}

exercises/pangram/PangramTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.4.0 of the canonical data.
1+
// This file was auto-generated based on version 1.4.1 of the canonical data.
22

33
using Xunit;
44

exercises/phone-number/PhoneNumberTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.6.0 of the canonical data.
1+
// This file was auto-generated based on version 1.6.1 of the canonical data.
22

33
using System;
44
using Xunit;

exercises/protein-translation/ProteinTranslationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.1.0 of the canonical data.
1+
// This file was auto-generated based on version 1.1.1 of the canonical data.
22

33
using Xunit;
44

exercises/rest-api/RestApiTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.0.1 of the canonical data.
1+
// This file was auto-generated based on version 1.0.2 of the canonical data.
22

33
using Xunit;
44

@@ -98,4 +98,4 @@ public void Lender_owes_borrower_less_than_new_loan()
9898
var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{\"Bob\":1.0},\"balance\":1.0},{\"name\":\"Bob\",\"owes\":{\"Adam\":1.0},\"owed_by\":{},\"balance\":-1.0}]";
9999
Assert.Equal(expected, actual);
100100
}
101-
}
101+
}

exercises/robot-simulator/RobotSimulatorTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 3.0.0 of the canonical data.
1+
// This file was auto-generated based on version 3.1.0 of the canonical data.
22

33
using Xunit;
44

@@ -143,7 +143,7 @@ public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_decr
143143
}
144144

145145
[Fact(Skip = "Remove to run test")]
146-
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north()
146+
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north_from_readme()
147147
{
148148
var sut = new RobotSimulator(Direction.North, new Coordinate(7, 3));
149149
sut.Simulate("RAALAL");
@@ -173,7 +173,7 @@ public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_
173173
}
174174

175175
[Fact(Skip = "Remove to run test")]
176-
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north1()
176+
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north()
177177
{
178178
var sut = new RobotSimulator(Direction.South, new Coordinate(8, 4));
179179
sut.Simulate("LAAARRRALLLL");

exercises/saddle-points/Example.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SaddlePoints(int[,] values)
1717

1818
public IEnumerable<(int, int)> Calculate()
1919
{
20-
return Coordinates().Where(IsSaddlePoint);
20+
return Coordinates().Where(IsSaddlePoint).ToArray();
2121
}
2222

2323
private bool IsSaddlePoint((int, int) coordinate)

exercises/saddle-points/SaddlePointsTest.cs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.1.0 of the canonical data.
1+
// This file was auto-generated based on version 1.3.0 of the canonical data.
22

33
using System;
44
using Xunit;
@@ -44,7 +44,7 @@ public void Can_identify_lack_of_saddle_points_when_there_are_none()
4444
}
4545

4646
[Fact(Skip = "Remove to run test")]
47-
public void Can_identify_multiple_saddle_points()
47+
public void Can_identify_multiple_saddle_points_in_a_column()
4848
{
4949
var matrix = new[,]
5050
{
@@ -58,6 +58,21 @@ public void Can_identify_multiple_saddle_points()
5858
Assert.Equal(expected, actual);
5959
}
6060

61+
[Fact(Skip = "Remove to run test")]
62+
public void Can_identify_multiple_saddle_points_in_a_row()
63+
{
64+
var matrix = new[,]
65+
{
66+
{ 6, 7, 8 },
67+
{ 5, 5, 5 },
68+
{ 7, 5, 6 }
69+
};
70+
var sut = new SaddlePoints(matrix);
71+
var actual = sut.Calculate();
72+
var expected = new[] { (1, 0), (1, 1), (1, 2) };
73+
Assert.Equal(expected, actual);
74+
}
75+
6176
[Fact(Skip = "Remove to run test")]
6277
public void Can_identify_saddle_point_in_bottom_right_corner()
6378
{
@@ -72,4 +87,47 @@ public void Can_identify_saddle_point_in_bottom_right_corner()
7287
var expected = new[] { (2, 2) };
7388
Assert.Equal(expected, actual);
7489
}
90+
91+
[Fact(Skip = "Remove to run test")]
92+
public void Can_identify_saddle_points_in_a_non_square_matrix()
93+
{
94+
var matrix = new[,]
95+
{
96+
{ 3, 1, 3 },
97+
{ 3, 2, 4 }
98+
};
99+
var sut = new SaddlePoints(matrix);
100+
var actual = sut.Calculate();
101+
var expected = new[] { (0, 0), (0, 2) };
102+
Assert.Equal(expected, actual);
103+
}
104+
105+
[Fact(Skip = "Remove to run test")]
106+
public void Can_identify_that_saddle_points_in_a_single_column_matrix_are_those_with_the_minimum_value()
107+
{
108+
var matrix = new[,]
109+
{
110+
{ 2 },
111+
{ 1 },
112+
{ 4 },
113+
{ 1 }
114+
};
115+
var sut = new SaddlePoints(matrix);
116+
var actual = sut.Calculate();
117+
var expected = new[] { (1, 0), (3, 0) };
118+
Assert.Equal(expected, actual);
119+
}
120+
121+
[Fact(Skip = "Remove to run test")]
122+
public void Can_identify_that_saddle_points_in_a_single_row_matrix_are_those_with_the_maximum_value()
123+
{
124+
var matrix = new[,]
125+
{
126+
{ 2, 5, 3, 5 }
127+
};
128+
var sut = new SaddlePoints(matrix);
129+
var actual = sut.Calculate();
130+
var expected = new[] { (0, 1), (0, 3) };
131+
Assert.Equal(expected, actual);
132+
}
75133
}

exercises/scale-generator/Example.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public static class ScaleGenerator
1414
private static string[] SkipInterval(char interval, string[] scale) => scale.Skip(Intervals[interval]).ToArray();
1515
private static string[] Shift(int index, string[] scale) => scale.Skip(index).Concat(scale.Take(index)).ToArray();
1616

17-
public static string[] Pitches(string tonic)
17+
public static string[] Chromatic(string tonic)
1818
{
19-
return Pitches(tonic, "mmmmmmmmmmmm");
19+
return Interval(tonic, "mmmmmmmmmmmm");
2020
}
2121

22-
public static string[] Pitches(string tonic, string pattern)
22+
public static string[] Interval(string tonic, string pattern)
2323
{
2424
var scale = Scale(tonic);
2525
var index = Array.FindIndex(scale, pitch => string.Equals(pitch, tonic, StringComparison.OrdinalIgnoreCase));

exercises/scale-generator/ScaleGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
public static class ScaleGenerator
44
{
5-
public static string[] Pitches(string tonic)
5+
public static string[] Chromatic(string tonic)
66
{
77
throw new NotImplementedException("You need to implement this function.");
88
}
99

10-
public static string[] Pitches(string tonic, string pattern)
10+
public static string[] Interval(string tonic, string pattern)
1111
{
1212
throw new NotImplementedException("You need to implement this function.");
1313
}

0 commit comments

Comments
 (0)