trackler 2.0.8.6 → 2.0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/bin/verify-metadata +7 -11
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/clojure/config.json +5 -0
  5. data/tracks/clojure/exercises/luhn/luhn.mustache +9 -0
  6. data/tracks/clojure/exercises/luhn/src/example.clj +11 -9
  7. data/tracks/clojure/exercises/luhn/test/luhn_test.clj +29 -29
  8. data/tracks/clojure/exercises/nth-prime/project.clj +4 -0
  9. data/tracks/clojure/exercises/nth-prime/src/example.clj +33 -0
  10. data/tracks/clojure/exercises/nth-prime/test/nth_prime_test.clj +23 -0
  11. data/tracks/go/exercises/TRACK_HINTS.md +3 -0
  12. data/tracks/go/exercises/ocr-numbers/example.go +2 -0
  13. data/tracks/go/exercises/ocr-numbers/ocr_numbers_test.go +8 -0
  14. data/tracks/go/exercises/octal/octal_test.go +6 -6
  15. data/tracks/go/exercises/paasio/paasio_test.go +5 -3
  16. data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +6 -6
  17. data/tracks/go/exercises/strain/strain_test.go +37 -39
  18. data/tracks/julia/config.json +19 -0
  19. data/tracks/julia/exercises/etl/etl.jl +4 -0
  20. data/tracks/julia/exercises/etl/example.jl +11 -0
  21. data/tracks/julia/exercises/etl/runtests.jl +36 -0
  22. data/tracks/julia/exercises/pascals-triangle/example.jl +1 -0
  23. data/tracks/julia/exercises/pascals-triangle/pascals-triangle.jl +3 -0
  24. data/tracks/julia/exercises/pascals-triangle/runtests.jl +14 -0
  25. data/tracks/rust/config.json +22 -1
  26. data/tracks/rust/exercises/luhn-from/.gitignore +7 -0
  27. data/tracks/rust/exercises/luhn-from/Cargo.toml +3 -0
  28. data/tracks/rust/exercises/luhn-from/description.md +9 -0
  29. data/tracks/rust/exercises/luhn-from/example.rs +62 -0
  30. data/tracks/rust/exercises/luhn-from/metadata.yml +3 -0
  31. data/tracks/rust/exercises/luhn-from/tests/luhn-from.rs +101 -0
  32. data/tracks/rust/exercises/luhn-trait/.gitignore +7 -0
  33. data/tracks/rust/exercises/luhn-trait/Cargo.toml +3 -0
  34. data/tracks/rust/exercises/luhn-trait/description.md +17 -0
  35. data/tracks/rust/exercises/luhn-trait/example.rs +55 -0
  36. data/tracks/rust/exercises/luhn-trait/metadata.yml +3 -0
  37. data/tracks/rust/exercises/luhn-trait/tests/luhn-trait.rs +59 -0
  38. data/tracks/rust/exercises/nucleotide-codons/tests/codons.rs +24 -5
  39. data/tracks/rust/exercises/protein-translation/Cargo.lock +4 -0
  40. data/tracks/rust/exercises/protein-translation/Cargo.toml +4 -0
  41. data/tracks/rust/exercises/protein-translation/example.rs +40 -0
  42. data/tracks/rust/exercises/protein-translation/tests/proteins.rs +116 -0
  43. metadata +28 -2
