trackler 2.0.3.8 → 2.0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/book-store/description.md +67 -0
  3. data/common/exercises/book-store/metadata.yml +4 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/crystal/exercises/difference-of-squares/src/difference_of_squares.cr +1 -0
  6. data/tracks/ecmascript/exercises/custom-set/package.json +1 -0
  7. data/tracks/ecmascript/exercises/palindrome-products/palindrome-products.js +18 -18
  8. data/tracks/fsharp/docs/INSTALLATION.md +2 -3
  9. data/tracks/fsharp/docs/TESTS.md +1 -1
  10. data/tracks/fsharp/exercises/accumulate/HINTS.md +3 -0
  11. data/tracks/fsharp/exercises/diamond/HINTS.md +2 -0
  12. data/tracks/fsharp/exercises/grains/HINTS.md +1 -1
  13. data/tracks/fsharp/exercises/hello-world/HINTS.md +1 -1
  14. data/tracks/fsharp/exercises/parallel-letter-frequency/HINTS.md +3 -0
  15. data/tracks/fsharp/exercises/poker/HINTS.md +2 -0
  16. data/tracks/fsharp/exercises/raindrops/HINTS.md +2 -0
  17. data/tracks/fsharp/exercises/space-age/HINTS.md +3 -0
  18. data/tracks/javascript/exercises/bowling/bowling.spec.js +83 -63
  19. data/tracks/ocaml/config.json +5 -0
  20. data/tracks/ocaml/exercises/leap/test.ml +7 -13
  21. data/tracks/ocaml/exercises/robot-name/.merlin +3 -0
  22. data/tracks/ocaml/exercises/robot-name/Makefile +11 -0
  23. data/tracks/ocaml/exercises/robot-name/example.ml +26 -0
  24. data/tracks/ocaml/exercises/robot-name/robot_name.mli +7 -0
  25. data/tracks/ocaml/exercises/robot-name/test.ml +64 -0
  26. data/tracks/ocaml/tools/test-generator/Makefile +3 -0
  27. data/tracks/ocaml/tools/test-generator/README.md +1 -0
  28. data/tracks/ocaml/tools/test-generator/src/canonical_data_checker.ml +23 -0
  29. data/tracks/ocaml/tools/test-generator/src/controller.ml +12 -0
  30. data/tracks/ocaml/tools/test-generator/src/parser.ml +29 -22
  31. data/tracks/ocaml/tools/test-generator/src/utils.ml +8 -0
  32. data/tracks/ocaml/tools/test-generator/test/clock.json +437 -0
  33. data/tracks/ocaml/tools/test-generator/test/parser_test.ml +18 -4
  34. data/tracks/ocaml/tools/test-generator/test/with-methods-key.json +22 -0
  35. data/tracks/perl6/config.json +5 -0
  36. data/tracks/perl6/exercises/wordy/Example.p6 +16 -0
  37. data/tracks/perl6/exercises/wordy/cases.json +89 -0
  38. data/tracks/perl6/exercises/wordy/wordy.t +29 -0
  39. data/tracks/ruby/exercises/acronym/{.version → .meta/.version} +0 -0
  40. data/tracks/ruby/exercises/alphametics/{.version → .meta/.version} +0 -0
  41. data/tracks/ruby/exercises/anagram/{.version → .meta/.version} +0 -0
  42. data/tracks/ruby/exercises/binary/{.version → .meta/.version} +0 -0
  43. data/tracks/ruby/exercises/bowling/{.version → .meta/.version} +0 -0
  44. data/tracks/ruby/exercises/bracket-push/{.version → .meta/.version} +0 -0
  45. data/tracks/ruby/exercises/clock/{.version → .meta/.version} +0 -0
  46. data/tracks/ruby/exercises/connect/{.version → .meta/.version} +0 -0
  47. data/tracks/ruby/exercises/custom-set/{.version → .meta/.version} +0 -0
  48. data/tracks/ruby/exercises/difference-of-squares/{.version → .meta/.version} +0 -0
  49. data/tracks/ruby/exercises/dominoes/{.version → .meta/.version} +0 -0
  50. data/tracks/ruby/exercises/gigasecond/{.version → .meta/.version} +0 -0
  51. data/tracks/ruby/exercises/hamming/{.version → .meta/.version} +0 -0
  52. data/tracks/ruby/exercises/hello-world/{.version → .meta/.version} +0 -0
  53. data/tracks/ruby/exercises/isogram/{.version → .meta/.version} +0 -0
  54. data/tracks/ruby/exercises/largest-series-product/{.version → .meta/.version} +0 -0
  55. data/tracks/ruby/exercises/leap/{.version → .meta/.version} +0 -0
  56. data/tracks/ruby/exercises/nth-prime/{.version → .meta/.version} +0 -0
  57. data/tracks/ruby/exercises/pangram/{.version → .meta/.version} +0 -0
  58. data/tracks/ruby/exercises/queen-attack/{.version → .meta/.version} +0 -0
  59. data/tracks/ruby/exercises/raindrops/{.version → .meta/.version} +0 -0
  60. data/tracks/ruby/exercises/rna-transcription/{.version → .meta/.version} +0 -0
  61. data/tracks/ruby/exercises/roman-numerals/{.version → .meta/.version} +0 -0
  62. data/tracks/ruby/exercises/run-length-encoding/{.version → .meta/.version} +0 -0
  63. data/tracks/ruby/exercises/sieve/{.version → .meta/.version} +0 -0
  64. data/tracks/ruby/exercises/tournament/{.version → .meta/.version} +0 -0
  65. data/tracks/ruby/exercises/transpose/{.version → .meta/.version} +0 -0
  66. data/tracks/ruby/exercises/triangle/{.version → .meta/.version} +0 -0
  67. data/tracks/ruby/exercises/two-bucket/{.version → .meta/.version} +0 -0
  68. data/tracks/ruby/exercises/word-count/{.version → .meta/.version} +0 -0
  69. data/tracks/ruby/lib/generator.rb +15 -4
  70. data/tracks/rust/config.json +1 -0
  71. data/tracks/rust/exercises/largest-series-product/.gitignore +7 -0
  72. data/tracks/rust/exercises/largest-series-product/Cargo.toml +3 -0
  73. data/tracks/rust/exercises/largest-series-product/HINTS.md +6 -0
  74. data/tracks/rust/exercises/largest-series-product/example.rs +22 -0
  75. data/tracks/rust/exercises/largest-series-product/tests/largest-series-product.rs +105 -0
  76. data/tracks/rust/problems.md +1 -0
  77. data/tracks/scala/.gitignore +1 -0
  78. data/tracks/scala/exercises/accumulate/src/test/scala/{accumulate_test.scala → AccumulateTest.scala} +0 -0
  79. data/tracks/scala/exercises/allergies/src/test/scala/{allergies_test.scala → AllergiesTest.scala} +0 -0
  80. data/tracks/scala/exercises/anagram/src/test/scala/{anagram_test.scala → AnagramTest.scala} +0 -0
  81. data/tracks/scala/exercises/binary/src/test/scala/{binary_test.scala → BinaryTest.scala} +0 -0
  82. data/tracks/scala/exercises/bob/src/test/scala/{bob_test.scala → BobTest.scala} +0 -0
  83. data/tracks/scala/exercises/difference-of-squares/src/test/scala/{squares_test.scala → SquaresTest.scala} +0 -0
  84. data/tracks/scala/exercises/etl/src/test/scala/{etl_test.scala → EtlTest.scala} +0 -0
  85. data/tracks/scala/exercises/gigasecond/src/test/scala/{gigasecond_test.scala → GigasecondTest.scala} +0 -0
  86. data/tracks/scala/exercises/grade-school/src/test/scala/{grade_school_test.scala → GradeSchoolTest.scala} +0 -0
  87. data/tracks/scala/exercises/grains/src/test/scala/{grains_test.scala → GrainsTest.scala} +0 -0
  88. data/tracks/scala/exercises/hamming/src/test/scala/{hamming_test.scala → HammingTest.scala} +0 -0
  89. data/tracks/scala/exercises/hello-world/src/test/scala/HelloWorldTest.scala +2 -0
  90. data/tracks/scala/exercises/leap/src/test/scala/{leap_test.scala → LeapTest.scala} +0 -0
  91. data/tracks/scala/exercises/meetup/src/test/scala/{meetup_test.scala → MeetupTest.scala} +0 -0
  92. data/tracks/scala/exercises/nth-prime/example.scala +3 -1
  93. data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +11 -6
  94. data/tracks/scala/exercises/nucleotide-count/src/test/scala/{nucleotide_count_test.scala → NucleotideCountTest.scala} +0 -0
  95. data/tracks/scala/exercises/palindrome-products/src/test/scala/PalindromeProductsTest.scala +7 -0
  96. data/tracks/scala/exercises/pangram/src/test/scala/{PangramsTest.scala → PangramTest.scala} +0 -0
  97. data/tracks/scala/exercises/parallel-letter-frequency/HINTS.md +26 -0
  98. data/tracks/scala/exercises/phone-number/src/test/scala/{phone_number_test.scala → PhoneNumberTest.scala} +0 -0
  99. data/tracks/scala/exercises/prime-factors/src/test/scala/{primefactors_test.scala → PrimefactorsTest.scala} +10 -0
  100. data/tracks/scala/exercises/raindrops/src/test/scala/{raindrops_test.scala → RaindropsTest.scala} +15 -0
  101. data/tracks/scala/exercises/rna-transcription/src/test/scala/{transcription_test.scala → RnaTranscriptionTest.scala} +8 -0
  102. data/tracks/scala/exercises/robot-name/src/test/scala/{robot_name_test.scala → RobotNameTest.scala} +0 -0
  103. data/tracks/scala/exercises/roman-numerals/src/test/scala/{roman_numerals_test.scala → RomanNumeralsTest.scala} +17 -0
  104. data/tracks/scala/exercises/saddle-points/src/test/scala/{SaddlePointsSpecs.scala → SaddlePointsTest.scala} +3 -0
  105. data/tracks/scala/exercises/scrabble-score/src/test/scala/{scrabble_score_test.scala → ScrabbleScoreTest.scala} +0 -0
  106. data/tracks/scala/exercises/sgf-parsing/src/test/scala/SgfTest.scala +1 -0
  107. data/tracks/scala/exercises/space-age/src/test/scala/{space_age_test.scala → SpaceAgeTest.scala} +0 -0
  108. data/tracks/scala/exercises/sublist/src/test/scala/{sublist_test.scala → SublistTest.scala} +0 -0
  109. data/tracks/scala/exercises/triangle/src/test/scala/{triangle_test.scala → TriangleTest.scala} +7 -0
  110. data/tracks/scala/exercises/word-count/src/test/scala/{word_count_test.scala → WordCountTest.scala} +0 -0
  111. data/tracks/scala/exercises/zipper/src/test/scala/ZipperTest.scala +7 -0
  112. data/tracks/swift/config.json +19 -0
  113. data/tracks/swift/docs/TESTS.md +114 -23
  114. data/tracks/swift/exercises/beer-song/BeerSongExample.swift +32 -0
  115. data/tracks/swift/exercises/beer-song/BeerSongTest.swift +44 -0
  116. data/tracks/swift/exercises/hello-world/{helloWorldExample.swift → HelloWorldExample.swift} +4 -0
  117. data/tracks/swift/exercises/hello-world/{helloWorldTest/helloWorldTest.swift → helloWorldTest.swift} +1 -1
  118. data/tracks/swift/exercises/sublist/SubListTest.swift +95 -0
  119. data/tracks/swift/exercises/sublist/SublistExample.swift +72 -0
  120. data/tracks/swift/img/page_assets/001-splash.png +0 -0
  121. data/tracks/swift/img/page_assets/002-templateChooser.png +0 -0
  122. data/tracks/swift/img/page_assets/003-nameProject.jpg +0 -0
  123. data/tracks/swift/img/page_assets/004-saveProject.jpg +0 -0
  124. data/tracks/swift/img/page_assets/005-folderLayout.png +0 -0
  125. data/tracks/swift/img/page_assets/006-newProjectInitial.jpg +0 -0
  126. data/tracks/swift/img/page_assets/007-fileInspectorUpdate.png +0 -0
  127. data/tracks/swift/img/page_assets/008-templateChooserSwift.png +0 -0
  128. data/tracks/swift/img/page_assets/009-importTestSource.png +0 -0
  129. data/tracks/swift/img/page_assets/010-testsImportExample.png +0 -0
  130. data/tracks/swift/img/page_assets/011-finalLayoutExample.png +0 -0
  131. data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +36 -56
  132. metadata +103 -65
  133. data/tracks/swift/exercises/hello-world/helloWorld.swift +0 -1
  134. data/tracks/swift/exercises/hello-world/helloWorld.xcodeproj/project.pbxproj +0 -256
  135. data/tracks/swift/exercises/hello-world/helloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  136. data/tracks/swift/exercises/hello-world/helloWorldTest/Info.plist +0 -24
