|
1 | 1 | import "largest_series_product"
|
2 | 2 |
|
3 |
| --- Finds the largest product if span equals length |
| 3 | +-- finds the largest product if span equals length |
4 | 4 | -- ==
|
5 | 5 | -- input { "29" 2 }
|
6 | 6 | -- output { 18 }
|
7 | 7 |
|
8 |
| --- Can find the largest product of 2 with numbers in order |
| 8 | +-- can find the largest product of 2 with numbers in order |
9 | 9 | -- ==
|
10 | 10 | -- input { "0123456789" 2 }
|
11 | 11 | -- output { 72 }
|
12 | 12 |
|
13 |
| --- Can find the largest product of 2 |
| 13 | +-- can find the largest product of 2 |
14 | 14 | -- ==
|
15 | 15 | -- input { "576802143" 2 }
|
16 | 16 | -- output { 48 }
|
17 | 17 |
|
18 |
| --- Can find the largest product of 3 with numbers in order |
| 18 | +-- can find the largest product of 3 with numbers in order |
19 | 19 | -- ==
|
20 | 20 | -- input { "0123456789" 3 }
|
21 | 21 | -- output { 504 }
|
22 | 22 |
|
23 |
| --- Can find the largest product of 3 |
| 23 | +-- can find the largest product of 3 |
24 | 24 | -- ==
|
25 | 25 | -- input { "1027839564" 3 }
|
26 | 26 | -- output { 270 }
|
27 | 27 |
|
28 |
| --- Can find the largest product of 5 with numbers in order |
| 28 | +-- can find the largest product of 5 with numbers in order |
29 | 29 | -- ==
|
30 | 30 | -- input { "0123456789" 5 }
|
31 | 31 | -- output { 15120 }
|
32 | 32 |
|
33 |
| --- Can get the largest product of a big number |
| 33 | +-- can get the largest product of a big number |
34 | 34 | -- ==
|
35 | 35 | -- input { "73167176531330624919225119674426574742355349194934" 6 }
|
36 | 36 | -- output { 23520 }
|
37 | 37 |
|
38 |
| --- Reports zero if the only digits are zero |
| 38 | +-- reports zero if the only digits are zero |
39 | 39 | -- ==
|
40 | 40 | -- input { "0000" 2 }
|
41 | 41 | -- output { 0 }
|
42 | 42 |
|
43 |
| --- Reports zero if all spans include zero |
| 43 | +-- reports zero if all spans include zero |
44 | 44 | -- ==
|
45 | 45 | -- input { "99099" 3 }
|
46 | 46 | -- output { 0 }
|
47 | 47 |
|
48 |
| --- Rejects span longer than string length |
| 48 | +-- rejects span longer than string length |
49 | 49 | -- ==
|
50 | 50 | -- input { "123" 4 }
|
51 | 51 | -- error: Error*
|
52 | 52 |
|
53 |
| --- Rejects empty string and nonzero span |
| 53 | +-- reports 1 for empty string and empty product (0 span) |
| 54 | +-- == |
| 55 | +-- input { "" 0 } |
| 56 | +-- output { 1 } |
| 57 | + |
| 58 | +-- reports 1 for nonempty string and empty product (0 span) |
| 59 | +-- == |
| 60 | +-- input { "123" 0 } |
| 61 | +-- output { 1 } |
| 62 | + |
| 63 | +-- rejects empty string and nonzero span |
54 | 64 | -- ==
|
55 | 65 | -- input { "" 1 }
|
56 | 66 | -- error: Error*
|
57 | 67 |
|
58 |
| --- Rejects invalid character in digits |
| 68 | +-- rejects invalid character in digits |
59 | 69 | -- ==
|
60 | 70 | -- input { "1234a5" 2 }
|
61 | 71 | -- error: Error*
|
62 | 72 |
|
63 |
| --- Rejects negative span |
| 73 | +-- rejects negative span |
64 | 74 | -- ==
|
65 | 75 | -- input { "12345" -1 }
|
66 | 76 | -- error: Error*
|
|
0 commit comments