@@ -0,0 +1,59 @@
1
+ extern crate luhn_trait;
2
+
3
+ use luhn_trait::*;
4
+
5
+ #[test]
6
+ fn you_can_validate_from_a_str() {
7
+ assert!("046 454 286".valid_luhn());
8
+ assert!(!"046 454 287".valid_luhn());
9
+ }
10
+
11
+ #[test]
12
+ #[ignore]
13
+ fn you_can_validate_from_a_string() {
14
+ assert!(String::from("046 454 286").valid_luhn());
15
+ assert!(!String::from("046 454 287").valid_luhn());
16
+ }
17
+
18
+ #[test]
19
+ #[ignore]
20
+ fn you_can_validate_from_a_u8() {
21
+ assert!(240u8.valid_luhn());
22
+ assert!(!241u8.valid_luhn());
23
+ }
24
+
25
+ #[test]
26
+ #[ignore]
27
+ fn you_can_validate_from_a_u16() {
28
+ let valid = 64_436u16;
29
+ let invalid = 64_437u16;
30
+ assert!(valid.valid_luhn());
31
+ assert!(!invalid.valid_luhn());
32
+ }
33
+
34
+ #[test]
35
+ #[ignore]
36
+ fn you_can_validate_from_a_u32() {
37
+ let valid = 46_454_286u32;
38
+ let invalid = 46_454_287u32;
39
+ assert!(valid.valid_luhn());
40
+ assert!(!invalid.valid_luhn());
41
+ }
42
+
43
+ #[test]
44
+ #[ignore]
45
+ fn you_can_validate_from_a_u64() {
46
+ let valid = 8273_1232_7352_0562u64;
47
+ let invalid = 8273_1232_7352_0569u64;
48
+ assert!(valid.valid_luhn());
49
+ assert!(!invalid.valid_luhn());
50
+ }
51
+
52
+ #[test]
53
+ #[ignore]
54
+ fn you_can_validate_from_a_usize() {
55
+ let valid = 8273_1232_7352_0562usize;
56
+ let invalid = 8273_1232_7352_0569usize;
57
+ assert!(valid.valid_luhn());
58
+ assert!(!invalid.valid_luhn());
59
+ }
@@ -17,7 +17,8 @@ fn test_cysteine_tgt() {
17
17
  #[ignore]
18
18
  fn test_cysteine_tgy() { // "compressed" name for TGT and TGC
19
19
  let info = codons::parse(make_pairs());
20
- assert_eq!(info.name_for("TGY"), Ok("cysteine"));
20
+ assert_eq!(info.name_for("TGT"), info.name_for("TGY"));
21
+ assert_eq!(info.name_for("TGC"), info.name_for("TGY"));
21
22
  }
22
23
 
23
24
  #[test]
@@ -54,12 +55,30 @@ fn test_arginine_name() {
54
55
 
55
56
  #[test]
56
57
  #[ignore]
57
- fn test_invalid() {
58
+ fn empty_is_invalid() {
58
59
  let info = codons::parse(make_pairs());
59
60
  assert!(info.name_for("").is_err());
60
- assert!(info.name_for("VWX").is_err()); // X is not a shorthand
61
- assert!(info.name_for("AB").is_err()); // too short
62
- assert!(info.name_for("ABCD").is_err()); // too long
61
+ }
62
+
63
+ #[test]
64
+ #[ignore]
65
+ fn x_is_not_shorthand_so_is_invalid() {
66
+ let info = codons::parse(make_pairs());
67
+ assert!(info.name_for("VWX").is_err());
68
+ }
69
+
70
+ #[test]
71
+ #[ignore]
72
+ fn too_short_is_invalid() {
73
+ let info = codons::parse(make_pairs());
74
+ assert!(info.name_for("AT").is_err());
75
+ }
76
+
77
+ #[test]
78
+ #[ignore]
79
+ fn too_long_is_invalid() {
80
+ let info = codons::parse(make_pairs());
81
+ assert!(info.name_for("ATTA").is_err());
63
82
  }
64
83
 
65
84
  // The input data constructor. Returns a list of codon, name pairs.
@@ -0,0 +1,4 @@
1
+ [root]
2
+ name = "protein-translation"
3
+ version = "0.1.0"
4
+
@@ -0,0 +1,4 @@
1
+ [package]
2
+ name = "protein-translation"
3
+ version = "0.1.0"
4
+ authors = ["Peter Minten <peter@pminten.nl>"]
@@ -0,0 +1,40 @@
1
+ use std::collections::HashMap;
2
+
3
+ pub struct CodonInfo<'a> {
4
+ actual_codons: HashMap<&'a str, &'a str>
5
+ }
6
+
7
+ pub fn parse<'a>(pairs: Vec<(&'a str, &'a str)>) -> CodonInfo<'a> {
8
+ CodonInfo{
9
+ actual_codons: pairs.into_iter().collect()
10
+ }
11
+ }
12
+
13
+ impl<'a> CodonInfo<'a> {
14
+ pub fn name_for(&self, codon: &str) -> Result<&'a str, &'static str> {
15
+ if codon.len() != 3 {
16
+ return Err("invalid length")
17
+ }
18
+
19
+ let mut valid = true;
20
+ let lookup: String = codon.chars().map(|l| {
21
+ // Get an example of a "letter" represented by the possibly encoded letter.
22
+ // Since every codon represented by the compressed notation has to be of
23
+ // the desired amino acid just picking one at random will do.
24
+ match l {
25
+ 'A' | 'W' | 'M' | 'R' | 'D' | 'H' | 'V' | 'N' => 'A',
26
+ 'C' | 'S' | 'Y' | 'B' => 'C',
27
+ 'G' | 'K' => 'G',
28
+ 'T' => 'T',
29
+ _ => { valid = false; ' ' }
30
+ }
31
+ }).collect();
32
+ if !valid {
33
+ return Err("invalid char")
34
+ }
35
+
36
+ // If the input table is correct (which it is) every valid codon is in it
37
+ // so unwrap() shouldn't panic.
38
+ Ok(self.actual_codons.get(&lookup.as_ref()).unwrap())
39
+ }
40
+ }
@@ -0,0 +1,116 @@
1
+ extern crate protein_translation as proteins;
2
+
3
+ #[test]
4
+ fn test_methionine() {
5
+ let info = proteins::parse(make_pairs());
6
+ assert_eq!(info.name_for("ATG"), Ok("methionine"));
7
+ }
8
+
9
+ #[test]
10
+ #[ignore]
11
+ fn test_cysteine_tgt() {
12
+ let info = proteins::parse(make_pairs());
13
+ assert_eq!(info.name_for("TGT"), Ok("cysteine"));
14
+ }
15
+
16
+ #[test]
17
+ #[ignore]
18
+ fn test_cysteine_tgy() { // "compressed" name for TGT and TGC
19
+ let info = proteins::parse(make_pairs());
20
+ assert_eq!(info.name_for("TGT"), info.name_for("TGY"));
21
+ assert_eq!(info.name_for("TGC"), info.name_for("TGY"));
22
+ }
23
+
24
+ #[test]
25
+ #[ignore]
26
+ fn test_stop() {
27
+ let info = proteins::parse(make_pairs());
28
+ assert_eq!(info.name_for("TAA"), Ok("stop codon"));
29
+ }
30
+
31
+ #[test]
32
+ #[ignore]
33
+ fn test_valine() {
34
+ let info = proteins::parse(make_pairs());
35
+ assert_eq!(info.name_for("GTN"), Ok("valine"));
36
+ }
37
+
38
+
39
+ #[test]
40
+ #[ignore]
41
+ fn test_isoleucine() {
42
+ let info = proteins::parse(make_pairs());
43
+ assert_eq!(info.name_for("ATH"), Ok("isoleucine"));
44
+ }
45
+
46
+ #[test]
47
+ #[ignore]
48
+ fn test_arginine_name() {
49
+ // In arginine CGA can be "compresed" both as CGN and as MGR
50
+ let info = proteins::parse(make_pairs());
51
+ assert_eq!(info.name_for("CGA"), Ok("arginine"));
52
+ assert_eq!(info.name_for("CGN"), Ok("arginine"));
53
+ assert_eq!(info.name_for("MGR"), Ok("arginine"));
54
+ }
55
+
56
+ #[test]
57
+ #[ignore]
58
+ fn empty_is_invalid() {
59
+ let info = proteins::parse(make_pairs());
60
+ assert!(info.name_for("").is_err());
61
+ }
62
+
63
+ #[test]
64
+ #[ignore]
65
+ fn x_is_not_shorthand_so_is_invalid() {
66
+ let info = proteins::parse(make_pairs());
67
+ assert!(info.name_for("VWX").is_err());
68
+ }
69
+
70
+ #[test]
71
+ #[ignore]
72
+ fn too_short_is_invalid() {
73
+ let info = proteins::parse(make_pairs());
74
+ assert!(info.name_for("AT").is_err());
75
+ }
76
+
77
+ #[test]
78
+ #[ignore]
79
+ fn too_long_is_invalid() {
80
+ let info = proteins::parse(make_pairs());
81
+ assert!(info.name_for("ATTA").is_err());
82
+ }
83
+
84
+ // The input data constructor. Returns a list of codon, name pairs.
85
+ fn make_pairs() -> Vec<(&'static str, &'static str)> {
86
+ let grouped = vec![
87
+ ("isoleucine", vec!["ATT", "ATC", "ATA"]),
88
+ ("leucine", vec!["CTT", "CTC", "CTA", "CTG", "TTA", "TTG"]),
89
+ ("valine", vec!["GTT", "GTC", "GTA", "GTG"]),
90
+ ("phenylalanine", vec!["TTT", "TTC"]),
91
+ ("methionine", vec!["ATG"]),
92
+ ("cysteine", vec!["TGT", "TGC"]),
93
+ ("alanine", vec!["GCT", "GCC", "GCA", "GCG"]),
94
+ ("glycine", vec!["GGT", "GGC", "GGA", "GGG"]),
95
+ ("proline", vec!["CCT", "CCC", "CCA", "CCG"]),
96
+ ("threonine", vec!["ACT", "ACC", "ACA", "ACG"]),
97
+ ("serine", vec!["TCT", "TCC", "TCA", "TCG", "AGT", "AGC"]),
98
+ ("tyrosine", vec!["TAT", "TAC"]),
99
+ ("tryptophan", vec!["TGG"]),
100
+ ("glutamine", vec!["CAA", "CAG"]),
101
+ ("asparagine", vec!["AAT", "AAC"]),
102
+ ("histidine", vec!["CAT", "CAC"]),
103
+ ("glutamic acid", vec!["GAA", "GAG"]),
104
+ ("aspartic acid", vec!["GAT", "GAC"]),
105
+ ("lysine", vec!["AAA", "AAG"]),
106
+ ("arginine", vec!["CGT", "CGC", "CGA", "CGG", "AGA", "AGG"]),
107
+ ("stop codon", vec!["TAA", "TAG", "TGA"])];
108
+ let mut pairs = Vec::<(&'static str, &'static str)>::new();
109
+ for (name, codons) in grouped.into_iter() {
110
+ for codon in codons {
111
+ pairs.push((codon, name));
112
+ }
113
+ };
114
+ pairs.sort_by(|&(_, a), &(_, b)| a.cmp(b));
115
+ return pairs
116
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8.6
4
+ version: 2.0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-26 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -930,6 +930,7 @@ files:
930
930
  - tracks/clojure/exercises/leap/project.clj
931
931
  - tracks/clojure/exercises/leap/src/example.clj
932
932
  - tracks/clojure/exercises/leap/test/leap_test.clj
933
+ - tracks/clojure/exercises/luhn/luhn.mustache
933
934
  - tracks/clojure/exercises/luhn/project.clj
934
935
  - tracks/clojure/exercises/luhn/src/example.clj
935
936
  - tracks/clojure/exercises/luhn/test/luhn_test.clj
@@ -939,6 +940,9 @@ files:
939
940
  - tracks/clojure/exercises/minesweeper/project.clj
940
941
  - tracks/clojure/exercises/minesweeper/src/example.clj
941
942
  - tracks/clojure/exercises/minesweeper/test/minesweeper_test.clj
943
+ - tracks/clojure/exercises/nth-prime/project.clj
944
+ - tracks/clojure/exercises/nth-prime/src/example.clj
945
+ - tracks/clojure/exercises/nth-prime/test/nth_prime_test.clj
942
946
  - tracks/clojure/exercises/nucleotide-count/project.clj
943
947
  - tracks/clojure/exercises/nucleotide-count/src/example.clj
944
948
  - tracks/clojure/exercises/nucleotide-count/test/nucleotide_count_test.clj
@@ -4365,6 +4369,9 @@ files:
4365
4369
  - tracks/julia/exercises/difference-of-squares/difference-of-squares.jl
4366
4370
  - tracks/julia/exercises/difference-of-squares/example.jl
4367
4371
  - tracks/julia/exercises/difference-of-squares/runtests.jl
4372
+ - tracks/julia/exercises/etl/etl.jl
4373
+ - tracks/julia/exercises/etl/example.jl
4374
+ - tracks/julia/exercises/etl/runtests.jl
4368
4375
  - tracks/julia/exercises/gigasecond/example.jl
4369
4376
  - tracks/julia/exercises/gigasecond/gigasecond.jl
4370
4377
  - tracks/julia/exercises/gigasecond/runtests.jl
@@ -4389,6 +4396,9 @@ files:
4389
4396
  - tracks/julia/exercises/pangram/example.jl
4390
4397
  - tracks/julia/exercises/pangram/pangram.jl
4391
4398
  - tracks/julia/exercises/pangram/runtests.jl
4399
+ - tracks/julia/exercises/pascals-triangle/example.jl
4400
+ - tracks/julia/exercises/pascals-triangle/pascals-triangle.jl
4401
+ - tracks/julia/exercises/pascals-triangle/runtests.jl
4392
4402
  - tracks/julia/exercises/raindrops/example.jl
4393
4403
  - tracks/julia/exercises/raindrops/raindrops.jl
4394
4404
  - tracks/julia/exercises/raindrops/runtests.jl
@@ -6899,6 +6909,18 @@ files:
6899
6909
  - tracks/rust/exercises/leap/Cargo.toml
6900
6910
  - tracks/rust/exercises/leap/example.rs
6901
6911
  - tracks/rust/exercises/leap/tests/leap.rs
6912
+ - tracks/rust/exercises/luhn-from/.gitignore
6913
+ - tracks/rust/exercises/luhn-from/Cargo.toml
6914
+ - tracks/rust/exercises/luhn-from/description.md
6915
+ - tracks/rust/exercises/luhn-from/example.rs
6916
+ - tracks/rust/exercises/luhn-from/metadata.yml
6917
+ - tracks/rust/exercises/luhn-from/tests/luhn-from.rs
6918
+ - tracks/rust/exercises/luhn-trait/.gitignore
6919
+ - tracks/rust/exercises/luhn-trait/Cargo.toml
6920
+ - tracks/rust/exercises/luhn-trait/description.md
6921
+ - tracks/rust/exercises/luhn-trait/example.rs
6922
+ - tracks/rust/exercises/luhn-trait/metadata.yml
6923
+ - tracks/rust/exercises/luhn-trait/tests/luhn-trait.rs
6902
6924
  - tracks/rust/exercises/luhn/.gitignore
6903
6925
  - tracks/rust/exercises/luhn/Cargo.toml
6904
6926
  - tracks/rust/exercises/luhn/example.rs
@@ -6946,6 +6968,10 @@ files:
6946
6968
  - tracks/rust/exercises/phone-number/Cargo.toml
6947
6969
  - tracks/rust/exercises/phone-number/example.rs
6948
6970
  - tracks/rust/exercises/phone-number/tests/phone-number.rs
6971
+ - tracks/rust/exercises/protein-translation/Cargo.lock
6972
+ - tracks/rust/exercises/protein-translation/Cargo.toml
6973
+ - tracks/rust/exercises/protein-translation/example.rs
6974
+ - tracks/rust/exercises/protein-translation/tests/proteins.rs
6949
6975
  - tracks/rust/exercises/queen-attack/.gitignore
6950
6976
  - tracks/rust/exercises/queen-attack/Cargo.lock
6951
6977
  - tracks/rust/exercises/queen-attack/Cargo.toml