Skip to content

Commit 02fa4f8

Browse files
committed
'v1.0'
0 parents  commit 02fa4f8

File tree

633 files changed

+29910
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+29910
-0
lines changed

.vs/CodeSolveTool/v17/.suo

83 KB
Binary file not shown.
26.2 MB
Binary file not shown.
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
<PrivateAssets>all</PrivateAssets>
16+
</PackageReference>
17+
<PackageReference Include="coverlet.collector" Version="3.1.0">
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
<PrivateAssets>all</PrivateAssets>
20+
</PackageReference>
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Xunit;
8+
using Xunit.Abstractions;
9+
10+
namespace TestYazilimi.Test
11+
{
12+
public class Question1UnitTest
13+
{
14+
static string path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\..\\"));
15+
private readonly ITestOutputHelper _testOutputHelper;
16+
public Question1UnitTest(ITestOutputHelper testOutputHelper)
17+
{
18+
this._testOutputHelper = testOutputHelper;
19+
}
20+
21+
[Theory]
22+
[MemberData(nameof(GetData), parameters: 5)]
23+
public void TestCases(int questionNo, int caseNo, string input, string output)
24+
{
25+
_testOutputHelper.WriteLine($"{questionNo}. question, {caseNo} test case process");
26+
//Arrange - Veri Girişleri
27+
int answer = 0;
28+
int.TryParse(output, out answer);
29+
30+
//Act - Olması Gereken Davranış
31+
HashSet<char> set = new HashSet<char>();
32+
int currentMax = 0,
33+
i = 0,
34+
j = 0;
35+
36+
while (j < input.Length)
37+
if (!set.Contains(input[j]))
38+
{
39+
set.Add(input[j++]);
40+
currentMax = Math.Max(currentMax, j - i);
41+
}
42+
else
43+
set.Remove(input[i++]);
44+
45+
//Assert - Sonuç Kontrol
46+
Assert.Equal(currentMax, answer);
47+
}
48+
49+
public static IEnumerable<object[]> GetData(int numTests)
50+
{
51+
var listInputOutput = new List<object[]>();
52+
53+
for (int k = 1; k <= 5; k++)
54+
{
55+
string input = File.ReadAllText($"{path}/CodeSolveTool/Inputs/Question1_Input{k}.txt");
56+
string output = File.ReadAllText($"{path}/CodeSolveTool/Outputs/Question1_Output{k}.txt");
57+
listInputOutput.Add(new object[] { 1, k, input, output });
58+
}
59+
60+
return listInputOutput.Take(numTests);
61+
}
62+
}
63+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Xunit;
8+
using Xunit.Abstractions;
9+
10+
namespace TestYazilimi.Test
11+
{
12+
public class Question2UnitTest
13+
{
14+
static string path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\..\\"));
15+
private readonly ITestOutputHelper _testOutputHelper;
16+
public Question2UnitTest(ITestOutputHelper testOutputHelper)
17+
{
18+
this._testOutputHelper = testOutputHelper;
19+
}
20+
21+
[Theory]
22+
[MemberData(nameof(GetData), parameters: 5)]
23+
public void TestCases(int questionNo, int caseNo, string input, string output)
24+
{
25+
_testOutputHelper.WriteLine($"{questionNo}. question, {caseNo} test case process");
26+
//Arrange - Veri Girişleri
27+
int answer = 0;
28+
int.TryParse(output, out answer);
29+
30+
//Act - Olması Gereken Davranış
31+
char[] arrInput = input.ToCharArray();
32+
char[] arrCheck = { '(', '[', '{' };
33+
List<int> checkedOut = new List<int>();
34+
int puan = 0;
35+
36+
foreach (var item in arrInput)
37+
{
38+
if (arrCheck.Contains(item) && !checkedOut.Contains(item))
39+
{
40+
checkedOut.Add(item);
41+
int numOpen = arrInput.Where(x => x == item).Count();
42+
int numClose = 0;
43+
//(, {, [ açılış parantezleri değerlendirilir ve kapanış sayısıyla karşılaştırılır.
44+
switch (item)
45+
{
46+
case '(':
47+
numClose = arrInput.Where(y => y == ')').Count();
48+
puan += numClose;
49+
break;
50+
case '[':
51+
numClose = arrInput.Where(y => y == ']').Count();
52+
puan += 2 * numClose;
53+
break;
54+
case '{':
55+
numClose = arrInput.Where(y => y == '}').Count();
56+
puan += 3 * numClose;
57+
break;
58+
default:
59+
break;
60+
}
61+
62+
if (numOpen != numClose)
63+
{
64+
//Eşitsizlik vardır
65+
puan = -1;
66+
break;
67+
}
68+
}
69+
}
70+
71+
//Assert - Sonuç Kontrol
72+
Assert.Equal(puan, answer);
73+
}
74+
75+
public static IEnumerable<object[]> GetData(int numTests)
76+
{
77+
var listInputOutput = new List<object[]>();
78+
79+
for (int k = 1; k <= 5; k++)
80+
{
81+
string input = File.ReadAllText($"{path}/CodeSolveTool/Inputs/Question2_Input{k}.txt");
82+
string output = File.ReadAllText($"{path}/CodeSolveTool/Outputs/Question2_Output{k}.txt");
83+
listInputOutput.Add(new object[] { 2, k, input, output });
84+
}
85+
86+
return listInputOutput.Take(numTests);
87+
}
88+
}
89+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Xunit;
8+
using Xunit.Abstractions;
9+
10+
namespace TestYazilimi.Test
11+
{
12+
public class Question3UnitTest
13+
{
14+
static string path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\..\\"));
15+
private readonly ITestOutputHelper _testOutputHelper;
16+
public Question3UnitTest(ITestOutputHelper testOutputHelper)
17+
{
18+
this._testOutputHelper = testOutputHelper;
19+
}
20+
21+
[Theory]
22+
[MemberData(nameof(GetData), parameters: 5)]
23+
public void TestCases(int questionNo, int caseNo, string input, string output)
24+
{
25+
_testOutputHelper.WriteLine($"{questionNo}. question, {caseNo} test case process");
26+
//Arrange - Veri Girişleri
27+
int answer = 0;
28+
int.TryParse(output, out answer);
29+
int expectedAnswer;
30+
31+
//Act - Olması Gereken Davranış
32+
Dictionary<int, int> dictNumbers = new Dictionary<int, int>();
33+
foreach (var num in input.Split(' '))
34+
{
35+
int number = 0;
36+
int.TryParse(num, out number);
37+
if (dictNumbers.ContainsKey(number))
38+
{
39+
dictNumbers[number]++;
40+
}
41+
else
42+
{
43+
dictNumbers[number] = 1;
44+
}
45+
}
46+
47+
//Eşleniği çift olmayan sayı yalnız sayıdır.
48+
expectedAnswer = dictNumbers.Where(p => p.Value % 2 == 1).First().Key;
49+
50+
//Assert - Sonuç Kontrol
51+
Assert.Equal(expectedAnswer, answer);
52+
}
53+
54+
public static IEnumerable<object[]> GetData(int numTests)
55+
{
56+
var listInputOutput = new List<object[]>();
57+
58+
for (int k = 1; k <= 5; k++)
59+
{
60+
string input = File.ReadAllText($"{path}/CodeSolveTool/Inputs/Question3_Input{k}.txt");
61+
string output = File.ReadAllText($"{path}/CodeSolveTool/Outputs/Question3_Output{k}.txt");
62+
listInputOutput.Add(new object[] { 3, k, input, output });
63+
}
64+
65+
return listInputOutput.Take(numTests);
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)