Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Katas.Session.01/Katas.Session.01.Test/MultipleKataTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -20,7 +20,7 @@
[TestCase(13,45)]
public void SumMultiplesBelow(int input, int expected)
{
Assert.AreEqual(expected, MultipleKata.SumMultiplesBelow(input), $"Value: {input}");

Check warning on line 23 in Katas.Session.01/Katas.Session.01.Test/MultipleKataTest.cs

View workflow job for this annotation

GitHub Actions / unit-tests

Consider using the constraint model, Assert.That(actual, Is.EqualTo(expected)), instead of the classic model, Assert.AreEqual(expected, actual) (https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2005.md)
}
}
}
}
12 changes: 4 additions & 8 deletions Katas.Session.01/Katas.Session.01/EvenOddKata.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Katas.Session._01
{
public static class EvenOddKata
{
private const string EVEN = "Even";
private const string ODD = "Odd";

/// <summary>
/// This method take an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public static string EvenOrOdd(int input)
{
throw new NotImplementedException();
}
public static string EvenOrOdd(int input) => input % 2 == 0 ? EVEN : ODD;
}
}
7 changes: 3 additions & 4 deletions Katas.Session.01/Katas.Session.01/MinMaxKata.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Katas.Session._01
{
Expand All @@ -18,7 +15,9 @@ public static class MinMaxKata
/// <exception cref="NotImplementedException"></exception>
public static string ComputeMinMax(string input)
{
throw new NotImplementedException();
var inputList = input?.Split()?.Select(int.Parse);

return $"{inputList?.Max()} {inputList?.Min()}";
}
}
}
11 changes: 7 additions & 4 deletions Katas.Session.01/Katas.Session.01/MultipleKata.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Katas.Session._01
{
Expand All @@ -18,7 +15,13 @@ public static class MultipleKata
/// <exception cref="NotImplementedException"></exception>
public static int SumMultiplesBelow(int input)
{
throw new NotImplementedException();
if (input <= 0) return 0;

return Enumerable
.Repeat(0, input - 1)
.Select((value, index) => index + 1)
.Where(x => x % 3 == 0 || x % 5 == 0)
.Sum();
}
}
}
8 changes: 1 addition & 7 deletions Katas.Session.01/Katas.Session.01/ReverseStringKata.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Katas.Session._01
{
Expand All @@ -14,9 +11,6 @@ public static class ReverseStringKata
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public static string ReverseWords(string input)
{
throw new NotImplementedException();
}
public static string ReverseWords(string input) => string.Join(" ", input.Split().Reverse());
}
}
9 changes: 3 additions & 6 deletions Katas.Session.01/Katas.Session.01/VowelsKata.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Katas.Session._01
{
public static class VowelsKata
{
private static List<char> vowelsWanted = ['a', 'e', 'i', 'o', 'u'];

/// <summary>
/// This method counts number of vowels in the given string
/// We will consider a, e, i, o, u as vowels for this Kata (but not y).
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public static int CountVowels(string input)
{
throw new NotImplementedException();
}
public static int CountVowels(string input) => input.ToCharArray().Where(vowelsWanted.Contains).Count();
}
}
Loading