trackler 2.2.1.80 → 2.2.1.81
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/bob/canonical-data.json +76 -26
- data/problem-specifications/exercises/isbn-verifier/canonical-data.json +9 -1
- data/problem-specifications/exercises/luhn/canonical-data.json +40 -14
- data/tracks/bash/CONTRIBUTING.md +3 -3
- data/tracks/bash/exercises/error-handling/README.md +15 -0
- data/tracks/bash/exercises/hello-world/{HINTS.md → .meta/hints.md} +1 -1
- data/tracks/csharp/config.json +24 -0
- data/tracks/csharp/exercises/binary/Binary.cs +9 -0
- data/tracks/csharp/exercises/binary/Binary.csproj +17 -0
- data/tracks/csharp/exercises/binary/BinaryTest.cs +94 -0
- data/tracks/csharp/exercises/binary/Example.cs +24 -0
- data/tracks/csharp/exercises/binary/README.md +41 -0
- data/tracks/csharp/exercises/hexadecimal/Example.cs +41 -0
- data/tracks/csharp/exercises/hexadecimal/Hexadecimal.cs +9 -0
- data/tracks/csharp/exercises/hexadecimal/Hexadecimal.csproj +17 -0
- data/tracks/csharp/exercises/hexadecimal/HexadecimalTest.cs +65 -0
- data/tracks/csharp/exercises/hexadecimal/README.md +20 -0
- data/tracks/csharp/exercises/octal/Example.cs +24 -0
- data/tracks/csharp/exercises/octal/Octal.cs +9 -0
- data/tracks/csharp/exercises/octal/Octal.csproj +17 -0
- data/tracks/csharp/exercises/octal/OctalTest.cs +88 -0
- data/tracks/csharp/exercises/octal/README.md +55 -0
- data/tracks/csharp/exercises/trinary/Example.cs +24 -0
- data/tracks/csharp/exercises/trinary/README.md +34 -0
- data/tracks/csharp/exercises/trinary/Trinary.cs +9 -0
- data/tracks/csharp/exercises/trinary/Trinary.csproj +17 -0
- data/tracks/csharp/exercises/trinary/TrinaryTest.cs +70 -0
- data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +12 -0
- data/tracks/fsharp/config.json +21 -1
- data/tracks/fsharp/exercises/binary/Binary.fs +3 -0
- data/tracks/fsharp/exercises/binary/Binary.fsproj +23 -0
- data/tracks/fsharp/exercises/binary/BinaryTest.fs +67 -0
- data/tracks/fsharp/exercises/binary/Example.fs +13 -0
- data/tracks/fsharp/exercises/binary/Program.fs +1 -0
- data/tracks/fsharp/exercises/binary/README.md +35 -0
- data/tracks/fsharp/exercises/hexadecimal/Example.fs +14 -0
- data/tracks/fsharp/exercises/hexadecimal/Hexadecimal.fs +3 -0
- data/tracks/fsharp/exercises/hexadecimal/Hexadecimal.fsproj +23 -0
- data/tracks/fsharp/exercises/hexadecimal/HexadecimalTest.fs +47 -0
- data/tracks/fsharp/exercises/hexadecimal/Program.fs +1 -0
- data/tracks/fsharp/exercises/hexadecimal/README.md +14 -0
- data/tracks/fsharp/exercises/octal/Example.fs +10 -0
- data/tracks/fsharp/exercises/octal/Octal.fs +3 -0
- data/tracks/fsharp/exercises/octal/Octal.fsproj +23 -0
- data/tracks/fsharp/exercises/octal/OctalTest.fs +59 -0
- data/tracks/fsharp/exercises/octal/Program.fs +1 -0
- data/tracks/fsharp/exercises/octal/README.md +49 -0
- data/tracks/fsharp/exercises/transpose/TrinaryTest.fs +24 -0
- data/tracks/fsharp/exercises/trinary/Example.fs +13 -0
- data/tracks/fsharp/exercises/trinary/Program.fs +1 -0
- data/tracks/fsharp/exercises/trinary/README.md +28 -0
- data/tracks/fsharp/exercises/trinary/Trinary.fs +3 -0
- data/tracks/fsharp/exercises/trinary/Trinary.fsproj +23 -0
- data/tracks/fsharp/exercises/trinary/TrinaryTest.fs +51 -0
- data/tracks/lua/config.json +6 -1
- data/tracks/lua/exercises/accumulate/accumulate_spec.lua +27 -0
- data/tracks/lua/exercises/accumulate/example.lua +7 -0
- data/tracks/python/config.json +10 -0
- data/tracks/python/exercises/reverse-string/README.md +9 -0
- data/tracks/python/exercises/reverse-string/example.py +2 -0
- data/tracks/python/exercises/reverse-string/reverse_string.py +2 -0
- data/tracks/python/exercises/reverse-string/reverse_string_test.py +26 -0
- metadata +55 -3
@@ -0,0 +1,23 @@
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
|
+
|
3
|
+
<PropertyGroup>
|
4
|
+
<TargetFramework>netcoreapp2.0</TargetFramework>
|
5
|
+
|
6
|
+
<IsPackable>false</IsPackable>
|
7
|
+
</PropertyGroup>
|
8
|
+
|
9
|
+
<ItemGroup>
|
10
|
+
<Compile Include="Hexadecimal.fs" />
|
11
|
+
<Compile Include="HexadecimalTest.fs" />
|
12
|
+
<Compile Include="Program.fs" />
|
13
|
+
</ItemGroup>
|
14
|
+
|
15
|
+
<ItemGroup>
|
16
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
17
|
+
<PackageReference Include="xunit" Version="2.3.1" />
|
18
|
+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
19
|
+
<PackageReference Include="FsUnit.xUnit" Version="3.0.0" />
|
20
|
+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
21
|
+
</ItemGroup>
|
22
|
+
|
23
|
+
</Project>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module HexadecimalTest
|
2
|
+
|
3
|
+
open FsUnit.Xunit
|
4
|
+
open Xunit
|
5
|
+
|
6
|
+
open Hexadecimal
|
7
|
+
|
8
|
+
[<Fact>]
|
9
|
+
let ``Hexadecimal 1 is decimal 1`` () =
|
10
|
+
toDecimal "1" |> should equal 1
|
11
|
+
|
12
|
+
[<Fact(Skip = "Remove to run test")>]
|
13
|
+
let ``Hexadecimal c is decimal 12`` () =
|
14
|
+
toDecimal "c" |> should equal 12
|
15
|
+
|
16
|
+
[<Fact(Skip = "Remove to run test")>]
|
17
|
+
let ``Hexadecimal 10 is decimal 16`` () =
|
18
|
+
toDecimal "10" |> should equal 16
|
19
|
+
|
20
|
+
[<Fact(Skip = "Remove to run test")>]
|
21
|
+
let ``Hexadecimal af is decimal 175`` () =
|
22
|
+
toDecimal "af" |> should equal 175
|
23
|
+
|
24
|
+
[<Fact(Skip = "Remove to run test")>]
|
25
|
+
let ``Hexadecimal 100 is decimal 256`` () =
|
26
|
+
toDecimal "100" |> should equal 256
|
27
|
+
|
28
|
+
[<Fact(Skip = "Remove to run test")>]
|
29
|
+
let ``Hexadecimal 19ace is decimal 105166`` () =
|
30
|
+
toDecimal "19ace" |> should equal 105166
|
31
|
+
|
32
|
+
[<Fact(Skip = "Remove to run test")>]
|
33
|
+
let ``Hexadecimal 000000 is decimal 0`` () =
|
34
|
+
toDecimal "000000" |> should equal 0
|
35
|
+
|
36
|
+
[<Fact(Skip = "Remove to run test")>]
|
37
|
+
let ``Hexadecimal ffffff is decimal 16777215`` () =
|
38
|
+
toDecimal "ffffff" |> should equal 16777215
|
39
|
+
|
40
|
+
[<Fact(Skip = "Remove to run test")>]
|
41
|
+
let ``Hexadecimal ffff00 is decimal 16776960`` () =
|
42
|
+
toDecimal "ffff00" |> should equal 16776960
|
43
|
+
|
44
|
+
[<Fact(Skip = "Remove to run test")>]
|
45
|
+
let ``Hexadecimal carrot is decimal 0`` () =
|
46
|
+
toDecimal "carrot" |> should equal 0
|
47
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
module Program = let [<EntryPoint>] main _ = 0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Hexadecimal
|
2
|
+
|
3
|
+
Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion).
|
4
|
+
|
5
|
+
On the web we use hexadecimal to represent colors, e.g. green: 008000,
|
6
|
+
teal: 008080, navy: 000080).
|
7
|
+
|
8
|
+
The program should handle invalid hexadecimal strings.
|
9
|
+
## Source
|
10
|
+
|
11
|
+
All of Computer Science [http://www.wolframalpha.com/examples/NumberBases.html](http://www.wolframalpha.com/examples/NumberBases.html)
|
12
|
+
|
13
|
+
## Submitting Incomplete Solutions
|
14
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Octal
|
2
|
+
|
3
|
+
let isValid char = char >= '0' && char <= '7'
|
4
|
+
|
5
|
+
let charToDecimal char = (int)char - (int)'0'
|
6
|
+
|
7
|
+
let toDecimal (input: string) =
|
8
|
+
let chars = input.ToCharArray()
|
9
|
+
if Array.forall isValid chars then Array.fold (fun acc c -> acc * 8 + charToDecimal c) 0 chars
|
10
|
+
else 0
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
|
+
|
3
|
+
<PropertyGroup>
|
4
|
+
<TargetFramework>netcoreapp2.0</TargetFramework>
|
5
|
+
|
6
|
+
<IsPackable>false</IsPackable>
|
7
|
+
</PropertyGroup>
|
8
|
+
|
9
|
+
<ItemGroup>
|
10
|
+
<Compile Include="Octal.fs" />
|
11
|
+
<Compile Include="OctalTest.fs" />
|
12
|
+
<Compile Include="Program.fs" />
|
13
|
+
</ItemGroup>
|
14
|
+
|
15
|
+
<ItemGroup>
|
16
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
17
|
+
<PackageReference Include="xunit" Version="2.3.1" />
|
18
|
+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
19
|
+
<PackageReference Include="FsUnit.xUnit" Version="3.0.0" />
|
20
|
+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
21
|
+
</ItemGroup>
|
22
|
+
|
23
|
+
</Project>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module OctalTest
|
2
|
+
|
3
|
+
open FsUnit.Xunit
|
4
|
+
open Xunit
|
5
|
+
|
6
|
+
open Octal
|
7
|
+
|
8
|
+
[<Fact(Skip = "Remove to run test")>]
|
9
|
+
let ``Octal 1 is decimal 1`` () =
|
10
|
+
toDecimal "1" |> should equal 1
|
11
|
+
|
12
|
+
[<Fact(Skip = "Remove to run test")>]
|
13
|
+
let ``Octal 10 is decimal 8`` () =
|
14
|
+
toDecimal "10" |> should equal 8
|
15
|
+
|
16
|
+
[<Fact(Skip = "Remove to run test")>]
|
17
|
+
let ``Octal 17 is decimal 15`` () =
|
18
|
+
toDecimal "17" |> should equal 15
|
19
|
+
|
20
|
+
[<Fact(Skip = "Remove to run test")>]
|
21
|
+
let ``Octal 11 is decimal 9`` () =
|
22
|
+
toDecimal "11" |> should equal 9
|
23
|
+
|
24
|
+
[<Fact(Skip = "Remove to run test")>]
|
25
|
+
let ``Octal 130 is decimal 88`` () =
|
26
|
+
toDecimal "130" |> should equal 88
|
27
|
+
|
28
|
+
[<Fact(Skip = "Remove to run test")>]
|
29
|
+
let ``Octal 2047 is decimal 1063`` () =
|
30
|
+
toDecimal "2047" |> should equal 1063
|
31
|
+
|
32
|
+
[<Fact(Skip = "Remove to run test")>]
|
33
|
+
let ``Octal 7777 is decimal 4095`` () =
|
34
|
+
toDecimal "7777" |> should equal 4095
|
35
|
+
|
36
|
+
[<Fact(Skip = "Remove to run test")>]
|
37
|
+
let ``Octal 1234567 is decimal 342391`` () =
|
38
|
+
toDecimal "1234567" |> should equal 342391
|
39
|
+
|
40
|
+
[<Fact(Skip = "Remove to run test")>]
|
41
|
+
let ``Invalid Octal carrot is decimal 0`` () =
|
42
|
+
toDecimal "carrot" |> should equal 0
|
43
|
+
|
44
|
+
[<Fact(Skip = "Remove to run test")>]
|
45
|
+
let ``Invalid Octal 8 is decimal 0`` () =
|
46
|
+
toDecimal "8" |> should equal 0
|
47
|
+
|
48
|
+
[<Fact(Skip = "Remove to run test")>]
|
49
|
+
let ``Invalid Octal 9 is decimal 0`` () =
|
50
|
+
toDecimal "9" |> should equal 0
|
51
|
+
|
52
|
+
[<Fact(Skip = "Remove to run test")>]
|
53
|
+
let ``Invalid Octal 6789 is decimal 0`` () =
|
54
|
+
toDecimal "6789" |> should equal 0
|
55
|
+
|
56
|
+
[<Fact(Skip = "Remove to run test")>]
|
57
|
+
let ``Invalid Octal abc1z is decimal 0`` () =
|
58
|
+
toDecimal "abc1z" |> should equal 0
|
59
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
module Program = let [<EntryPoint>] main _ = 0
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Octal
|
2
|
+
|
3
|
+
Convert an octal number, represented as a string (e.g. '1735263'), to its
|
4
|
+
decimal equivalent using first principles (i.e. no, you may not use built-in or
|
5
|
+
external libraries to accomplish the conversion).
|
6
|
+
|
7
|
+
Implement octal to decimal conversion. Given an octal input
|
8
|
+
string, your program should produce a decimal output.
|
9
|
+
|
10
|
+
## Note
|
11
|
+
- Implement the conversion yourself.
|
12
|
+
Do not use something else to perform the conversion for you.
|
13
|
+
- Treat invalid input as octal 0.
|
14
|
+
|
15
|
+
## About Octal (Base-8)
|
16
|
+
Decimal is a base-10 system.
|
17
|
+
|
18
|
+
A number 233 in base 10 notation can be understood
|
19
|
+
as a linear combination of powers of 10:
|
20
|
+
|
21
|
+
- The rightmost digit gets multiplied by 10^0 = 1
|
22
|
+
- The next number gets multiplied by 10^1 = 10
|
23
|
+
- ...
|
24
|
+
- The *n*th number gets multiplied by 10^*(n-1)*.
|
25
|
+
- All these values are summed.
|
26
|
+
|
27
|
+
So:
|
28
|
+
```
|
29
|
+
233 # decimal
|
30
|
+
= 2*10^2 + 3*10^1 + 3*10^0
|
31
|
+
= 2*100 + 3*10 + 3*1
|
32
|
+
```
|
33
|
+
|
34
|
+
Octal is similar, but uses powers of 8 rather than powers of 10.
|
35
|
+
|
36
|
+
So:
|
37
|
+
```
|
38
|
+
233 # octal
|
39
|
+
= 2*8^2 + 3*8^1 + 3*8^0
|
40
|
+
= 2*64 + 3*8 + 3*1
|
41
|
+
= 128 + 24 + 3
|
42
|
+
= 155
|
43
|
+
```
|
44
|
+
## Source
|
45
|
+
|
46
|
+
All of Computer Science [http://www.wolframalpha.com/input/?i=base+8](http://www.wolframalpha.com/input/?i=base+8)
|
47
|
+
|
48
|
+
## Submitting Incomplete Solutions
|
49
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module TrinaryTest
|
2
|
+
|
3
|
+
open NUnit.Framework
|
4
|
+
open Trinary
|
5
|
+
|
6
|
+
[<TestCase("1", ExpectedResult = 1)>]
|
7
|
+
[<TestCase("2", ExpectedResult = 2, Ignore = "Remove to run test case")>]
|
8
|
+
[<TestCase("10", ExpectedResult = 3, Ignore = "Remove to run test case")>]
|
9
|
+
[<TestCase("11", ExpectedResult = 4, Ignore = "Remove to run test case")>]
|
10
|
+
[<TestCase("100", ExpectedResult = 9, Ignore = "Remove to run test case")>]
|
11
|
+
[<TestCase("112", ExpectedResult = 14, Ignore = "Remove to run test case")>]
|
12
|
+
[<TestCase("222", ExpectedResult = 26, Ignore = "Remove to run test case")>]
|
13
|
+
[<TestCase("1122000120", ExpectedResult = 32091, Ignore = "Remove to run test case")>]
|
14
|
+
let ``Binary converts to decimal`` input =
|
15
|
+
toDecimal input
|
16
|
+
|
17
|
+
[<TestCase("carrot", Ignore = "Remove to run test case")>]
|
18
|
+
[<TestCase("3", Ignore = "Remove to run test case")>]
|
19
|
+
[<TestCase("6", Ignore = "Remove to run test case")>]
|
20
|
+
[<TestCase("9", Ignore = "Remove to run test case")>]
|
21
|
+
[<TestCase("124578", Ignore = "Remove to run test case")>]
|
22
|
+
[<TestCase("abc1z", Ignore = "Remove to run test case")>]
|
23
|
+
let ``Invalid binary is decimal 0`` input =
|
24
|
+
Assert.That(toDecimal input, Is.EqualTo(0))
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Trinary
|
2
|
+
|
3
|
+
let isValid char =
|
4
|
+
match char with
|
5
|
+
| '0' | '1' | '2' -> true
|
6
|
+
| _ -> false
|
7
|
+
|
8
|
+
let charToDecimal char = (int)char - (int)'0'
|
9
|
+
|
10
|
+
let toDecimal(input: string) =
|
11
|
+
let chars = input.ToCharArray()
|
12
|
+
if Array.forall isValid chars then Array.fold (fun acc c -> acc * 3 + charToDecimal c) 0 chars
|
13
|
+
else 0
|
@@ -0,0 +1 @@
|
|
1
|
+
module Program = let [<EntryPoint>] main _ = 0
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Trinary
|
2
|
+
|
3
|
+
Convert a trinary number, represented as a string (e.g. '102012'), to its
|
4
|
+
decimal equivalent using first principles.
|
5
|
+
|
6
|
+
The program should consider strings specifying an invalid trinary as the
|
7
|
+
value 0.
|
8
|
+
|
9
|
+
Trinary numbers contain three symbols: 0, 1, and 2.
|
10
|
+
|
11
|
+
The last place in a trinary number is the 1's place. The second to last
|
12
|
+
is the 3's place, the third to last is the 9's place, etc.
|
13
|
+
|
14
|
+
```bash
|
15
|
+
# "102012"
|
16
|
+
1 0 2 0 1 2 # the number
|
17
|
+
1*3^5 + 0*3^4 + 2*3^3 + 0*3^2 + 1*3^1 + 2*3^0 # the value
|
18
|
+
243 + 0 + 54 + 0 + 3 + 2 = 302
|
19
|
+
```
|
20
|
+
|
21
|
+
If your language provides a method in the standard library to perform the
|
22
|
+
conversion, pretend it doesn't exist and implement it yourself.
|
23
|
+
## Source
|
24
|
+
|
25
|
+
All of Computer Science [http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-](http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-)
|
26
|
+
|
27
|
+
## Submitting Incomplete Solutions
|
28
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2
|
+
|
3
|
+
<PropertyGroup>
|
4
|
+
<TargetFramework>netcoreapp2.0</TargetFramework>
|
5
|
+
|
6
|
+
<IsPackable>false</IsPackable>
|
7
|
+
</PropertyGroup>
|
8
|
+
|
9
|
+
<ItemGroup>
|
10
|
+
<Compile Include="Trinary.fs" />
|
11
|
+
<Compile Include="TrinaryTest.fs" />
|
12
|
+
<Compile Include="Program.fs" />
|
13
|
+
</ItemGroup>
|
14
|
+
|
15
|
+
<ItemGroup>
|
16
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
17
|
+
<PackageReference Include="xunit" Version="2.3.1" />
|
18
|
+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
19
|
+
<PackageReference Include="FsUnit.xUnit" Version="3.0.0" />
|
20
|
+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
21
|
+
</ItemGroup>
|
22
|
+
|
23
|
+
</Project>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module TrinaryTest
|
2
|
+
|
3
|
+
open FsUnit.Xunit
|
4
|
+
open Xunit
|
5
|
+
|
6
|
+
open Trinary
|
7
|
+
|
8
|
+
[<Fact>]
|
9
|
+
let ``Trinary_1_is_decimal_1`` () =
|
10
|
+
toDecimal "1" |> should equal 1
|
11
|
+
|
12
|
+
[<Fact(Skip = "Remove to run test")>]
|
13
|
+
let ``Trinary_2_is_decimal_2`` () =
|
14
|
+
toDecimal "2" |> should equal 2
|
15
|
+
|
16
|
+
[<Fact(Skip = "Remove to run test")>]
|
17
|
+
let ``Trinary_10_is_decimal_3`` () =
|
18
|
+
toDecimal "10" |> should equal 3
|
19
|
+
|
20
|
+
[<Fact(Skip = "Remove to run test")>]
|
21
|
+
let ``Trinary_11_is_decimal_4`` () =
|
22
|
+
toDecimal "11" |> should equal 4
|
23
|
+
|
24
|
+
[<Fact(Skip = "Remove to run test")>]
|
25
|
+
let ``Trinary_100_is_decimal_9`` () =
|
26
|
+
toDecimal "100" |> should equal 9
|
27
|
+
|
28
|
+
[<Fact(Skip = "Remove to run test")>]
|
29
|
+
let ``Trinary_112_is_decimal_14`` () =
|
30
|
+
toDecimal "112" |> should equal 14
|
31
|
+
|
32
|
+
[<Fact(Skip = "Remove to run test")>]
|
33
|
+
let ``Trinary_222_is_decimal_26`` () =
|
34
|
+
toDecimal "222" |> should equal 26
|
35
|
+
|
36
|
+
[<Fact(Skip = "Remove to run test")>]
|
37
|
+
let ``Trinary_1122000120_is_decimal_32091`` () =
|
38
|
+
toDecimal "1122000120" |> should equal 32091
|
39
|
+
|
40
|
+
[<Fact(Skip = "Remove to run test")>]
|
41
|
+
let ``Invalid_trinary_digits_returns_0`` () =
|
42
|
+
toDecimal "1234" |> should equal 0
|
43
|
+
|
44
|
+
[<Fact(Skip = "Remove to run test")>]
|
45
|
+
let ``Invalid_word_as_input_returns_0`` () =
|
46
|
+
toDecimal "carrot" |> should equal 0
|
47
|
+
|
48
|
+
[<Fact(Skip = "Remove to run test")>]
|
49
|
+
let ``Invalid_numbers_with_letters_as_input_returns_0`` () =
|
50
|
+
toDecimal "0a1b2c" |> should equal 0
|
51
|
+
|
data/tracks/lua/config.json
CHANGED
@@ -954,9 +954,14 @@
|
|
954
954
|
],
|
955
955
|
"unlocked_by": "run-length-encoding",
|
956
956
|
"uuid": "a9a6a2c7-2a58-4090-b538-5a275c521fe0"
|
957
|
+
},
|
958
|
+
{
|
959
|
+
"deprecated": true,
|
960
|
+
"slug": "accumulate",
|
961
|
+
"uuid": "70bc1661-9132-43af-bb44-b51e7d81676b"
|
957
962
|
}
|
958
963
|
],
|
959
964
|
"foregone": [],
|
960
965
|
"language": "Lua",
|
961
966
|
"test_pattern": ".*spec[.]lua$"
|
962
|
-
}
|
967
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
local accumulate = require('accumulate')
|
2
|
+
|
3
|
+
describe('accumulate', function()
|
4
|
+
local function square(x) return x * x end
|
5
|
+
|
6
|
+
it('should accumulate over an empty array', function()
|
7
|
+
assert.are.same({}, accumulate({}, square))
|
8
|
+
end)
|
9
|
+
|
10
|
+
it('should accumulate over an array with a single element', function()
|
11
|
+
assert.are.same({ 4 }, accumulate({ 2 }, square))
|
12
|
+
end)
|
13
|
+
|
14
|
+
it('should accumulate over an array with several elements', function()
|
15
|
+
assert.are.same({ 1, 4, 9 }, accumulate({ 1, 2, 3 }, square))
|
16
|
+
end)
|
17
|
+
|
18
|
+
it('should accumulate over an array with a different function', function()
|
19
|
+
assert.are.same({ 'HELLO', 'WORLD' }, accumulate({ 'hello', 'world' }, string.upper))
|
20
|
+
end)
|
21
|
+
|
22
|
+
it('should not modify the input array', function()
|
23
|
+
local input = { 1, 2, 3 }
|
24
|
+
accumulate(input, square)
|
25
|
+
assert.are.same({ 1, 2, 3 }, input)
|
26
|
+
end)
|
27
|
+
end)
|