diff --git a/exercises/alphametics/AlphameticsTest.cs b/exercises/alphametics/AlphameticsTest.cs index ce325e38b8..84c930065d 100644 --- a/exercises/alphametics/AlphameticsTest.cs +++ b/exercises/alphametics/AlphameticsTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.2.0 of the canonical data. +// This file was auto-generated based on version 1.3.0 of the canonical data. using System; using System.Collections.Generic; @@ -31,6 +31,19 @@ public void Leading_zero_solution_is_invalid() Assert.Throws(() => Alphametics.Solve("ACA + DD == BD")); } + [Fact(Skip = "Remove to run test")] + public void Puzzle_with_two_digits_final_carry() + { + var actual = Alphametics.Solve("A + A + A + A + A + A + A + A + A + A + A + B == BCC"); + var expected = new Dictionary + { + ['A'] = 9, + ['B'] = 1, + ['C'] = 0 + }; + Assert.Equal(expected, actual); + } + [Fact(Skip = "Remove to run test")] public void Puzzle_with_four_letters() { diff --git a/exercises/atbash-cipher/AtbashCipherTest.cs b/exercises/atbash-cipher/AtbashCipherTest.cs index b333a49680..150a779c55 100644 --- a/exercises/atbash-cipher/AtbashCipherTest.cs +++ b/exercises/atbash-cipher/AtbashCipherTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.2.0 of the canonical data. using Xunit; @@ -75,4 +75,16 @@ public void Decode_all_the_letters() { Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AtbashCipher.Decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt")); } + + [Fact(Skip = "Remove to run test")] + public void Decode_with_too_many_spaces() + { + Assert.Equal("exercism", AtbashCipher.Decode("vc vix r hn")); + } + + [Fact(Skip = "Remove to run test")] + public void Decode_with_no_spaces() + { + Assert.Equal("anobstacleisoftenasteppingstone", AtbashCipher.Decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv")); + } } \ No newline at end of file diff --git a/exercises/bracket-push/BracketPushTest.cs b/exercises/bracket-push/BracketPushTest.cs index f87a41e2e4..718e1cca4d 100644 --- a/exercises/bracket-push/BracketPushTest.cs +++ b/exercises/bracket-push/BracketPushTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.3.0 of the canonical data. +// This file was auto-generated based on version 1.4.0 of the canonical data. using Xunit; @@ -95,6 +95,13 @@ public void Paired_and_wrong_nested_brackets() Assert.False(BracketPush.IsPaired(value)); } + [Fact(Skip = "Remove to run test")] + public void Paired_and_incomplete_brackets() + { + var value = "{}["; + Assert.False(BracketPush.IsPaired(value)); + } + [Fact(Skip = "Remove to run test")] public void Math_expression() { diff --git a/exercises/grep/GrepTest.cs b/exercises/grep/GrepTest.cs index 2c6f0c1e77..d60ada2f4a 100644 --- a/exercises/grep/GrepTest.cs +++ b/exercises/grep/GrepTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.2.0 of the canonical data. using System; using System.IO; @@ -139,6 +139,34 @@ public void One_file_no_matches_various_flags() Assert.Equal(expected, Grep.Match(pattern, flags, files)); } + [Fact(Skip = "Remove to run test")] + public void One_file_one_match_file_flag_takes_precedence_over_line_flag() + { + var pattern = "ten"; + var flags = "-n -l"; + var files = new[] { "iliad.txt" }; + var expected = "iliad.txt"; + Assert.Equal(expected, Grep.Match(pattern, flags, files)); + } + + [Fact(Skip = "Remove to run test")] + public void One_file_several_matches_inverted_and_match_entire_lines_flags() + { + var pattern = "Illustrious into Ades premature,"; + var flags = "-x -v"; + var files = new[] { "iliad.txt" }; + var expected = + "Achilles sing, O Goddess! Peleus' son;\n" + + "His wrath pernicious, who ten thousand woes\n" + + "Caused to Achaia's host, sent many a soul\n" + + "And Heroes gave (so stood the will of Jove)\n" + + "To dogs and to all ravening fowls a prey,\n" + + "When fierce dispute had separated once\n" + + "The noble Chief Achilles from the son\n" + + "Of Atreus, Agamemnon, King of men."; + Assert.Equal(expected, Grep.Match(pattern, flags, files)); + } + [Fact(Skip = "Remove to run test")] public void Multiple_files_one_match_no_flags() { @@ -251,6 +279,51 @@ public void Multiple_files_no_matches_various_flags() Assert.Equal(expected, Grep.Match(pattern, flags, files)); } + [Fact(Skip = "Remove to run test")] + public void Multiple_files_several_matches_file_flag_takes_precedence_over_line_number_flag() + { + var pattern = "who"; + var flags = "-n -l"; + var files = new[] { "iliad.txt", "midsummer-night.txt", "paradise-lost.txt" }; + var expected = + "iliad.txt\n" + + "paradise-lost.txt"; + Assert.Equal(expected, Grep.Match(pattern, flags, files)); + } + + [Fact(Skip = "Remove to run test")] + public void Multiple_files_several_matches_inverted_and_match_entire_lines_flags() + { + var pattern = "Illustrious into Ades premature,"; + var flags = "-x -v"; + var files = new[] { "iliad.txt", "midsummer-night.txt", "paradise-lost.txt" }; + var expected = + "iliad.txt:Achilles sing, O Goddess! Peleus' son;\n" + + "iliad.txt:His wrath pernicious, who ten thousand woes\n" + + "iliad.txt:Caused to Achaia's host, sent many a soul\n" + + "iliad.txt:And Heroes gave (so stood the will of Jove)\n" + + "iliad.txt:To dogs and to all ravening fowls a prey,\n" + + "iliad.txt:When fierce dispute had separated once\n" + + "iliad.txt:The noble Chief Achilles from the son\n" + + "iliad.txt:Of Atreus, Agamemnon, King of men.\n" + + "midsummer-night.txt:I do entreat your grace to pardon me.\n" + + "midsummer-night.txt:I know not by what power I am made bold,\n" + + "midsummer-night.txt:Nor how it may concern my modesty,\n" + + "midsummer-night.txt:In such a presence here to plead my thoughts;\n" + + "midsummer-night.txt:But I beseech your grace that I may know\n" + + "midsummer-night.txt:The worst that may befall me in this case,\n" + + "midsummer-night.txt:If I refuse to wed Demetrius.\n" + + "paradise-lost.txt:Of Mans First Disobedience, and the Fruit\n" + + "paradise-lost.txt:Of that Forbidden Tree, whose mortal tast\n" + + "paradise-lost.txt:Brought Death into the World, and all our woe,\n" + + "paradise-lost.txt:With loss of Eden, till one greater Man\n" + + "paradise-lost.txt:Restore us, and regain the blissful Seat,\n" + + "paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n" + + "paradise-lost.txt:Of Oreb, or of Sinai, didst inspire\n" + + "paradise-lost.txt:That Shepherd, who first taught the chosen Seed"; + Assert.Equal(expected, Grep.Match(pattern, flags, files)); + } + private const string IliadFileName = "iliad.txt"; private const string IliadContents = "Achilles sing, O Goddess! Peleus' son;\n" + diff --git a/exercises/leap/LeapTest.cs b/exercises/leap/LeapTest.cs index 228ea69015..9af9431ef9 100644 --- a/exercises/leap/LeapTest.cs +++ b/exercises/leap/LeapTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.3.0 of the canonical data. +// This file was auto-generated based on version 1.4.0 of the canonical data. using Xunit; @@ -27,4 +27,10 @@ public void Year_divisible_by_400_is_leap_year() { Assert.True(Leap.IsLeapYear(2000)); } + + [Fact(Skip = "Remove to run test")] + public void Year_divisible_by_200_not_divisible_by_400_is_common_year() + { + Assert.False(Leap.IsLeapYear(1800)); + } } \ No newline at end of file diff --git a/exercises/pangram/PangramTest.cs b/exercises/pangram/PangramTest.cs index 6bb6f0c4a3..108caf8392 100644 --- a/exercises/pangram/PangramTest.cs +++ b/exercises/pangram/PangramTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.4.0 of the canonical data. +// This file was auto-generated based on version 1.4.1 of the canonical data. using Xunit; diff --git a/exercises/phone-number/PhoneNumberTest.cs b/exercises/phone-number/PhoneNumberTest.cs index 9eebabb269..5e500d9418 100644 --- a/exercises/phone-number/PhoneNumberTest.cs +++ b/exercises/phone-number/PhoneNumberTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.6.0 of the canonical data. +// This file was auto-generated based on version 1.6.1 of the canonical data. using System; using Xunit; diff --git a/exercises/protein-translation/ProteinTranslationTest.cs b/exercises/protein-translation/ProteinTranslationTest.cs index 0ce5f52782..a60595a03b 100644 --- a/exercises/protein-translation/ProteinTranslationTest.cs +++ b/exercises/protein-translation/ProteinTranslationTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.1.1 of the canonical data. using Xunit; diff --git a/exercises/rest-api/RestApiTest.cs b/exercises/rest-api/RestApiTest.cs index d9baecdbde..b14b877641 100644 --- a/exercises/rest-api/RestApiTest.cs +++ b/exercises/rest-api/RestApiTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.0.1 of the canonical data. +// This file was auto-generated based on version 1.0.2 of the canonical data. using Xunit; @@ -98,4 +98,4 @@ public void Lender_owes_borrower_less_than_new_loan() var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{\"Bob\":1.0},\"balance\":1.0},{\"name\":\"Bob\",\"owes\":{\"Adam\":1.0},\"owed_by\":{},\"balance\":-1.0}]"; Assert.Equal(expected, actual); } -} +} \ No newline at end of file diff --git a/exercises/robot-simulator/RobotSimulatorTest.cs b/exercises/robot-simulator/RobotSimulatorTest.cs index 0ed4acb75b..f77b6849e7 100644 --- a/exercises/robot-simulator/RobotSimulatorTest.cs +++ b/exercises/robot-simulator/RobotSimulatorTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 3.0.0 of the canonical data. +// This file was auto-generated based on version 3.1.0 of the canonical data. using Xunit; @@ -143,7 +143,7 @@ public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_decr } [Fact(Skip = "Remove to run test")] - 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() + 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() { var sut = new RobotSimulator(Direction.North, new Coordinate(7, 3)); sut.Simulate("RAALAL"); @@ -173,7 +173,7 @@ public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_ } [Fact(Skip = "Remove to run test")] - 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() + 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() { var sut = new RobotSimulator(Direction.South, new Coordinate(8, 4)); sut.Simulate("LAAARRRALLLL"); diff --git a/exercises/saddle-points/Example.cs b/exercises/saddle-points/Example.cs index 4b17b1b7f1..5ec26956ae 100644 --- a/exercises/saddle-points/Example.cs +++ b/exercises/saddle-points/Example.cs @@ -17,7 +17,7 @@ public SaddlePoints(int[,] values) public IEnumerable<(int, int)> Calculate() { - return Coordinates().Where(IsSaddlePoint); + return Coordinates().Where(IsSaddlePoint).ToArray(); } private bool IsSaddlePoint((int, int) coordinate) diff --git a/exercises/saddle-points/SaddlePointsTest.cs b/exercises/saddle-points/SaddlePointsTest.cs index 2419bfa828..84843dc4ff 100644 --- a/exercises/saddle-points/SaddlePointsTest.cs +++ b/exercises/saddle-points/SaddlePointsTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.3.0 of the canonical data. using System; using Xunit; @@ -44,7 +44,7 @@ public void Can_identify_lack_of_saddle_points_when_there_are_none() } [Fact(Skip = "Remove to run test")] - public void Can_identify_multiple_saddle_points() + public void Can_identify_multiple_saddle_points_in_a_column() { var matrix = new[,] { @@ -58,6 +58,21 @@ public void Can_identify_multiple_saddle_points() Assert.Equal(expected, actual); } + [Fact(Skip = "Remove to run test")] + public void Can_identify_multiple_saddle_points_in_a_row() + { + var matrix = new[,] + { + { 6, 7, 8 }, + { 5, 5, 5 }, + { 7, 5, 6 } + }; + var sut = new SaddlePoints(matrix); + var actual = sut.Calculate(); + var expected = new[] { (1, 0), (1, 1), (1, 2) }; + Assert.Equal(expected, actual); + } + [Fact(Skip = "Remove to run test")] public void Can_identify_saddle_point_in_bottom_right_corner() { @@ -72,4 +87,47 @@ public void Can_identify_saddle_point_in_bottom_right_corner() var expected = new[] { (2, 2) }; Assert.Equal(expected, actual); } + + [Fact(Skip = "Remove to run test")] + public void Can_identify_saddle_points_in_a_non_square_matrix() + { + var matrix = new[,] + { + { 3, 1, 3 }, + { 3, 2, 4 } + }; + var sut = new SaddlePoints(matrix); + var actual = sut.Calculate(); + var expected = new[] { (0, 0), (0, 2) }; + Assert.Equal(expected, actual); + } + + [Fact(Skip = "Remove to run test")] + public void Can_identify_that_saddle_points_in_a_single_column_matrix_are_those_with_the_minimum_value() + { + var matrix = new[,] + { + { 2 }, + { 1 }, + { 4 }, + { 1 } + }; + var sut = new SaddlePoints(matrix); + var actual = sut.Calculate(); + var expected = new[] { (1, 0), (3, 0) }; + Assert.Equal(expected, actual); + } + + [Fact(Skip = "Remove to run test")] + public void Can_identify_that_saddle_points_in_a_single_row_matrix_are_those_with_the_maximum_value() + { + var matrix = new[,] + { + { 2, 5, 3, 5 } + }; + var sut = new SaddlePoints(matrix); + var actual = sut.Calculate(); + var expected = new[] { (0, 1), (0, 3) }; + Assert.Equal(expected, actual); + } } \ No newline at end of file diff --git a/exercises/scale-generator/Example.cs b/exercises/scale-generator/Example.cs index 9dfbd1134a..1efb9fe18c 100644 --- a/exercises/scale-generator/Example.cs +++ b/exercises/scale-generator/Example.cs @@ -14,12 +14,12 @@ public static class ScaleGenerator private static string[] SkipInterval(char interval, string[] scale) => scale.Skip(Intervals[interval]).ToArray(); private static string[] Shift(int index, string[] scale) => scale.Skip(index).Concat(scale.Take(index)).ToArray(); - public static string[] Pitches(string tonic) + public static string[] Chromatic(string tonic) { - return Pitches(tonic, "mmmmmmmmmmmm"); + return Interval(tonic, "mmmmmmmmmmmm"); } - public static string[] Pitches(string tonic, string pattern) + public static string[] Interval(string tonic, string pattern) { var scale = Scale(tonic); var index = Array.FindIndex(scale, pitch => string.Equals(pitch, tonic, StringComparison.OrdinalIgnoreCase)); diff --git a/exercises/scale-generator/ScaleGenerator.cs b/exercises/scale-generator/ScaleGenerator.cs index 5473a3c5f9..8bc20d51eb 100644 --- a/exercises/scale-generator/ScaleGenerator.cs +++ b/exercises/scale-generator/ScaleGenerator.cs @@ -2,12 +2,12 @@ public static class ScaleGenerator { - public static string[] Pitches(string tonic) + public static string[] Chromatic(string tonic) { throw new NotImplementedException("You need to implement this function."); } - public static string[] Pitches(string tonic, string pattern) + public static string[] Interval(string tonic, string pattern) { throw new NotImplementedException("You need to implement this function."); } diff --git a/exercises/scale-generator/ScaleGeneratorTest.cs b/exercises/scale-generator/ScaleGeneratorTest.cs index 3f5e9e0870..3699db2718 100644 --- a/exercises/scale-generator/ScaleGeneratorTest.cs +++ b/exercises/scale-generator/ScaleGeneratorTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.0.0 of the canonical data. +// This file was auto-generated based on version 2.0.0 of the canonical data. using Xunit; @@ -8,118 +8,118 @@ public class ScaleGeneratorTest public void Chromatic_scale_with_sharps() { var expected = new[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; - Assert.Equal(expected, ScaleGenerator.Pitches("C")); + Assert.Equal(expected, ScaleGenerator.Chromatic("C")); } [Fact(Skip = "Remove to run test")] public void Chromatic_scale_with_flats() { var expected = new[] { "F", "Gb", "G", "Ab", "A", "Bb", "B", "C", "Db", "D", "Eb", "E" }; - Assert.Equal(expected, ScaleGenerator.Pitches("F")); + Assert.Equal(expected, ScaleGenerator.Chromatic("F")); } [Fact(Skip = "Remove to run test")] public void Simple_major_scale() { var expected = new[] { "C", "D", "E", "F", "G", "A", "B" }; - Assert.Equal(expected, ScaleGenerator.Pitches("C", "MMmMMMm")); + Assert.Equal(expected, ScaleGenerator.Interval("C", "MMmMMMm")); } [Fact(Skip = "Remove to run test")] public void Major_scale_with_sharps() { var expected = new[] { "G", "A", "B", "C", "D", "E", "F#" }; - Assert.Equal(expected, ScaleGenerator.Pitches("G", "MMmMMMm")); + Assert.Equal(expected, ScaleGenerator.Interval("G", "MMmMMMm")); } [Fact(Skip = "Remove to run test")] public void Major_scale_with_flats() { var expected = new[] { "F", "G", "A", "Bb", "C", "D", "E" }; - Assert.Equal(expected, ScaleGenerator.Pitches("F", "MMmMMMm")); + Assert.Equal(expected, ScaleGenerator.Interval("F", "MMmMMMm")); } [Fact(Skip = "Remove to run test")] public void Minor_scale_with_sharps() { var expected = new[] { "F#", "G#", "A", "B", "C#", "D", "E" }; - Assert.Equal(expected, ScaleGenerator.Pitches("f#", "MmMMmMM")); + Assert.Equal(expected, ScaleGenerator.Interval("f#", "MmMMmMM")); } [Fact(Skip = "Remove to run test")] public void Minor_scale_with_flats() { var expected = new[] { "Bb", "C", "Db", "Eb", "F", "Gb", "Ab" }; - Assert.Equal(expected, ScaleGenerator.Pitches("bb", "MmMMmMM")); + Assert.Equal(expected, ScaleGenerator.Interval("bb", "MmMMmMM")); } [Fact(Skip = "Remove to run test")] public void Dorian_mode() { var expected = new[] { "D", "E", "F", "G", "A", "B", "C" }; - Assert.Equal(expected, ScaleGenerator.Pitches("d", "MmMMMmM")); + Assert.Equal(expected, ScaleGenerator.Interval("d", "MmMMMmM")); } [Fact(Skip = "Remove to run test")] public void Mixolydian_mode() { var expected = new[] { "Eb", "F", "G", "Ab", "Bb", "C", "Db" }; - Assert.Equal(expected, ScaleGenerator.Pitches("Eb", "MMmMMmM")); + Assert.Equal(expected, ScaleGenerator.Interval("Eb", "MMmMMmM")); } [Fact(Skip = "Remove to run test")] public void Lydian_mode() { var expected = new[] { "A", "B", "C#", "D#", "E", "F#", "G#" }; - Assert.Equal(expected, ScaleGenerator.Pitches("a", "MMMmMMm")); + Assert.Equal(expected, ScaleGenerator.Interval("a", "MMMmMMm")); } [Fact(Skip = "Remove to run test")] public void Phrygian_mode() { var expected = new[] { "E", "F", "G", "A", "B", "C", "D" }; - Assert.Equal(expected, ScaleGenerator.Pitches("e", "mMMMmMM")); + Assert.Equal(expected, ScaleGenerator.Interval("e", "mMMMmMM")); } [Fact(Skip = "Remove to run test")] public void Locrian_mode() { var expected = new[] { "G", "Ab", "Bb", "C", "Db", "Eb", "F" }; - Assert.Equal(expected, ScaleGenerator.Pitches("g", "mMMmMMM")); + Assert.Equal(expected, ScaleGenerator.Interval("g", "mMMmMMM")); } [Fact(Skip = "Remove to run test")] public void Harmonic_minor() { var expected = new[] { "D", "E", "F", "G", "A", "Bb", "Db" }; - Assert.Equal(expected, ScaleGenerator.Pitches("d", "MmMMmAm")); + Assert.Equal(expected, ScaleGenerator.Interval("d", "MmMMmAm")); } [Fact(Skip = "Remove to run test")] public void Octatonic() { var expected = new[] { "C", "D", "D#", "F", "F#", "G#", "A", "B" }; - Assert.Equal(expected, ScaleGenerator.Pitches("C", "MmMmMmMm")); + Assert.Equal(expected, ScaleGenerator.Interval("C", "MmMmMmMm")); } [Fact(Skip = "Remove to run test")] public void Hexatonic() { var expected = new[] { "Db", "Eb", "F", "G", "A", "B" }; - Assert.Equal(expected, ScaleGenerator.Pitches("Db", "MMMMMM")); + Assert.Equal(expected, ScaleGenerator.Interval("Db", "MMMMMM")); } [Fact(Skip = "Remove to run test")] public void Pentatonic() { var expected = new[] { "A", "B", "C#", "E", "F#" }; - Assert.Equal(expected, ScaleGenerator.Pitches("A", "MMAMA")); + Assert.Equal(expected, ScaleGenerator.Interval("A", "MMAMA")); } [Fact(Skip = "Remove to run test")] public void Enigmatic() { var expected = new[] { "G", "G#", "B", "C#", "D#", "F", "F#" }; - Assert.Equal(expected, ScaleGenerator.Pitches("G", "mAMMMmm")); + Assert.Equal(expected, ScaleGenerator.Interval("G", "mAMMMmm")); } } \ No newline at end of file diff --git a/exercises/simple-cipher/Example.cs b/exercises/simple-cipher/Example.cs index b93f450db5..ef78ab8316 100644 --- a/exercises/simple-cipher/Example.cs +++ b/exercises/simple-cipher/Example.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Text; -using System.Text.RegularExpressions; public class SimpleCipher { @@ -18,11 +17,9 @@ public SimpleCipher() public SimpleCipher(string key) { - Key = IsValidKey(key) ? key : throw new ArgumentException("Invalid key"); + Key = key; } - private static bool IsValidKey(string key) => Regex.IsMatch(key, "^[a-z]+$"); - public string Encode(string plaintext) { var ciphertext = new StringBuilder(plaintext.Length); diff --git a/exercises/simple-cipher/SimpleCipherTest.cs b/exercises/simple-cipher/SimpleCipherTest.cs index f37284d626..e320f99c31 100644 --- a/exercises/simple-cipher/SimpleCipherTest.cs +++ b/exercises/simple-cipher/SimpleCipherTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.2.0 of the canonical data. using System; using Xunit; @@ -81,22 +81,4 @@ public void Substitution_cipher_can_handle_messages_longer_than_the_key() var sut = new SimpleCipher("abc"); Assert.Equal("iboaqcnecbfcr", sut.Encode("iamapandabear")); } - - [Fact(Skip = "Remove to run test")] - public void Incorrect_key_cipher_throws_an_error_with_an_all_uppercase_key() - { - Assert.Throws(() => new SimpleCipher("ABCDEF")); - } - - [Fact(Skip = "Remove to run test")] - public void Incorrect_key_cipher_throws_an_error_with_a_numeric_key() - { - Assert.Throws(() => new SimpleCipher("12345")); - } - - [Fact(Skip = "Remove to run test")] - public void Incorrect_key_cipher_throws_an_error_with_empty_key() - { - Assert.Throws(() => new SimpleCipher("")); - } } \ No newline at end of file diff --git a/exercises/sum-of-multiples/Example.cs b/exercises/sum-of-multiples/Example.cs index d80e5f73f2..63ba4cc55b 100644 --- a/exercises/sum-of-multiples/Example.cs +++ b/exercises/sum-of-multiples/Example.cs @@ -6,7 +6,7 @@ public static class SumOfMultiples public static int Sum(IEnumerable multiples, int max) { return Enumerable.Range(1, max - 1) - .Where(i => multiples.Any(m => i % m == 0)) + .Where(i => multiples.Any(m => m != 0 && i % m == 0)) .Sum(); } } \ No newline at end of file diff --git a/exercises/sum-of-multiples/SumOfMultiplesTest.cs b/exercises/sum-of-multiples/SumOfMultiplesTest.cs index d2e97016a7..ac5a7be113 100644 --- a/exercises/sum-of-multiples/SumOfMultiplesTest.cs +++ b/exercises/sum-of-multiples/SumOfMultiplesTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.2.0 of the canonical data. +// This file was auto-generated based on version 1.5.0 of the canonical data. using System; using Xunit; @@ -6,80 +6,98 @@ public class SumOfMultiplesTest { [Fact] - public void Multiples_of_3_or_5_up_to_1() + public void No_multiples_within_limit() { Assert.Equal(0, SumOfMultiples.Sum(new[] { 3, 5 }, 1)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_3_or_5_up_to_4() + public void One_factor_has_multiples_within_limit() { Assert.Equal(3, SumOfMultiples.Sum(new[] { 3, 5 }, 4)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_3_up_to_7() + public void More_than_one_multiple_within_limit() { Assert.Equal(9, SumOfMultiples.Sum(new[] { 3 }, 7)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_3_or_5_up_to_10() + public void More_than_one_factor_with_multiples_within_limit() { Assert.Equal(23, SumOfMultiples.Sum(new[] { 3, 5 }, 10)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_3_or_5_up_to_100() + public void Each_multiple_is_only_counted_once() { Assert.Equal(2318, SumOfMultiples.Sum(new[] { 3, 5 }, 100)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_3_or_5_up_to_1000() + public void A_much_larger_limit() { Assert.Equal(233168, SumOfMultiples.Sum(new[] { 3, 5 }, 1000)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_7_13_or_17_up_to_20() + public void Three_factors() { Assert.Equal(51, SumOfMultiples.Sum(new[] { 7, 13, 17 }, 20)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_4_or_6_up_to_15() + public void Factors_not_relatively_prime() { Assert.Equal(30, SumOfMultiples.Sum(new[] { 4, 6 }, 15)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_5_6_or_8_up_to_150() + public void Some_pairs_of_factors_relatively_prime_and_some_not() { Assert.Equal(4419, SumOfMultiples.Sum(new[] { 5, 6, 8 }, 150)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_5_or_25_up_to_51() + public void One_factor_is_a_multiple_of_another() { Assert.Equal(275, SumOfMultiples.Sum(new[] { 5, 25 }, 51)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_43_or_47_up_to_10000() + public void Much_larger_factors() { Assert.Equal(2203160, SumOfMultiples.Sum(new[] { 43, 47 }, 10000)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_1_up_to_100() + public void All_numbers_are_multiples_of_1() { Assert.Equal(4950, SumOfMultiples.Sum(new[] { 1 }, 100)); } [Fact(Skip = "Remove to run test")] - public void Multiples_of_an_empty_list_up_to_10000() + public void No_factors_means_an_empty_sum() { Assert.Equal(0, SumOfMultiples.Sum(Array.Empty(), 10000)); } + + [Fact(Skip = "Remove to run test")] + public void The_only_multiple_of_0_is_0() + { + Assert.Equal(0, SumOfMultiples.Sum(new[] { 0 }, 1)); + } + + [Fact(Skip = "Remove to run test")] + public void The_factor_0_does_not_affect_the_sum_of_multiples_of_other_factors() + { + Assert.Equal(3, SumOfMultiples.Sum(new[] { 3, 0 }, 4)); + } + + [Fact(Skip = "Remove to run test")] + public void Solutions_using_include_exclude_must_extend_to_cardinality_greater_than_3() + { + Assert.Equal(39614537, SumOfMultiples.Sum(new[] { 2, 3, 5, 7, 11 }, 10000)); + } } \ No newline at end of file diff --git a/exercises/triangle/TriangleTest.cs b/exercises/triangle/TriangleTest.cs index fee4a183fa..1631f28544 100644 --- a/exercises/triangle/TriangleTest.cs +++ b/exercises/triangle/TriangleTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 1.2.0 of the canonical data. using Xunit; @@ -65,11 +65,23 @@ public void Returns_true_if_the_triangle_is_isosceles_false_if_no_sides_are_equa } [Fact(Skip = "Remove to run test")] - public void Returns_true_if_the_triangle_is_isosceles_sides_that_violate_triangle_inequality_are_not_isosceles_even_if_two_are_equal() + public void Returns_true_if_the_triangle_is_isosceles_sides_that_violate_triangle_inequality_are_not_isosceles_even_if_two_are_equal_1_() { Assert.False(Triangle.IsIsosceles(1, 1, 3)); } + [Fact(Skip = "Remove to run test")] + public void Returns_true_if_the_triangle_is_isosceles_sides_that_violate_triangle_inequality_are_not_isosceles_even_if_two_are_equal_2_() + { + Assert.False(Triangle.IsIsosceles(1, 3, 1)); + } + + [Fact(Skip = "Remove to run test")] + public void Returns_true_if_the_triangle_is_isosceles_sides_that_violate_triangle_inequality_are_not_isosceles_even_if_two_are_equal_3_() + { + Assert.False(Triangle.IsIsosceles(3, 1, 1)); + } + [Fact(Skip = "Remove to run test")] public void Returns_true_if_the_triangle_is_isosceles_sides_may_be_floats() { diff --git a/generators/Exercises/Generators/SaddlePoints.cs b/generators/Exercises/Generators/SaddlePoints.cs index afc1ca6493..e65d5003b4 100644 --- a/generators/Exercises/Generators/SaddlePoints.cs +++ b/generators/Exercises/Generators/SaddlePoints.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Exercism.CSharp.Output; using Newtonsoft.Json.Linq; @@ -43,7 +44,7 @@ private static (string, object)[] ToTupleCollection(Array array) tuples.Add((current["row"].ToString(), current["column"].ToString())); } - return tuples.ToArray(); + return tuples.OrderBy(x => x).ToArray(); } } }