New Fetch

This commit is contained in:
2017-08-12 09:01:07 -05:00
parent ba838ca4fb
commit a9630f6ee8
58 changed files with 2530 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Sum Of Multiples
Given a number, find the sum of all the multiples of particular numbers up to
but not including that number.
If we list all the natural numbers up to but not including 20 that are
multiples of either 3 or 5, we get 3, 5, 6 and 9, 10, 12, 15, and 18.
The sum of these multiples is 78.
Given a number, find the sum of the multiples of a given set of numbers,
up to but not including that number.
## Hints
This exercise requires you to process a collection of data. You can simplify your code by using LINQ (Language Integrated Query).
For more information, see [this page](https://docs.microsoft.com/en-us/dotnet/articles/standard/using-linq).
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the exercise file that you're submitting is in the `exercism/csharp/<exerciseName>` directory.
For example, if you're submitting `bob.cs` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/csharp/bob/bob.cs`.
## Source
A variation on Problem 1 at Project Euler [http://projecteuler.net/problem=1](http://projecteuler.net/problem=1)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
public static class SumOfMultiples
{
public static int To(IEnumerable<int> multiples, int max)
{
throw new NotImplementedException("You need to implement this function.");
}
}

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Example.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,46 @@
using Xunit;
public class SumOfMultiplesTest
{
[Fact]
public void Sum_to_1()
{
Assert.Equal(0, SumOfMultiples.To(new[] { 3, 5 }, 1));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_3()
{
Assert.Equal(3, SumOfMultiples.To(new[] { 3, 5 }, 4));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_10()
{
Assert.Equal(23, SumOfMultiples.To(new[] { 3, 5 }, 10));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_100()
{
Assert.Equal(2318, SumOfMultiples.To(new[] { 3, 5 }, 100));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_1000()
{
Assert.Equal(233168, SumOfMultiples.To(new[] { 3, 5 }, 1000));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_20()
{
Assert.Equal(51, SumOfMultiples.To(new [] { 7, 13, 17 }, 20));
}
[Fact(Skip = "Remove to run test")]
public void Sum_to_10000()
{
Assert.Equal(2203160, SumOfMultiples.To(new [] { 43, 47 }, 10000));
}
}