-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodeWars, Dog class #16
Open
Fuflick
wants to merge
22
commits into
ISUCT:Belov_Stepan_Maksimovich
Choose a base branch
from
Fuflick:master
base: Belov_Stepan_Maksimovich
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
73fb6b9
CodeWars tasks and tests for whem
Fuflick f693ff4
CodeWars, dog class, fix linter
Fuflick 4539a92
Fix dotnetcore.yml
Fuflick 32b8d99
try to fix problem on gh
Fuflick 40666ed
fix checkout and setup-doynet to @v3
Fuflick 6b97f7b
Try to fix conflict
Fuflick 0272fd8
Try to fix again
Fuflick 434fcb4
Try number 3
Fuflick 547f3f0
Try №4
Fuflick bccc735
Fix num 5
Fuflick b846f80
Fix num 6
Fuflick 39e5b21
Fix num 7
Fuflick b7c156e
Try 8
Fuflick 1009acc
Try 9
Fuflick 7bbad36
Add func and List to the Dog class
Fuflick d517a4a
Fix workflows
Fuflick e277191
add letter to the end of file dotnetcore.yml
Fuflick ef396b7
Rpg saga
Fuflick 0fcb999
Fix pragma's exception with global using in CourseApp.Tests/CodeWarsU…
Fuflick ba45d72
make Dog's age property uint
Fuflick 7cdb821
delete '~' from Dockerfile (I don't know, how his got here.)
Fuflick 506310b
Some changes in RpgSaga
Fuflick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CodeWarsTests\CodeWarsTests.csproj" /> | ||
</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,12 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
using CodWearsTests; | ||
|
||
public class CamalCaseTest | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
Assert.Equal("theStealthWarrior", StrToCamelCase.ToCamelCase("the_stealth_warrior")); | ||
} | ||
} |
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
CourseApp.Tests/CodeWarsUnitTests/DuplicatesEncoderTest.cs
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,42 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
using CodWearsTests; | ||
|
||
public class DuplicatesEncoderTest | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
// Act | ||
var res = DuplicatesEncoder.DuplicateEncode("din"); | ||
|
||
Assert.Equal("(((", res); | ||
} | ||
|
||
[Fact] | ||
public void Test2() | ||
{ | ||
// Act | ||
var res = DuplicatesEncoder.DuplicateEncode("recede"); | ||
|
||
Assert.Equal("()()()", res); | ||
} | ||
|
||
[Fact] | ||
public void Test3() | ||
{ | ||
// Act | ||
var res = DuplicatesEncoder.DuplicateEncode("Success"); | ||
|
||
Assert.Equal(")())())", res); | ||
} | ||
|
||
[Fact] | ||
public void Test4() | ||
{ | ||
// Act | ||
var res = DuplicatesEncoder.DuplicateEncode("(( @"); | ||
|
||
Assert.Equal("))((", res); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
CourseApp.Tests/CodeWarsUnitTests/FindMissingLetter.Test.cs
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,18 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
using CodWearsTests; | ||
|
||
public class FindMissingLetter_Test | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
Assert.Equal('e', MissingLetter.FindMissingLetter(new[] { 'a', 'b', 'c', 'd', 'f' })); | ||
} | ||
|
||
[Fact] | ||
public void Test2() | ||
{ | ||
Assert.Equal('P', MissingLetter.FindMissingLetter(new[] { 'O', 'Q', 'R', 'S' })); | ||
} | ||
} |
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 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
using CodWearsTests; | ||
|
||
public class Merge_Tests | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
Assert.Equal(new string[] { "a", "1", "b", "2", "c", "3", "d", "e" }, Merge.MergeArrays(new string[] { "a", "b", "c", "d", "e" }, new string[] { "1", "2", "3" })); | ||
} | ||
} |
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,9 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
public class SumOfDigigts | ||
{ | ||
public int DigitalRoot(long n) | ||
{ | ||
return 0; | ||
} | ||
} |
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,26 @@ | ||
namespace CodeWarsTests.UnitTest; | ||
|
||
using CodWearsTests; | ||
|
||
public class TowerTest | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
Assert.Equal(string.Join(",", new[] { "*" }), string.Join(",", Towerbuild.TowerBuilder(1))); | ||
} | ||
|
||
[Fact] | ||
public void Test2() | ||
{ | ||
Assert.Equal(string.Join(",", new[] { " * ", "***" }), string.Join(",", Towerbuild.TowerBuilder(2))); | ||
} | ||
|
||
[Fact] | ||
public void Test3() | ||
{ | ||
Assert.Equal( | ||
string.Join(",", new[] { " * ", " *** ", "*****" }), | ||
string.Join(",", Towerbuild.TowerBuilder(3))); | ||
} | ||
} |
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,3 @@ | ||
#pragma warning disable SA1200 | ||
global using Xunit; | ||
#pragma warning restore SA1200 |
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,9 @@ | ||
namespace CodWearsTests; | ||
|
||
public class DigitalRootClass | ||
{ | ||
public static int DigitalRoot(long n) | ||
{ | ||
return 0; | ||
} | ||
} |
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 @@ | ||
namespace CodWearsTests; | ||
|
||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
public class DuplicatesEncoder | ||
{ | ||
public static string DuplicateEncode(string word) | ||
{ | ||
var mass = new List<string>(); | ||
word = word.ToLower(); | ||
foreach (var sym in word) | ||
{ | ||
mass.Add(word.Count(x => x == sym) != 1 ? ")" : "("); | ||
} | ||
|
||
return string.Join(string.Empty, mass); | ||
} | ||
} |
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 @@ | ||
namespace CodWearsTests; | ||
|
||
public class FibNums | ||
{ | ||
public static ulong[] ProductFib(ulong prod) | ||
{ | ||
ulong a = 0; | ||
ulong b = 1; | ||
|
||
while (a * b < prod) | ||
{ | ||
ulong temp = a; | ||
a = b; | ||
b = temp + b; | ||
} | ||
|
||
return new ulong[] { a, b, (ulong)(a * b == prod ? 1 : 0) }; | ||
} | ||
} |
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,37 @@ | ||
namespace CodWearsTests; | ||
|
||
using System.Collections.Generic; | ||
|
||
public class Merge | ||
{ | ||
public static string[] MergeArrays(string[] arr1, string[] arr2) | ||
{ | ||
var res = new List<string>(); | ||
var length = arr1.Length > arr2.Length ? arr2.Length : arr1.Length; | ||
var index = 0; | ||
|
||
while (index < length) | ||
{ | ||
res.Add(arr1[index]); | ||
res.Add(arr2[index]); | ||
index++; | ||
} | ||
|
||
if (arr1.Length > arr2.Length) | ||
{ | ||
for (; index < arr1.Length; index++) | ||
{ | ||
res.Add(arr1[index]); | ||
} | ||
} | ||
else | ||
{ | ||
for (; index < arr2.Length; index++) | ||
{ | ||
res.Add(arr2[index]); | ||
} | ||
} | ||
|
||
return res.ToArray(); | ||
} | ||
} |
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,24 @@ | ||
namespace CodWearsTests; | ||
|
||
public class MissingLetter | ||
{ | ||
public static char FindMissingLetter(char[] chars) | ||
{ | ||
var alphabet = "abcdefghijklmnopqrstuvwxyz"; | ||
chars.ToString(); | ||
|
||
if (char.IsUpper(chars[0])) | ||
{ | ||
alphabet = alphabet.ToUpper(); | ||
} | ||
|
||
var index = alphabet.IndexOf(chars[0]); | ||
|
||
for (int i = 0; chars[i] == alphabet[index]; i++) | ||
{ | ||
index++; | ||
} | ||
|
||
return alphabet[index]; | ||
} | ||
} |
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,25 @@ | ||
namespace CodWearsTests; | ||
|
||
public class StrToCamelCase | ||
{ | ||
public static string ToCamelCase(string str) | ||
{ | ||
var res = string.Empty; | ||
|
||
str.ToCharArray(); | ||
for (int i = 0; i < str.Length; i++) | ||
{ | ||
if (str[i] != '_' && str[i] != '-') | ||
{ | ||
res += str[i].ToString(); | ||
} | ||
else | ||
{ | ||
res += str[i + 1].ToString().ToUpper(); | ||
i += 1; | ||
} | ||
} | ||
|
||
return res; | ||
} | ||
} |
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,36 @@ | ||
namespace CodWearsTests; | ||
|
||
public class TicTacToe | ||
{ | ||
public int IsSolved(int[,] board) | ||
{ | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
if (board[i, 0] == board[i, 1] && (board[i, 1] == board[i, 2]) && board[i, 1] != 0) | ||
{ | ||
return board[i, 0]; | ||
} | ||
else if (board[0, i] == board[1, i] && board[1, i] == board[2, i] && board[1, i] != 0) | ||
{ | ||
return board[i, 0]; | ||
} | ||
else if ((board[0, 0] == board[1, 1] && board[1, 1] == board[2, 2] && board[1, 1] != 0) || | ||
(board[2, 0] == board[1, 1] && board[1, 1] == board[0, 2] && board[1, 1] != 0)) | ||
{ | ||
return board[1, 1]; | ||
} | ||
else | ||
{ | ||
for (int k = 0; k < 2; k++) | ||
{ | ||
if (board[i, k] == 0) | ||
{ | ||
return -1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а это зачем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Линтер указывает на ошибку в том, что using директивы расположены неправильно. Считает, что using должен располагаться после пространства имён. Я поправил, докинул в каждый класс с тестами "using Xuint" и удалил этот файл.
На будущее хотел бы спросить, есть ли какой-то более важный плюс у этого global, чем просто везде не указывать, одинаковые using'и?