@@ -17,7 +17,7 @@ let parser_tests = [
17
17
  ae (single []) (parse_json_text "{\"cases\" : []}");
18
18
 
19
19
  "gives an error with a json map that does not have the key cases in" >::
20
- ae (Error UnrecognizedJson)
20
+ ae (Error (TestMustHaveKeyCalledCases "case"))
21
21
  (parse_json_text "{\"case\" : [{\"description\" : \"d1\", \"expected\" : 100}]}");
22
22
 
23
23
  "gives an error with cases that is not a json list" >::
@@ -61,15 +61,15 @@ let parser_tests = [
61
61
  (parse_json_text "{\"cases\" : [{\"description\" : \"d1\", \"input\" : [\"s1\", \"s2\"], \"expected\" : 85}]}");
62
62
 
63
63
  "an element without a description is an Error" >::
64
- ae (Error BadDescription)
64
+ ae (Error NoDescription)
65
65
  (parse_json_text "{\"cases\" : [{\"input\" : 11, \"expected\" : 85}]}");
66
66
 
67
67
  "an element with a description which is an int is an Error" >::
68
68
  ae (Error BadDescription)
69
69
  (parse_json_text "{\"cases\" : [{\"description\" : 1, \"input\" : 11, \"expected\" : 85}]}");
70
70
 
71
- "an element without expected is an Error" >::
72
- ae (Error BadDescription)
71
+ "an element without description is an Error" >::
72
+ ae (Error NoDescription)
73
73
  (parse_json_text "{\"cases\" : [{\"input\" : 11}]}");
74
74
 
75
75
  "parses a map in the expected parameter" >::(fun _ctx ->
@@ -97,4 +97,18 @@ let parser_tests = [
97
97
  | Ok (Single p) -> assert_failure "was single"
98
98
  | Error e -> assert_failure ("failed to parse difference_of_squares.json: " ^ show_error e)
99
99
  );
100
+
101
+ "parses clock.json" >::(fun ctxt ->
102
+ match parse_json_text @@ In_channel.read_all "test/clock.json" with
103
+ | Ok (Suite p) -> assert_equal ["create"; "add"; "equal"] (List.map ~f:(fun x -> x.name) p)
104
+ | Ok (Single p) -> assert_failure "was single"
105
+ | Error e -> assert_failure ("failed to parse clock.json: " ^ show_error e)
106
+ );
107
+
108
+ "parses json with a methods key for dynamic languages" >::(fun ctxt ->
109
+ match parse_json_text @@ In_channel.read_all "test/with-methods-key.json" with
110
+ | Ok (Suite p) -> assert_failure "was suite"
111
+ | Ok (Single p) -> ()
112
+ | Error e -> assert_failure ("failed to parse with-methods-key.json: " ^ show_error e)
113
+ );
100
114
  ]
@@ -0,0 +1,22 @@
1
+ {
2
+ "#": [
3
+ "Markdown is a shorthand for creating HTML from text strings."
4
+ ],
5
+ "methods": {
6
+ "description": [
7
+ "Check the public API is correct."
8
+ ],
9
+ "cases": [{
10
+ "description": "must be able to parse a Markdown string",
11
+ "method": "parse",
12
+ "arity": 1
13
+ }]
14
+ },
15
+ "cases": [
16
+ {
17
+ "description": "parses normal text as a paragraph",
18
+ "input": "This will be a paragraph",
19
+ "expected": "<p>This will be a paragraph</p>"
20
+ }
21
+ ]
22
+ }
@@ -76,6 +76,11 @@
76
76
  "slug": "binary",
77
77
  "topics": []
78
78
  },
79
+ {
80
+ "difficulty": 1,
81
+ "slug": "wordy",
82
+ "topics": []
83
+ },
79
84
  {
80
85
  "difficulty": 1,
81
86
  "slug": "trinary",
@@ -0,0 +1,16 @@
1
+ sub answer($q is copy) is export {
2
+
3
+ given $q {
4
+ s:s:g/^What is|\?$//;
5
+ s:g/plus/+/;
6
+ s:g/minus/-/;
7
+
8
+ loop {
9
+ last unless s:s/(.*) multiplied by/($0)*/
10
+ or s:s,(.*) divided by,($0)/,;
11
+ }
12
+ }
13
+
14
+ use MONKEY-SEE-NO-EVAL;
15
+ return EVAL $q;
16
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "#": [
3
+ "The tests that expect 'false' should be implemented to raise",
4
+ "an error, or indicate a failure. Implement this in a way that",
5
+ "makes sense for your language."
6
+ ],
7
+ "cases": [
8
+ {
9
+ "description": "addition",
10
+ "input": "What is 1 plus 1?",
11
+ "expected": 2
12
+ },
13
+ {
14
+ "description": "more addition",
15
+ "input": "What is 53 plus 2?",
16
+ "expected": 55
17
+ },
18
+ {
19
+ "description": "addition with negative numbers",
20
+ "input": "What is -1 plus -10?",
21
+ "expected": -11
22
+ },
23
+ {
24
+ "description": "large addition",
25
+ "input": "What is 123 plus 45678?",
26
+ "expected": 45801
27
+ },
28
+ {
29
+ "description": "subtraction",
30
+ "input": "What is 4 minus -12?",
31
+ "expected": 16
32
+ },
33
+ {
34
+ "description": "multiplication",
35
+ "input": "What is -3 multiplied by 25?",
36
+ "expected": -75
37
+ },
38
+ {
39
+ "description": "division",
40
+ "input": "What is 33 divided by -3?",
41
+ "expected": -11
42
+ },
43
+ {
44
+ "description": "multiple additions",
45
+ "input": "What is 1 plus 1 plus 1?",
46
+ "expected": 3
47
+ },
48
+ {
49
+ "description": "addition and subtraction",
50
+ "input": "What is 1 plus 5 minus -2?",
51
+ "expected": 8
52
+ },
53
+ {
54
+ "description": "multiple subtraction",
55
+ "input": "What is 20 minus 4 minus 13?",
56
+ "expected": 3
57
+ },
58
+ {
59
+ "description": "subtraction then addition",
60
+ "input": "What is 17 minus 6 plus 3?",
61
+ "expected": 14
62
+ },
63
+ {
64
+ "description": "multiple multiplication",
65
+ "input": "What is 2 multiplied by -2 multiplied by 3?",
66
+ "expected": -12
67
+ },
68
+ {
69
+ "description": "addition and multiplication",
70
+ "input": "What is -3 plus 7 multiplied by -2?",
71
+ "expected": -8
72
+ },
73
+ {
74
+ "description": "multiple division",
75
+ "input": "What is -12 divided by 2 divided by -3?",
76
+ "expected": 2
77
+ },
78
+ {
79
+ "description": "unknown operation",
80
+ "input": "What is 52 cubed?",
81
+ "expected": null
82
+ },
83
+ {
84
+ "description": "Non math question",
85
+ "input": "Who is the President of the United States?",
86
+ "expected": null
87
+ }
88
+ ]
89
+ }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env perl6
2
+
3
+ use Test;
4
+ use JSON::Tiny;
5
+
6
+ use lib ( my $dir = IO::Path.new($?FILE).parent ).path;
7
+
8
+ my $module_name = %*ENV<EXERCISM>.so ?? 'Example' !! 'Wordy';
9
+ my @potential_module = <p6 pm6 pm>.map: $module_name ~ '.' ~ *;
10
+
11
+ my $module = first { $dir.child($_).e }, |@potential_module
12
+ or die "No file '$module_name.p6' found\n";
13
+
14
+ require $module <&answer>;
15
+
16
+ plan 16;
17
+
18
+ my %cases = from-json $dir.child('cases.json').slurp;
19
+
20
+ for |%cases<cases> -> %case {
21
+ with %case<expected> {
22
+ is answer(%case<input>), |%case<expected description>
23
+ or diag 'input: ' ~ %case<input>;
24
+ }
25
+ without %case<expected> {
26
+ dies-ok { answer(%case<input>) }, %case<description>
27
+ or diag 'input: ' ~ %case<input>;
28
+ }
29
+ }
@@ -14,20 +14,31 @@ class Generator
14
14
  end
15
15
 
16
16
  def metadata_dir
17
- # rubocop:disable Metrics/LineLength
18
17
  File.expand_path(File.join('..', '..', '..', METADATA_REPOSITORY, 'exercises', name), __FILE__)
19
18
  end
20
19
 
20
+ def exercise_dir
21
+ File.expand_path(File.join('..', '..', 'exercises', name), __FILE__)
22
+ end
23
+
24
+ def exercise_meta_dir
25
+ File.join(exercise_dir,'.meta')
26
+ end
27
+
28
+ def version_filename
29
+ File.join(exercise_meta_dir,'.version')
30
+ end
31
+
21
32
  def data
22
33
  File.read(File.join(metadata_dir, 'canonical-data.json'))
23
34
  end
24
35
 
25
36
  def path_to(file)
26
- File.expand_path(File.join('..', '..', 'exercises', name, file), __FILE__)
37
+ File.join(exercise_dir,file)
27
38
  end
28
39
 
29
40
  def version
30
- @version ||= File.read(path_to('.version')).strip.to_i
41
+ @version ||= File.read(version_filename).strip.to_i
31
42
  end
32
43
 
33
44
  def sha1
@@ -70,7 +81,7 @@ class Generator
70
81
  end
71
82
 
72
83
  def increment_version
73
- File.open(path_to('.version'), 'w') do |f|
84
+ File.open(version_filename, 'w') do |f|
74
85
  f.write version + 1
75
86
  end
76
87
  end
@@ -17,6 +17,7 @@
17
17
  "scrabble-score",
18
18
  "pangram",
19
19
  "nucleotide-count",
20
+ "largest-series-product",
20
21
  "word-count",
21
22
  "atbash-cipher",
22
23
  "etl",
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,3 @@
1
+ [package]
2
+ name = "largest-series-product"
3
+ version = "0.0.0"
@@ -0,0 +1,6 @@
1
+ # Largest Series Product in Rust
2
+
3
+ These iterators may be useful, depending on your approach
4
+
5
+ - [Windows](https://doc.rust-lang.org/std/primitive.slice.html#method.windows)
6
+ - [Product](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.product)
@@ -0,0 +1,22 @@
1
+ pub fn lsp(string_digits: &str, span: usize) -> Result<u64, String> {
2
+ if span == 0 {
3
+ return Ok(1);
4
+ }
5
+
6
+ if string_digits.chars().any(|c| !c.is_digit(10)) {
7
+ return Err(String::from("All characters must be numbers"));
8
+ }
9
+
10
+ let products: Vec<u64> = string_digits.chars()
11
+ .map(|c| c.to_digit(10).unwrap() as u64)
12
+ .collect::<Vec<u64>>()
13
+ .windows(span)
14
+ .map(|w| w.into_iter().product())
15
+ .collect();
16
+
17
+ if let Some(&x) = products.iter().max() {
18
+ Ok(x)
19
+ } else {
20
+ Err(String::from("Span longer than string"))
21
+ }
22
+ }
@@ -0,0 +1,105 @@
1
+ extern crate largest_series_product;
2
+
3
+ use largest_series_product::*;
4
+
5
+ #[test]
6
+ fn return_is_a_result() {
7
+ assert!(lsp("29", 2).is_ok());
8
+ }
9
+
10
+ #[test]
11
+ #[ignore]
12
+ fn find_the_largest_product_when_span_equals_length() {
13
+ assert_eq!(18, lsp("29", 2).unwrap());
14
+ }
15
+
16
+ #[test]
17
+ #[ignore]
18
+ fn find_the_largest_product_of_two_with_numbers_in_order() {
19
+ assert_eq!(72, lsp("0123456789", 2).unwrap());
20
+ }
21
+
22
+ #[test]
23
+ #[ignore]
24
+ fn find_the_largest_product_of_two_with_numbers_not_in_order() {
25
+ assert_eq!(48, lsp("576802143", 2).unwrap());
26
+ }
27
+
28
+ #[test]
29
+ #[ignore]
30
+ fn find_the_largest_product_of_three_with_numbers_in_order() {
31
+ assert_eq!(504, lsp("0123456789", 3).unwrap());
32
+ }
33
+
34
+ #[test]
35
+ #[ignore]
36
+ fn find_the_largest_product_of_three_with_numbers_not_in_order() {
37
+ assert_eq!(270, lsp("1027839564", 3).unwrap());
38
+ }
39
+
40
+ #[test]
41
+ #[ignore]
42
+ fn find_the_largest_product_of_five_with_numbers_in_order() {
43
+ assert_eq!(15120, lsp("0123456789", 5).unwrap());
44
+ }
45
+
46
+ #[test]
47
+ #[ignore]
48
+ fn span_of_six_in_a_large_number() {
49
+ assert_eq!(23520,
50
+ lsp("73167176531330624919225119674426574742355349194934", 6).unwrap());
51
+ }
52
+
53
+ #[test]
54
+ #[ignore]
55
+ fn returns_zero_if_number_is_zeros() {
56
+ assert_eq!(0, lsp("0000", 2).unwrap());
57
+ }
58
+
59
+ #[test]
60
+ #[ignore]
61
+ fn returns_zero_if_all_products_are_zero() {
62
+ assert_eq!(0, lsp("99099", 3).unwrap());
63
+ }
64
+
65
+ #[test]
66
+ #[ignore]
67
+ fn a_span_is_longer_than_number_is_an_error() {
68
+ assert!(lsp("123", 4).is_err());
69
+ }
70
+
71
+ // There may be some confusion about whether this should be 1 or error.
72
+ // The reasoning for it being 1 is this:
73
+ // There is one 0-character string contained in the empty string.
74
+ // That's the empty string itself.
75
+ // The empty product is 1 (the identity for multiplication).
76
+ // Therefore LSP('', 0) is 1.
77
+ // It's NOT the case that LSP('', 0) takes max of an empty list.
78
+ // So there is no error.
79
+ // Compare against LSP('123', 4):
80
+ // There are zero 4-character strings in '123'.
81
+ // So LSP('123', 4) really DOES take the max of an empty list.
82
+ // So LSP('123', 4) errors and LSP('', 0) does NOT.
83
+ #[test]
84
+ #[ignore]
85
+ fn an_empty_string_and_no_span_returns_one() {
86
+ assert_eq!(1, lsp("", 0).unwrap());
87
+ }
88
+
89
+ #[test]
90
+ #[ignore]
91
+ fn a_non_empty_string_and_no_span_returns_one() {
92
+ assert_eq!(1, lsp("123", 0).unwrap());
93
+ }
94
+
95
+ #[test]
96
+ #[ignore]
97
+ fn empty_string_and_non_zero_span_is_an_error() {
98
+ assert!(lsp("", 1).is_err());
99
+ }
100
+
101
+ #[test]
102
+ #[ignore]
103
+ fn a_string_with_non_digits_is_an_error() {
104
+ assert!(lsp("1234a5", 2).is_err());
105
+ }