trackler 2.2.1.12 → 2.2.1.13
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/problem-specifications/exercises/space-age/description.md +2 -1
- data/problem-specifications/exercises/two-fer/canonical-data.json +4 -4
- data/tracks/csharp/.gitignore +2 -1
- data/tracks/csharp/config/maintainers.json +3 -3
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.cs +1 -1
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjectureTest.cs +8 -8
- data/tracks/csharp/exercises/collatz-conjecture/Example.cs +6 -6
- data/tracks/csharp/exercises/gigasecond/Example.cs +1 -1
- data/tracks/csharp/exercises/gigasecond/Gigasecond.cs +1 -1
- data/tracks/csharp/exercises/gigasecond/GigasecondTest.cs +21 -10
- data/tracks/csharp/exercises/hamming/Example.cs +6 -1
- data/tracks/csharp/exercises/hamming/Hamming.cs +1 -1
- data/tracks/csharp/exercises/hamming/HammingTest.cs +69 -12
- data/tracks/csharp/exercises/pangram/PangramTest.cs +15 -20
- data/tracks/csharp/exercises/phone-number/Example.cs +15 -42
- data/tracks/csharp/exercises/phone-number/PhoneNumber.cs +2 -17
- data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +57 -20
- data/tracks/csharp/exercises/prime-factors/Example.cs +1 -1
- data/tracks/csharp/exercises/prime-factors/PrimeFactors.cs +1 -1
- data/tracks/csharp/exercises/prime-factors/PrimeFactorsTest.cs +16 -38
- data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipherTest.cs +21 -19
- data/tracks/csharp/exercises/rna-transcription/Example.cs +7 -2
- data/tracks/csharp/exercises/rna-transcription/RnaTranscription.cs +2 -2
- data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +26 -6
- data/tracks/csharp/exercises/rotational-cipher/RotationalCipherTest.cs +7 -7
- data/tracks/csharp/exercises/run-length-encoding/RunLengthEncodingTest.cs +53 -29
- data/tracks/csharp/exercises/scrabble-score/Example.cs +2 -2
- data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.cs +1 -1
- data/tracks/csharp/exercises/scrabble-score/ScrabbleScoreTest.cs +33 -19
- data/tracks/csharp/exercises/secret-handshake/SecretHandshake.cs +0 -1
- data/tracks/csharp/exercises/secret-handshake/SecretHandshakeTest.cs +36 -10
- data/tracks/csharp/exercises/two-fer/Example.cs +1 -1
- data/tracks/csharp/exercises/two-fer/TwoFer.cs +1 -1
- data/tracks/csharp/exercises/two-fer/TwoFerTest.cs +19 -19
- data/tracks/csharp/generators/.gitignore +1 -1
- data/tracks/csharp/generators/Exercise.cs +85 -10
- data/tracks/csharp/generators/Exercises/AllYourBase.cs +3 -14
- data/tracks/csharp/generators/Exercises/Allergies.cs +21 -18
- data/tracks/csharp/generators/Exercises/Alphametics.cs +6 -7
- data/tracks/csharp/generators/Exercises/Anagram.cs +4 -4
- data/tracks/csharp/generators/Exercises/BeerSong.cs +4 -2
- data/tracks/csharp/generators/Exercises/BinarySearch.cs +3 -3
- data/tracks/csharp/generators/Exercises/BookStore.cs +3 -3
- data/tracks/csharp/generators/Exercises/BracketPush.cs +4 -2
- data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +16 -0
- data/tracks/csharp/generators/Exercises/ConvertExtensions.cs +12 -0
- data/tracks/csharp/generators/Exercises/CryptoSquare.cs +3 -2
- data/tracks/csharp/generators/Exercises/FoodChain.cs +3 -3
- data/tracks/csharp/generators/Exercises/Gigasecond.cs +38 -0
- data/tracks/csharp/generators/Exercises/Hamming.cs +16 -0
- data/tracks/csharp/generators/Exercises/Leap.cs +4 -2
- data/tracks/csharp/generators/Exercises/Luhn.cs +3 -1
- data/tracks/csharp/generators/Exercises/NthPrime.cs +2 -10
- data/tracks/csharp/generators/Exercises/Pangram.cs +17 -0
- data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +2 -9
- data/tracks/csharp/generators/Exercises/PhoneNumber.cs +15 -0
- data/tracks/csharp/generators/Exercises/PrimeFactors.cs +6 -0
- data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +23 -0
- data/tracks/csharp/generators/Exercises/RnaTranscription.cs +6 -0
- data/tracks/csharp/generators/Exercises/RomanNumerals.cs +4 -2
- data/tracks/csharp/generators/Exercises/RunLengthEncoding.cs +40 -0
- data/tracks/csharp/generators/Exercises/ScrabbleScore.cs +6 -0
- data/tracks/csharp/generators/Exercises/SecretHandshake.cs +15 -0
- data/tracks/csharp/generators/Exercises/Transpose.cs +4 -4
- data/tracks/csharp/generators/Exercises/TwoFer.cs +6 -0
- data/tracks/csharp/generators/Exercises/Wordy.cs +2 -10
- data/tracks/csharp/generators/Generators.csproj +1 -3
- data/tracks/csharp/generators/Input/CanonicalDataFile.cs +48 -11
- data/tracks/csharp/generators/Input/CanonicalDataOptions.cs +8 -0
- data/tracks/csharp/generators/Input/CanonicalDataParser.cs +11 -3
- data/tracks/csharp/generators/Options.cs +8 -0
- data/tracks/csharp/generators/Output/{TestClassFile.cs → ExerciseWriter.cs} +4 -3
- data/tracks/csharp/generators/Output/FormattingExtensions.cs +14 -0
- data/tracks/csharp/generators/Output/IndentFilter.cs +13 -0
- data/tracks/csharp/generators/Output/TemplateRenderer.cs +23 -0
- data/tracks/csharp/generators/Output/Templates/_Act.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_Arrange.liquid +3 -0
- data/tracks/csharp/generators/Output/Templates/_AssertBoolean.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertEqual.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertEqual_Empty.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertNull.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertThrowsException.liquid +1 -0
- data/tracks/csharp/generators/Output/{TestClass.liquid → Templates/_TestClass.liquid} +2 -8
- data/tracks/csharp/generators/Output/Templates/_TestMethod.liquid +5 -0
- data/tracks/csharp/generators/Output/Templates/_TestMethodBody.liquid +3 -0
- data/tracks/csharp/generators/Output/TestClass.cs +5 -2
- data/tracks/csharp/generators/Output/TestMethod.cs +6 -6
- data/tracks/csharp/generators/Output/TestMethodBody.cs +49 -0
- data/tracks/csharp/generators/Output/TestMethodBodyData.cs +85 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithBooleanCheck.cs +16 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithEqualityCheck.cs +21 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithExceptionCheck.cs +18 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithNullCheck.cs +13 -0
- data/tracks/csharp/generators/Output/UnescapedValue.cs +6 -2
- data/tracks/csharp/generators/Output/ValueFormatter.cs +1 -10
- data/tracks/csharp/generators/Program.cs +34 -8
- data/tracks/delphi/config/maintainers.json +1 -1
- data/tracks/delphi/docs/{Getting_Started_Guide.md → GETTING_STARTED_GUIDE.md} +0 -0
- data/tracks/fsharp/config.json +16 -5
- data/tracks/fsharp/config/maintainers.json +3 -3
- data/tracks/fsharp/exercises/two-fer/Example.fs +4 -0
- data/tracks/fsharp/exercises/two-fer/README.md +28 -0
- data/tracks/fsharp/exercises/two-fer/TwoFerTest.fs +19 -0
- data/tracks/groovy/CONTRIBUTING.md +19 -0
- data/tracks/groovy/README.md +10 -2
- data/tracks/java/exercises/allergies/src/example/java/Allergies.java +1 -1
- data/tracks/r/bin/run_tests.R +1 -4
- data/tracks/r/docs/{snippet.txt → SNIPPET.txt} +0 -0
- data/tracks/r/exercises/hamming/example.R +1 -1
- data/tracks/ruby/exercises/flatten-array/README.md +1 -1
- data/tracks/scala/exercises/gigasecond/example.scala +3 -3
- data/tracks/scala/exercises/gigasecond/src/main/scala/Gigasecond.scala +2 -2
- data/tracks/scala/exercises/gigasecond/src/test/scala/GigasecondTest.scala +12 -21
- data/tracks/scala/exercises/house/example.scala +6 -3
- data/tracks/scala/exercises/house/src/test/scala/HouseTest.scala +289 -97
- data/tracks/scala/exercises/isogram/src/main/scala/{Isogram.scala → .keep} +0 -0
- data/tracks/scala/exercises/isogram/src/test/scala/IsogramTest.scala +16 -19
- data/tracks/scala/testgen/src/main/scala/GigasecondTestGenerator.scala +49 -0
- data/tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala +47 -0
- data/tracks/scala/testgen/src/main/scala/IsogramTestGenerator.scala +10 -31
- data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +3 -3
- data/tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt +5 -1
- data/tracks/swift/config.json +11 -0
- data/tracks/swift/exercises/rotational-cipher/.gitignore +4 -0
- data/tracks/swift/exercises/rotational-cipher/Package.swift +5 -0
- data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipher.swift +1 -0
- data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipherExample.swift +30 -0
- data/tracks/swift/exercises/rotational-cipher/Tests/LinuxMain.swift +6 -0
- data/tracks/swift/exercises/rotational-cipher/Tests/RotationalCipherTests/RotationalCipherTests.swift +70 -0
- metadata +51 -17
- data/tracks/csharp/generators/Output/BooleanTestMethodGenerator.cs +0 -13
- data/tracks/csharp/generators/Output/EqualityTestMethodGenerator.cs +0 -27
- data/tracks/csharp/generators/Output/ExceptionTestMethodGenerator.cs +0 -15
- data/tracks/csharp/generators/Output/TestClassGenerator.cs +0 -30
- data/tracks/csharp/generators/Output/TestClassRenderer.cs +0 -26
- data/tracks/csharp/generators/Output/TestMethodGenerator.cs +0 -94
- data/tracks/java/docs/img/eclipse-help-dropdown.png +0 -0
- data/tracks/java/docs/img/eclipse-mp-search-buildship-gradle.png +0 -0
- data/tracks/java/docs/img/mac-osx--idea-ce-run-unit-tests.png +0 -0
- data/tracks/java/docs/img/mac-osx--install-java-dialog.png +0 -0
@@ -1,50 +1,23 @@
|
|
1
|
+
using System.Linq;
|
1
2
|
using System.Text.RegularExpressions;
|
2
3
|
|
3
4
|
public class PhoneNumber
|
4
5
|
{
|
5
|
-
private static readonly Regex
|
6
|
+
private static readonly Regex phoneNumberFormat = new Regex("^1?([2-9][0-9]{2}[2-9][0-9]{6})$");
|
6
7
|
|
7
|
-
public string
|
8
|
-
public string AreaCode { get; private set; }
|
9
|
-
|
10
|
-
public PhoneNumber(string phoneNumber)
|
11
|
-
{
|
12
|
-
Number = GetValidatedPhoneNumber(phoneNumber);
|
13
|
-
AreaCode = Number.Substring(0, 3);
|
14
|
-
}
|
15
|
-
|
16
|
-
private static string GetValidatedPhoneNumber(string phoneNumber)
|
17
|
-
{
|
18
|
-
var stripped = StripOutNonNumerics(phoneNumber);
|
19
|
-
|
20
|
-
if (IsInvalidPhoneNumber(stripped))
|
21
|
-
return GetInvalidPhoneNumberReplacement(stripped);
|
22
|
-
|
23
|
-
return stripped;
|
24
|
-
}
|
25
|
-
|
26
|
-
private static string StripOutNonNumerics(string value)
|
27
|
-
{
|
28
|
-
return DigitsOnly.Replace(value, "");
|
29
|
-
}
|
30
|
-
|
31
|
-
private static bool IsInvalidPhoneNumber(string phoneNumber)
|
32
|
-
{
|
33
|
-
return phoneNumber.Length != 10;
|
34
|
-
}
|
35
|
-
|
36
|
-
private static string GetInvalidPhoneNumberReplacement(string phoneNumber)
|
37
|
-
{
|
38
|
-
return IsPhoneNumberWithUSAreaCode(phoneNumber) ? phoneNumber.Substring(1) : "0000000000";
|
39
|
-
}
|
40
|
-
|
41
|
-
private static bool IsPhoneNumberWithUSAreaCode(string value)
|
42
|
-
{
|
43
|
-
return value.Length == 11 && value.StartsWith("1");
|
44
|
-
}
|
45
|
-
|
46
|
-
public override string ToString()
|
8
|
+
public static string Clean(string phoneNumber)
|
47
9
|
{
|
48
|
-
|
10
|
+
var digits = string.Join(string.Empty, phoneNumber.Where(l => l >= '0' && l <= '9'));
|
11
|
+
|
12
|
+
var match = phoneNumberFormat.Match(digits);
|
13
|
+
|
14
|
+
if (match.Success)
|
15
|
+
{
|
16
|
+
return match.Groups[1].ToString();
|
17
|
+
}
|
18
|
+
else
|
19
|
+
{
|
20
|
+
return null;
|
21
|
+
}
|
49
22
|
}
|
50
23
|
}
|
@@ -2,23 +2,8 @@
|
|
2
2
|
|
3
3
|
public class PhoneNumber
|
4
4
|
{
|
5
|
-
public
|
5
|
+
public static string Clean(string phoneNumber)
|
6
6
|
{
|
7
|
-
|
8
|
-
|
9
|
-
public string Number
|
10
|
-
{
|
11
|
-
get
|
12
|
-
{
|
13
|
-
throw new NotImplementedException("You need to implement this function.");
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
public string AreaCode
|
18
|
-
{
|
19
|
-
get
|
20
|
-
{
|
21
|
-
throw new NotImplementedException("You need to implement this function.");
|
22
|
-
}
|
7
|
+
throw new NotImplementedException("You need to implement this function.");
|
23
8
|
}
|
24
9
|
}
|
@@ -1,53 +1,90 @@
|
|
1
|
+
// This file was auto-generated based on version 1.2.0 of the canonical data.
|
2
|
+
|
1
3
|
using Xunit;
|
2
4
|
|
3
5
|
public class PhoneNumberTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
8
|
+
public void Cleans_the_number()
|
7
9
|
{
|
8
|
-
var
|
9
|
-
Assert.Equal("
|
10
|
+
var phrase = "(223) 456-7890";
|
11
|
+
Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
|
10
12
|
}
|
11
13
|
|
12
14
|
[Fact(Skip = "Remove to run test")]
|
13
15
|
public void Cleans_numbers_with_dots()
|
14
16
|
{
|
15
|
-
var
|
16
|
-
Assert.Equal("
|
17
|
+
var phrase = "223.456.7890";
|
18
|
+
Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
|
17
19
|
}
|
18
20
|
|
19
21
|
[Fact(Skip = "Remove to run test")]
|
20
|
-
public void
|
22
|
+
public void Cleans_numbers_with_multiple_spaces()
|
21
23
|
{
|
22
|
-
var
|
23
|
-
Assert.Equal("
|
24
|
+
var phrase = "223 456 7890 ";
|
25
|
+
Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
|
24
26
|
}
|
25
27
|
|
26
28
|
[Fact(Skip = "Remove to run test")]
|
27
|
-
public void
|
29
|
+
public void Invalid_when_9_digits()
|
28
30
|
{
|
29
|
-
var
|
30
|
-
Assert.
|
31
|
+
var phrase = "123456789";
|
32
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
31
33
|
}
|
32
34
|
|
33
35
|
[Fact(Skip = "Remove to run test")]
|
34
|
-
public void
|
36
|
+
public void Invalid_when_11_digits_does_not_start_with_a_1()
|
37
|
+
{
|
38
|
+
var phrase = "22234567890";
|
39
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
40
|
+
}
|
41
|
+
|
42
|
+
[Fact(Skip = "Remove to run test")]
|
43
|
+
public void Valid_when_11_digits_and_starting_with_1()
|
44
|
+
{
|
45
|
+
var phrase = "12234567890";
|
46
|
+
Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
|
47
|
+
}
|
48
|
+
|
49
|
+
[Fact(Skip = "Remove to run test")]
|
50
|
+
public void Valid_when_11_digits_and_starting_with_1_even_with_punctuation()
|
51
|
+
{
|
52
|
+
var phrase = "+1 (223) 456-7890";
|
53
|
+
Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
|
54
|
+
}
|
55
|
+
|
56
|
+
[Fact(Skip = "Remove to run test")]
|
57
|
+
public void Invalid_when_more_than_11_digits()
|
58
|
+
{
|
59
|
+
var phrase = "321234567890";
|
60
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
61
|
+
}
|
62
|
+
|
63
|
+
[Fact(Skip = "Remove to run test")]
|
64
|
+
public void Invalid_with_letters()
|
65
|
+
{
|
66
|
+
var phrase = "123-abc-7890";
|
67
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
68
|
+
}
|
69
|
+
|
70
|
+
[Fact(Skip = "Remove to run test")]
|
71
|
+
public void Invalid_with_punctuations()
|
35
72
|
{
|
36
|
-
var
|
37
|
-
Assert.
|
73
|
+
var phrase = "123-@:!-7890";
|
74
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
38
75
|
}
|
39
76
|
|
40
77
|
[Fact(Skip = "Remove to run test")]
|
41
|
-
public void
|
78
|
+
public void Invalid_if_area_code_does_not_start_with_2_9()
|
42
79
|
{
|
43
|
-
var
|
44
|
-
Assert.
|
80
|
+
var phrase = "(123) 456-7890";
|
81
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
45
82
|
}
|
46
83
|
|
47
84
|
[Fact(Skip = "Remove to run test")]
|
48
|
-
public void
|
85
|
+
public void Invalid_if_exchange_code_does_not_start_with_2_9()
|
49
86
|
{
|
50
|
-
var
|
51
|
-
Assert.
|
87
|
+
var phrase = "(223) 056-7890";
|
88
|
+
Assert.Null(PhoneNumber.Clean(phrase));
|
52
89
|
}
|
53
90
|
}
|
@@ -1,70 +1,48 @@
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
|
+
|
1
3
|
using Xunit;
|
2
4
|
|
3
5
|
public class PrimeFactorsTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
7
|
-
{
|
8
|
-
Assert.Equal(new int[0], PrimeFactors.For(1));
|
9
|
-
}
|
10
|
-
|
11
|
-
[Fact(Skip = "Remove to run test")]
|
12
|
-
public void Test_2()
|
13
|
-
{
|
14
|
-
Assert.Equal(new[] { 2 }, PrimeFactors.For(2));
|
15
|
-
}
|
16
|
-
|
17
|
-
[Fact(Skip = "Remove to run test")]
|
18
|
-
public void Test_3()
|
19
|
-
{
|
20
|
-
Assert.Equal(new[] { 3 }, PrimeFactors.For(3));
|
21
|
-
}
|
22
|
-
|
23
|
-
[Fact(Skip = "Remove to run test")]
|
24
|
-
public void Test_4()
|
25
|
-
{
|
26
|
-
Assert.Equal(new[] { 2, 2 }, PrimeFactors.For(4));
|
27
|
-
}
|
28
|
-
|
29
|
-
[Fact(Skip = "Remove to run test")]
|
30
|
-
public void Test_6()
|
8
|
+
public void No_factors()
|
31
9
|
{
|
32
|
-
Assert.
|
10
|
+
Assert.Empty(PrimeFactors.Factors(1));
|
33
11
|
}
|
34
12
|
|
35
13
|
[Fact(Skip = "Remove to run test")]
|
36
|
-
public void
|
14
|
+
public void Prime_number()
|
37
15
|
{
|
38
|
-
Assert.Equal(new[] { 2
|
16
|
+
Assert.Equal(new[] { 2 }, PrimeFactors.Factors(2));
|
39
17
|
}
|
40
18
|
|
41
19
|
[Fact(Skip = "Remove to run test")]
|
42
|
-
public void
|
20
|
+
public void Square_of_a_prime()
|
43
21
|
{
|
44
|
-
Assert.Equal(new[] { 3, 3 }, PrimeFactors.
|
22
|
+
Assert.Equal(new[] { 3, 3 }, PrimeFactors.Factors(9));
|
45
23
|
}
|
46
24
|
|
47
25
|
[Fact(Skip = "Remove to run test")]
|
48
|
-
public void
|
26
|
+
public void Cube_of_a_prime()
|
49
27
|
{
|
50
|
-
Assert.Equal(new[] {
|
28
|
+
Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.Factors(8));
|
51
29
|
}
|
52
30
|
|
53
31
|
[Fact(Skip = "Remove to run test")]
|
54
|
-
public void
|
32
|
+
public void Product_of_primes_and_non_primes()
|
55
33
|
{
|
56
|
-
Assert.Equal(new[] {
|
34
|
+
Assert.Equal(new[] { 2, 2, 3 }, PrimeFactors.Factors(12));
|
57
35
|
}
|
58
36
|
|
59
37
|
[Fact(Skip = "Remove to run test")]
|
60
|
-
public void
|
38
|
+
public void Product_of_primes()
|
61
39
|
{
|
62
|
-
Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.
|
40
|
+
Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.Factors(901255));
|
63
41
|
}
|
64
42
|
|
65
43
|
[Fact(Skip = "Remove to run test")]
|
66
|
-
public void
|
44
|
+
public void Factors_include_a_large_prime()
|
67
45
|
{
|
68
|
-
Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.
|
46
|
+
Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.Factors(93819012551));
|
69
47
|
}
|
70
48
|
}
|
@@ -1,58 +1,60 @@
|
|
1
|
-
|
1
|
+
// This file was auto-generated based on version 1.0.1 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
2
4
|
|
3
5
|
public class RailFenceCipherTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
8
|
public void Encode_with_two_rails()
|
7
9
|
{
|
8
|
-
var
|
9
|
-
var
|
10
|
+
var msg = "XOXOXOXOXOXOXOXOXO";
|
11
|
+
var sut = new RailFenceCipher(2);
|
10
12
|
var expected = "XXXXXXXXXOOOOOOOOO";
|
11
|
-
Assert.Equal(expected,
|
13
|
+
Assert.Equal(expected, sut.Encode(msg));
|
12
14
|
}
|
13
15
|
|
14
16
|
[Fact(Skip = "Remove to run test")]
|
15
17
|
public void Encode_with_three_rails()
|
16
18
|
{
|
17
|
-
var
|
18
|
-
var
|
19
|
+
var msg = "WEAREDISCOVEREDFLEEATONCE";
|
20
|
+
var sut = new RailFenceCipher(3);
|
19
21
|
var expected = "WECRLTEERDSOEEFEAOCAIVDEN";
|
20
|
-
Assert.Equal(expected,
|
22
|
+
Assert.Equal(expected, sut.Encode(msg));
|
21
23
|
}
|
22
24
|
|
23
25
|
[Fact(Skip = "Remove to run test")]
|
24
26
|
public void Encode_with_ending_in_the_middle()
|
25
27
|
{
|
26
|
-
var
|
27
|
-
var
|
28
|
+
var msg = "EXERCISES";
|
29
|
+
var sut = new RailFenceCipher(4);
|
28
30
|
var expected = "ESXIEECSR";
|
29
|
-
Assert.Equal(expected,
|
31
|
+
Assert.Equal(expected, sut.Encode(msg));
|
30
32
|
}
|
31
33
|
|
32
34
|
[Fact(Skip = "Remove to run test")]
|
33
35
|
public void Decode_with_three_rails()
|
34
36
|
{
|
35
|
-
var
|
36
|
-
var
|
37
|
+
var msg = "TEITELHDVLSNHDTISEIIEA";
|
38
|
+
var sut = new RailFenceCipher(3);
|
37
39
|
var expected = "THEDEVILISINTHEDETAILS";
|
38
|
-
Assert.Equal(expected,
|
40
|
+
Assert.Equal(expected, sut.Decode(msg));
|
39
41
|
}
|
40
42
|
|
41
43
|
[Fact(Skip = "Remove to run test")]
|
42
44
|
public void Decode_with_five_rails()
|
43
45
|
{
|
44
|
-
var
|
45
|
-
var
|
46
|
+
var msg = "EIEXMSMESAORIWSCE";
|
47
|
+
var sut = new RailFenceCipher(5);
|
46
48
|
var expected = "EXERCISMISAWESOME";
|
47
|
-
Assert.Equal(expected,
|
49
|
+
Assert.Equal(expected, sut.Decode(msg));
|
48
50
|
}
|
49
51
|
|
50
52
|
[Fact(Skip = "Remove to run test")]
|
51
53
|
public void Decode_with_six_rails()
|
52
54
|
{
|
53
|
-
var
|
54
|
-
var
|
55
|
+
var msg = "133714114238148966225439541018335470986172518171757571896261";
|
56
|
+
var sut = new RailFenceCipher(6);
|
55
57
|
var expected = "112358132134558914423337761098715972584418167651094617711286";
|
56
|
-
Assert.Equal(expected,
|
58
|
+
Assert.Equal(expected, sut.Decode(msg));
|
57
59
|
}
|
58
60
|
}
|
@@ -1,15 +1,20 @@
|
|
1
1
|
using System.Collections.Generic;
|
2
2
|
using System.Linq;
|
3
3
|
|
4
|
-
public class
|
4
|
+
public static class RnaTranscription
|
5
5
|
{
|
6
6
|
private static readonly Dictionary<char, char> DnaToRna = new Dictionary<char, char>
|
7
7
|
{
|
8
8
|
{ 'G', 'C' }, { 'C', 'G' }, { 'T', 'A' }, { 'A', 'U' }
|
9
9
|
};
|
10
10
|
|
11
|
-
public static string
|
11
|
+
public static string ToRna(string nucleotide)
|
12
12
|
{
|
13
|
+
if (nucleotide.Any(x => !DnaToRna.ContainsKey(x)))
|
14
|
+
{
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
|
13
18
|
return string.Concat(nucleotide.Select(x => DnaToRna[x]));
|
14
19
|
}
|
15
20
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
using System;
|
2
2
|
|
3
|
-
public static class
|
3
|
+
public static class RnaTranscription
|
4
4
|
{
|
5
|
-
public static string
|
5
|
+
public static string ToRna(string nucleotide)
|
6
6
|
{
|
7
7
|
throw new NotImplementedException("You need to implement this function.");
|
8
8
|
}
|
@@ -1,34 +1,54 @@
|
|
1
|
+
// This file was auto-generated based on version 1.0.1 of the canonical data.
|
2
|
+
|
1
3
|
using Xunit;
|
2
4
|
|
3
|
-
public class
|
5
|
+
public class RnaTranscriptionTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
8
|
public void Rna_complement_of_cytosine_is_guanine()
|
7
9
|
{
|
8
|
-
Assert.Equal("G",
|
10
|
+
Assert.Equal("G", RnaTranscription.ToRna("C"));
|
9
11
|
}
|
10
12
|
|
11
13
|
[Fact(Skip = "Remove to run test")]
|
12
14
|
public void Rna_complement_of_guanine_is_cytosine()
|
13
15
|
{
|
14
|
-
Assert.Equal("C",
|
16
|
+
Assert.Equal("C", RnaTranscription.ToRna("G"));
|
15
17
|
}
|
16
18
|
|
17
19
|
[Fact(Skip = "Remove to run test")]
|
18
20
|
public void Rna_complement_of_thymine_is_adenine()
|
19
21
|
{
|
20
|
-
Assert.Equal("A",
|
22
|
+
Assert.Equal("A", RnaTranscription.ToRna("T"));
|
21
23
|
}
|
22
24
|
|
23
25
|
[Fact(Skip = "Remove to run test")]
|
24
26
|
public void Rna_complement_of_adenine_is_uracil()
|
25
27
|
{
|
26
|
-
Assert.Equal("U",
|
28
|
+
Assert.Equal("U", RnaTranscription.ToRna("A"));
|
27
29
|
}
|
28
30
|
|
29
31
|
[Fact(Skip = "Remove to run test")]
|
30
32
|
public void Rna_complement()
|
31
33
|
{
|
32
|
-
Assert.Equal("UGCACCAGAAUU",
|
34
|
+
Assert.Equal("UGCACCAGAAUU", RnaTranscription.ToRna("ACGTGGTCTTAA"));
|
35
|
+
}
|
36
|
+
|
37
|
+
[Fact(Skip = "Remove to run test")]
|
38
|
+
public void Correctly_handles_invalid_input_rna_instead_of_dna_()
|
39
|
+
{
|
40
|
+
Assert.Null(RnaTranscription.ToRna("U"));
|
41
|
+
}
|
42
|
+
|
43
|
+
[Fact(Skip = "Remove to run test")]
|
44
|
+
public void Correctly_handles_completely_invalid_dna_input()
|
45
|
+
{
|
46
|
+
Assert.Null(RnaTranscription.ToRna("XXX"));
|
47
|
+
}
|
48
|
+
|
49
|
+
[Fact(Skip = "Remove to run test")]
|
50
|
+
public void Correctly_handles_partially_invalid_dna_input()
|
51
|
+
{
|
52
|
+
Assert.Null(RnaTranscription.ToRna("ACGTXXXCTTAA"));
|
33
53
|
}
|
34
54
|
}
|