trackler 2.2.1.75 → 2.2.1.76
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/alphametics/canonical-data.json +18 -1
- data/problem-specifications/exercises/anagram/canonical-data.json +72 -39
- data/problem-specifications/exercises/binary/canonical-data.json +47 -17
- data/tracks/clojure/exercises/beer-song/src/beer_song.clj +11 -0
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/raindrops/README.md +67 -0
- data/tracks/erlang/exercises/raindrops/rebar.config +30 -0
- data/tracks/erlang/exercises/raindrops/src/example.erl +30 -0
- data/tracks/erlang/exercises/raindrops/src/raindrops.app.src +9 -0
- data/tracks/erlang/exercises/raindrops/src/raindrops.erl +8 -0
- data/tracks/erlang/exercises/raindrops/test/raindrops_tests.erl +50 -0
- data/tracks/fsharp/exercises/bob/BobTest.fs +2 -2
- data/tracks/fsharp/exercises/bob/Example.fs +10 -4
- data/tracks/fsharp/exercises/book-store/BookStoreTest.fs +5 -1
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscriptionTest.fs +1 -13
- data/tracks/fsharp/generators/CanonicalData.fs +14 -7
- data/tracks/fsharp/generators/Exercise.fs +84 -18
- data/tracks/fsharp/generators/Generators.fs +65 -62
- data/tracks/fsharp/generators/Generators.fsproj +0 -4
- data/tracks/fsharp/generators/Options.fs +51 -17
- data/tracks/fsharp/generators/Program.fs +34 -7
- data/tracks/fsharp/generators/Rendering.fs +2 -1
- data/tracks/go/config.json +11 -0
- data/tracks/go/exercises/reverse-string/.meta/gen.go +52 -0
- data/tracks/go/exercises/reverse-string/README.md +31 -0
- data/tracks/go/exercises/reverse-string/cases_test.go +37 -0
- data/tracks/go/exercises/reverse-string/example.go +10 -0
- data/tracks/go/exercises/reverse-string/reverse_string_test.go +25 -0
- data/tracks/haskell/exercises/bob/README.md +2 -0
- data/tracks/haskell/exercises/bob/examples/success-standard/src/Bob.hs +7 -3
- data/tracks/haskell/exercises/bob/package.yaml +1 -1
- data/tracks/haskell/exercises/bob/test/Tests.hs +1 -1
- data/tracks/haskell/exercises/isbn-verifier/README.md +25 -20
- data/tracks/haskell/exercises/pov/README.md +0 -2
- data/tracks/haskell/exercises/secret-handshake/README.md +1 -1
- data/tracks/haskell/exercises/simple-cipher/README.md +4 -6
- data/tracks/java/config.json +12 -0
- data/tracks/java/exercises/beer-song/README.md +1 -1
- data/tracks/java/exercises/house/README.md +1 -1
- data/tracks/java/exercises/isbn-verifier/README.md +27 -21
- data/tracks/java/exercises/kindergarten-garden/README.md +3 -3
- data/tracks/java/exercises/meetup/README.md +16 -12
- data/tracks/java/exercises/nucleotide-count/README.md +2 -2
- data/tracks/java/exercises/palindrome-products/README.md +1 -1
- data/tracks/java/exercises/parallel-letter-frequency/.meta/HINTS.md +3 -0
- data/tracks/java/exercises/parallel-letter-frequency/.meta/src/reference/java/ParallelLetterFrequency.java +45 -0
- data/tracks/java/exercises/parallel-letter-frequency/README.md +30 -0
- data/tracks/java/exercises/parallel-letter-frequency/build.gradle +18 -0
- data/tracks/java/exercises/parallel-letter-frequency/src/main/java/.keep +0 -0
- data/tracks/java/exercises/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java +235 -0
- data/tracks/java/exercises/pig-latin/README.md +1 -0
- data/tracks/java/exercises/protein-translation/README.md +4 -2
- data/tracks/java/exercises/rectangles/README.md +9 -9
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/simple-cipher/README.md +4 -6
- data/tracks/java/exercises/sum-of-multiples/README.md +3 -3
- data/tracks/objective-c/config.json +11 -0
- data/tracks/objective-c/exercises/two-fer/TwoFerExample.h +15 -0
- data/tracks/objective-c/exercises/two-fer/TwoFerExample.m +21 -0
- data/tracks/objective-c/exercises/two-fer/TwoFerTest.m +31 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
- data/tracks/rust/exercises/bob/Cargo.toml +1 -1
- data/tracks/rust/exercises/bob/README.md +2 -0
- data/tracks/rust/exercises/bob/example.rs +1 -0
- data/tracks/rust/exercises/bob/tests/bob.rs +1 -1
- data/tracks/rust/exercises/isbn-verifier/README.md +25 -20
- data/tracks/typescript/config.json +13 -0
- data/tracks/typescript/exercises/atbash-cipher/README.md +60 -0
- data/tracks/typescript/exercises/atbash-cipher/atbash-cipher.example.ts +32 -0
- data/tracks/typescript/exercises/atbash-cipher/atbash-cipher.test.ts +73 -0
- data/tracks/typescript/exercises/atbash-cipher/atbash-cipher.ts +0 -0
- data/tracks/typescript/exercises/atbash-cipher/package.json +36 -0
- data/tracks/typescript/exercises/atbash-cipher/tsconfig.json +22 -0
- data/tracks/typescript/exercises/atbash-cipher/tslint.json +127 -0
- data/tracks/typescript/exercises/atbash-cipher/yarn.lock +2624 -0
- metadata +31 -2
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Protein Translation
|
2
|
+
|
3
|
+
Translate RNA sequences into proteins.
|
2
4
|
|
3
5
|
RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so:
|
4
6
|
|
@@ -55,4 +57,4 @@ Tyler Long
|
|
55
57
|
|
56
58
|
## Submitting Incomplete Solutions
|
57
59
|
|
58
|
-
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
60
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -37,27 +37,27 @@ The above diagram contains 6 rectangles:
|
|
37
37
|
```
|
38
38
|
|
39
39
|
```text
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
+--+
|
43
43
|
| |
|
44
44
|
+--+
|
45
45
|
```
|
46
46
|
|
47
47
|
```text
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
|
50
50
|
+--+
|
51
51
|
| |
|
52
52
|
+--+
|
53
53
|
```
|
54
54
|
|
55
55
|
```text
|
56
|
-
|
57
|
-
++
|
58
|
-
++
|
59
|
-
|
60
|
-
|
56
|
+
|
57
|
+
++
|
58
|
+
++
|
59
|
+
|
60
|
+
|
61
61
|
```
|
62
62
|
|
63
63
|
You may assume that the input is always a proper rectangle (i.e. the length of
|
@@ -58,15 +58,13 @@ would get the same thing as the Caesar Cipher.
|
|
58
58
|
|
59
59
|
The weakest link in any cipher is the human being. Let's make your
|
60
60
|
substitution cipher a little more fault tolerant by providing a source
|
61
|
-
of randomness and ensuring that the key
|
62
|
-
capital letters.
|
61
|
+
of randomness and ensuring that the key contains only lowercase letters.
|
63
62
|
|
64
63
|
If someone doesn't submit a key at all, generate a truly random key of
|
65
|
-
at least 100 characters in length
|
66
|
-
syntax means instance variable)
|
64
|
+
at least 100 characters in length.
|
67
65
|
|
68
|
-
If the key submitted
|
69
|
-
|
66
|
+
If the key submitted is not composed only of lowercase letters, your
|
67
|
+
solution should handle the error in a language-appropriate way.
|
70
68
|
|
71
69
|
## Extensions
|
72
70
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# Sum Of Multiples
|
2
2
|
|
3
|
-
Given a number, find the sum of all the multiples of particular numbers up to
|
3
|
+
Given a number, find the sum of all the unique multiples of particular numbers up to
|
4
4
|
but not including that number.
|
5
5
|
|
6
|
-
If we list all the natural numbers
|
7
|
-
|
6
|
+
If we list all the natural numbers below 20 that are multiples of 3 or 5,
|
7
|
+
we get 3, 5, 6, 9, 10, 12, 15, and 18.
|
8
8
|
|
9
9
|
The sum of these multiples is 78.
|
10
10
|
|
@@ -12,6 +12,17 @@
|
|
12
12
|
"unlocked_by": null,
|
13
13
|
"uuid": "da5eb908-8cdf-4f99-93f7-c2b7dcb4fb37"
|
14
14
|
},
|
15
|
+
{
|
16
|
+
"core": false,
|
17
|
+
"difficulty": 1,
|
18
|
+
"slug": "two-fer",
|
19
|
+
"topics": [
|
20
|
+
"optional_values",
|
21
|
+
"text_formatting"
|
22
|
+
],
|
23
|
+
"unlocked_by": null,
|
24
|
+
"uuid": "46da53f3-a39b-4f19-8ade-87f434cf12ec"
|
25
|
+
},
|
15
26
|
{
|
16
27
|
"core": false,
|
17
28
|
"difficulty": 1,
|
@@ -0,0 +1,15 @@
|
|
1
|
+
//
|
2
|
+
// TwoFerExample.h
|
3
|
+
// xobjectivecTest
|
4
|
+
//
|
5
|
+
// Created by Rob Hudson on 11/30/17.
|
6
|
+
// Copyright © 2017 exercism. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <Foundation/Foundation.h>
|
10
|
+
|
11
|
+
@interface TwoFer : NSObject
|
12
|
+
|
13
|
+
+ (nonnull NSString *)twoFerWithName:(nullable NSString *)name;
|
14
|
+
|
15
|
+
@end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
//
|
2
|
+
// TwoFerExample.m
|
3
|
+
// xobjectivecTest
|
4
|
+
//
|
5
|
+
// Created by Rob Hudson on 11/30/17.
|
6
|
+
// Copyright © 2017 exercism. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "TwoFerExample.h"
|
10
|
+
|
11
|
+
@implementation TwoFer
|
12
|
+
|
13
|
+
+ (NSString *)twoFerWithName:(NSString *)name {
|
14
|
+
if (!name) {
|
15
|
+
name = @"you"; // !OCLint
|
16
|
+
}
|
17
|
+
|
18
|
+
return [NSString stringWithFormat:@"One for %@, one for me.", name];
|
19
|
+
}
|
20
|
+
|
21
|
+
@end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#import <XCTest/XCTest.h>
|
2
|
+
|
3
|
+
#if __has_include("TwoFerExample.h")
|
4
|
+
# import "TwoFerExample.h"
|
5
|
+
# else
|
6
|
+
# import "TwoFer.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
@interface TwoFerTest : XCTestCase
|
10
|
+
|
11
|
+
@end
|
12
|
+
|
13
|
+
@implementation TwoFerTest
|
14
|
+
|
15
|
+
NS_ASSUME_NONNULL_BEGIN
|
16
|
+
|
17
|
+
- (void)testNoNameGiven {
|
18
|
+
XCTAssertEqualObjects([TwoFer twoFerWithName:nil], @"One for you, one for me.");
|
19
|
+
}
|
20
|
+
|
21
|
+
- (void)testANameGiven {
|
22
|
+
XCTAssertEqualObjects([TwoFer twoFerWithName:@"Alice"], @"One for Alice, one for me.");
|
23
|
+
}
|
24
|
+
|
25
|
+
- (void)testAnotherNameGiven {
|
26
|
+
XCTAssertEqualObjects([TwoFer twoFerWithName:@"Bob"], @"One for Bob, one for me.");
|
27
|
+
}
|
28
|
+
|
29
|
+
NS_ASSUME_NONNULL_END
|
30
|
+
|
31
|
+
@end
|
@@ -79,6 +79,8 @@
|
|
79
79
|
E951B6B91D429550009EB5B6 /* AllergiesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E951B6B81D429550009EB5B6 /* AllergiesTest.m */; };
|
80
80
|
E95C52551E81C82A0095D321 /* BinarySearchExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E95C52531E81C82A0095D321 /* BinarySearchExample.m */; };
|
81
81
|
E95C52561E81C82A0095D321 /* BinarySearchTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E95C52541E81C82A0095D321 /* BinarySearchTest.m */; };
|
82
|
+
E9630C491FD07A880024EE90 /* TwoFerExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E9630C481FD07A880024EE90 /* TwoFerExample.m */; };
|
83
|
+
E9630C4B1FD07AA10024EE90 /* TwoFerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E9630C4A1FD07AA10024EE90 /* TwoFerTest.m */; };
|
82
84
|
E964F68F1FBF9CA6000114D9 /* SayExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E964F68E1FBF9CA6000114D9 /* SayExample.m */; };
|
83
85
|
E964F6911FBF9CC6000114D9 /* SayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E964F6901FBF9CC6000114D9 /* SayTest.m */; };
|
84
86
|
E96993981DF60E1E009EA223 /* TransposeExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E96993971DF60E1E009EA223 /* TransposeExample.m */; };
|
@@ -199,6 +201,9 @@
|
|
199
201
|
E95C52521E81C82A0095D321 /* BinarySearchExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BinarySearchExample.h; path = "../../exercises/binary-search/BinarySearchExample.h"; sourceTree = "<group>"; };
|
200
202
|
E95C52531E81C82A0095D321 /* BinarySearchExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BinarySearchExample.m; path = "../../exercises/binary-search/BinarySearchExample.m"; sourceTree = "<group>"; };
|
201
203
|
E95C52541E81C82A0095D321 /* BinarySearchTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BinarySearchTest.m; path = "../../exercises/binary-search/BinarySearchTest.m"; sourceTree = "<group>"; };
|
204
|
+
E9630C471FD07A880024EE90 /* TwoFerExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TwoFerExample.h; path = "../../exercises/two-fer/TwoFerExample.h"; sourceTree = "<group>"; };
|
205
|
+
E9630C481FD07A880024EE90 /* TwoFerExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TwoFerExample.m; path = "../../exercises/two-fer/TwoFerExample.m"; sourceTree = "<group>"; };
|
206
|
+
E9630C4A1FD07AA10024EE90 /* TwoFerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TwoFerTest.m; path = "../../exercises/two-fer/TwoFerTest.m"; sourceTree = "<group>"; };
|
202
207
|
E964F68D1FBF9CA6000114D9 /* SayExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SayExample.h; path = ../../exercises/say/SayExample.h; sourceTree = "<group>"; };
|
203
208
|
E964F68E1FBF9CA6000114D9 /* SayExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SayExample.m; path = ../../exercises/say/SayExample.m; sourceTree = "<group>"; };
|
204
209
|
E964F6901FBF9CC6000114D9 /* SayTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SayTest.m; path = ../../exercises/say/SayTest.m; sourceTree = "<group>"; };
|
@@ -299,6 +304,7 @@
|
|
299
304
|
E99D1D7B1D5532C50006A303 /* SumOfMultiples */,
|
300
305
|
E96993951DF60DF1009EA223 /* Transpose */,
|
301
306
|
E947A4DB1D81FDDA00633720 /* Triangle */,
|
307
|
+
E9630C441FD07A390024EE90 /* TwoFer */,
|
302
308
|
E9E8B6F71D519E3A0012F12C /* WordCount */,
|
303
309
|
1E50BD001CB465C500FC128D /* Info.plist */,
|
304
310
|
);
|
@@ -462,6 +468,16 @@
|
|
462
468
|
name = BinarySearch;
|
463
469
|
sourceTree = "<group>";
|
464
470
|
};
|
471
|
+
E9630C441FD07A390024EE90 /* TwoFer */ = {
|
472
|
+
isa = PBXGroup;
|
473
|
+
children = (
|
474
|
+
E9630C471FD07A880024EE90 /* TwoFerExample.h */,
|
475
|
+
E9630C481FD07A880024EE90 /* TwoFerExample.m */,
|
476
|
+
E9630C4A1FD07AA10024EE90 /* TwoFerTest.m */,
|
477
|
+
);
|
478
|
+
name = TwoFer;
|
479
|
+
sourceTree = "<group>";
|
480
|
+
};
|
465
481
|
E964F68C1FBF9B6B000114D9 /* Say */ = {
|
466
482
|
isa = PBXGroup;
|
467
483
|
children = (
|
@@ -852,6 +868,7 @@
|
|
852
868
|
A097D4101E363C2700EAF2C2 /* BracketPushTest.m in Sources */,
|
853
869
|
E95C52551E81C82A0095D321 /* BinarySearchExample.m in Sources */,
|
854
870
|
1EFACABC1CCCAF3D006F2E69 /* WordCountTest.m in Sources */,
|
871
|
+
E9630C4B1FD07AA10024EE90 /* TwoFerTest.m in Sources */,
|
855
872
|
1EFACAB11CCCAF3D006F2E69 /* NucleotideCountExample.m in Sources */,
|
856
873
|
E9381D481D8EE00C003F22A1 /* DifferenceOfSquaresTest.m in Sources */,
|
857
874
|
E907FE941D87554500B93DA9 /* ScrabbleScoreTest.m in Sources */,
|
@@ -888,6 +905,7 @@
|
|
888
905
|
1EFACAA91CCCAF3D006F2E69 /* GradeSchoolExample.m in Sources */,
|
889
906
|
1EFACABA1CCCAF3D006F2E69 /* SpaceAgeTest.m in Sources */,
|
890
907
|
1EFACAB91CCCAF3D006F2E69 /* SpaceAgeExample.m in Sources */,
|
908
|
+
E9630C491FD07A880024EE90 /* TwoFerExample.m in Sources */,
|
891
909
|
E9F390091DFCA350005C5F46 /* IsogramTest.m in Sources */,
|
892
910
|
E964F6911FBF9CC6000114D9 /* SayTest.m in Sources */,
|
893
911
|
E951B6B71D4294E6009EB5B6 /* AllergiesExample.m in Sources */,
|
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
|
|
6
6
|
|
7
7
|
He answers 'Whoa, chill out!' if you yell at him.
|
8
8
|
|
9
|
+
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
|
10
|
+
|
9
11
|
He says 'Fine. Be that way!' if you address him without actually saying
|
10
12
|
anything.
|
11
13
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
pub fn reply(message: &str) -> &str {
|
2
2
|
if is_silence(message) { "Fine. Be that way!" }
|
3
|
+
else if is_yelling(message) && is_question(message) { "Calm down, I know what I'm doing!" }
|
3
4
|
else if is_yelling(message) { "Whoa, chill out!" }
|
4
5
|
else if is_question(message) { "Sure." }
|
5
6
|
else { "Whatever." }
|
@@ -1,40 +1,45 @@
|
|
1
1
|
# Isbn Verifier
|
2
2
|
|
3
|
-
|
3
|
+
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification
|
4
|
+
numbers. These normally contain dashes and look like: `3-598-21508-8`
|
4
5
|
|
5
|
-
##
|
6
|
+
## ISBN
|
6
7
|
|
7
|
-
|
8
|
-
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
8
|
+
The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula:
|
9
9
|
|
10
|
-
|
10
|
+
```
|
11
|
+
(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0
|
12
|
+
```
|
11
13
|
|
12
|
-
|
14
|
+
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid.
|
13
15
|
|
14
|
-
|
15
|
-
The first digit block indicates the group where the ISBN belongs. Groups can consist of shared languages, geographic regions or countries. The leading '3' signals this ISBN is from a german speaking country.
|
16
|
-
The following number block is to identify the publisher. Since this is a three digit publisher number there is a 5 digit title number for this book.
|
17
|
-
The last digit in the ISBN is the check digit which is used to detect read errors.
|
16
|
+
## Example
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
Let's take the ISBN-10 `3-598-21508-8`. We plug it in to the formula, and get:
|
19
|
+
```
|
20
|
+
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0
|
21
|
+
```
|
22
|
+
|
23
|
+
Since the result is 0, this proves that our ISBN is valid.
|
24
|
+
|
25
|
+
## Task
|
26
|
+
|
27
|
+
Given a string the program should check if the provided string is a valid ISBN-10.
|
28
|
+
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
21
29
|
|
22
|
-
|
23
|
-
So for our example ISBN this means:
|
24
|
-
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 = 0
|
30
|
+
The program should be able to verify ISBN-10 both with and without separating dashes.
|
25
31
|
|
26
|
-
Which proves that the ISBN is valid.
|
27
32
|
|
28
33
|
## Caveats
|
29
34
|
|
30
|
-
Converting from
|
31
|
-
|
35
|
+
Converting from strings to numbers can be tricky in certain languages.
|
36
|
+
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). For instance `3-598-21507-X` is a valid ISBN-10.
|
32
37
|
|
33
38
|
## Bonus tasks
|
34
39
|
|
35
|
-
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier)
|
40
|
+
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier).
|
36
41
|
|
37
|
-
* Generate valid ISBN, maybe even from a given starting ISBN
|
42
|
+
* Generate valid ISBN, maybe even from a given starting ISBN.
|
38
43
|
## Rust Installation
|
39
44
|
|
40
45
|
Refer to the [exercism help page][help-page] for Rust installation and learning
|
@@ -541,6 +541,19 @@
|
|
541
541
|
"games",
|
542
542
|
"parsing"
|
543
543
|
]
|
544
|
+
},
|
545
|
+
{
|
546
|
+
"uuid": "04de61fb-9fde-461c-b306-0b4ce52e2169",
|
547
|
+
"slug": "atbash-cipher",
|
548
|
+
"core": true,
|
549
|
+
"difficulty": 7,
|
550
|
+
"topics": [
|
551
|
+
"algorithms",
|
552
|
+
"arrays",
|
553
|
+
"control-flow-(conditionals)",
|
554
|
+
"control-flow-(loops)",
|
555
|
+
"text-formatting"
|
556
|
+
]
|
544
557
|
}
|
545
558
|
],
|
546
559
|
"foregone": [],
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Atbash Cipher
|
2
|
+
|
3
|
+
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
|
4
|
+
|
5
|
+
The Atbash cipher is a simple substitution cipher that relies on
|
6
|
+
transposing all the letters in the alphabet such that the resulting
|
7
|
+
alphabet is backwards. The first letter is replaced with the last
|
8
|
+
letter, the second with the second-last, and so on.
|
9
|
+
|
10
|
+
An Atbash cipher for the Latin alphabet would be as follows:
|
11
|
+
|
12
|
+
```text
|
13
|
+
Plain: abcdefghijklmnopqrstuvwxyz
|
14
|
+
Cipher: zyxwvutsrqponmlkjihgfedcba
|
15
|
+
```
|
16
|
+
|
17
|
+
It is a very weak cipher because it only has one possible key, and it is
|
18
|
+
a simple monoalphabetic substitution cipher. However, this may not have
|
19
|
+
been an issue in the cipher's time.
|
20
|
+
|
21
|
+
Ciphertext is written out in groups of fixed length, the traditional group size
|
22
|
+
being 5 letters, and punctuation is excluded. This is to make it harder to guess
|
23
|
+
things based on word boundaries.
|
24
|
+
|
25
|
+
## Examples
|
26
|
+
|
27
|
+
- Encoding `test` gives `gvhg`
|
28
|
+
- Decoding `gvhg` gives `test`
|
29
|
+
- Decoding `gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt` gives `thequickbrownfoxjumpsoverthelazydog`
|
30
|
+
## Setup
|
31
|
+
|
32
|
+
Go through the setup instructions for TypeScript to
|
33
|
+
install the necessary dependencies:
|
34
|
+
|
35
|
+
http://exercism.io/languages/typescript
|
36
|
+
|
37
|
+
## Requirements
|
38
|
+
|
39
|
+
Install assignment dependencies:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
$ yarn install
|
43
|
+
```
|
44
|
+
|
45
|
+
## Making the test suite pass
|
46
|
+
|
47
|
+
Execute the tests with:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ yarn test
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
## Source
|
56
|
+
|
57
|
+
Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup)
|
58
|
+
|
59
|
+
## Submitting Incomplete Solutions
|
60
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class AtbashCipher {
|
2
|
+
private alphabet: string = "abcdefghijklmnopqrstuvwxyz"
|
3
|
+
private numbers: string = "0123456789"
|
4
|
+
|
5
|
+
public encode(plainText: string) {
|
6
|
+
const lowerCaseLettersOnly = plainText
|
7
|
+
.toLowerCase()
|
8
|
+
.split("")
|
9
|
+
.filter((char) => this.alphabet.includes(char) || this.numbers.includes(char))
|
10
|
+
.join("")
|
11
|
+
|
12
|
+
return this.decode(lowerCaseLettersOnly)
|
13
|
+
.split("")
|
14
|
+
.reduce((accumulator: string[], _, index, array) => {
|
15
|
+
if (index % 5 === 0) {
|
16
|
+
accumulator.push(array.slice(index, index + 5).join(""))
|
17
|
+
}
|
18
|
+
return accumulator
|
19
|
+
}, [])
|
20
|
+
.join(" ")
|
21
|
+
}
|
22
|
+
|
23
|
+
public decode(cipherText: string) {
|
24
|
+
return cipherText
|
25
|
+
.split(" ").join("")
|
26
|
+
.split("")
|
27
|
+
.map((char) => this.alphabet.includes(char) ? this.alphabet[25 - this.alphabet.indexOf(char)] : char)
|
28
|
+
.join("")
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
export default AtbashCipher
|