-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a02324
commit 10906a9
Showing
11 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"fantomas-tool": { | ||
"version": "4.7.9", | ||
"commands": [ | ||
"fantomas" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Instructions | ||
|
||
Given a natural radicand, return its square root. | ||
|
||
Note that the term "radicand" refers to the number for which the root is to be determined. | ||
That is, it is the number under the root symbol. | ||
|
||
Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots]. | ||
|
||
Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up). | ||
|
||
[square-root]: https://en.wikipedia.org/wiki/Square_root | ||
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module SquareRoot | ||
|
||
let squareRoot n = | ||
let rec loop i = if i * i <= n then loop (i + 1) else i - 1 | ||
loop 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"authors": [ | ||
"erikschierboom" | ||
], | ||
"files": { | ||
"solution": [ | ||
"SquareRoot.fs" | ||
], | ||
"test": [ | ||
"SquareRootTests.fs" | ||
], | ||
"example": [ | ||
".meta/Example.fs" | ||
] | ||
}, | ||
"blurb": "Given a natural radicand, return its square root.", | ||
"source": "wolf99", | ||
"source_url": "https://github.com/exercism/problem-specifications/pull/1582" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[9b748478-7b0a-490c-b87a-609dacf631fd] | ||
description = "root of 1" | ||
|
||
[7d3aa9ba-9ac6-4e93-a18b-2e8b477139bb] | ||
description = "root of 4" | ||
|
||
[6624aabf-3659-4ae0-a1c8-25ae7f33c6ef] | ||
description = "root of 25" | ||
|
||
[93beac69-265e-4429-abb1-94506b431f81] | ||
description = "root of 81" | ||
|
||
[fbddfeda-8c4f-4bc4-87ca-6991af35360e] | ||
description = "root of 196" | ||
|
||
[c03d0532-8368-4734-a8e0-f96a9eb7fc1d] | ||
description = "root of 65025" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module SquareRoot | ||
|
||
let squareRoot n = | ||
failwith "Please implement the 'squareRoot' function" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="SquareRoot.fs" /> | ||
<Compile Include="SquareRootTests.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Exercism.Tests" Version="0.1.0-beta1" /> | ||
<PackageReference Include="FsUnit.xUnit" Version="4.0.4" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module SquareRootTests | ||
|
||
open FsUnit.Xunit | ||
open Xunit | ||
|
||
open SquareRoot | ||
|
||
[<Fact>] | ||
let ``Root of 1`` () = | ||
squareRoot 1 |> should equal 1 | ||
|
||
[<Fact(Skip = "Remove this Skip property to run this test")>] | ||
let ``Root of 4`` () = | ||
squareRoot 4 |> should equal 2 | ||
|
||
[<Fact(Skip = "Remove this Skip property to run this test")>] | ||
let ``Root of 25`` () = | ||
squareRoot 25 |> should equal 5 | ||
|
||
[<Fact(Skip = "Remove this Skip property to run this test")>] | ||
let ``Root of 81`` () = | ||
squareRoot 81 |> should equal 9 | ||
|
||
[<Fact(Skip = "Remove this Skip property to run this test")>] | ||
let ``Root of 196`` () = | ||
squareRoot 196 |> should equal 14 | ||
|
||
[<Fact(Skip = "Remove this Skip property to run this test")>] | ||
let ``Root of 65025`` () = | ||
squareRoot 65025 |> should equal 255 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters