Skip to content

Commit 75522fb

Browse files
authored
Merge pull request #33 from sir-gon/develop
Develop
2 parents f71bf70 + a30b179 commit 75522fb

File tree

11 files changed

+66
-47
lines changed

11 files changed

+66
-47
lines changed

.editorconfig

+19-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,22 @@ indent_size = 2
4141

4242
[*.cs]
4343
#IDE1006
44-
dotnet_naming_style.camel_case.capitalization = camel_case
45-
dotnet_naming_symbols.private_symbols.applicable_accessibilities = private
46-
dotnet_naming_rule.camel_case_for_private.severity = warning
47-
dotnet_naming_rule.camel_case_for_private.symbols = private_symbols
48-
dotnet_naming_rule.camel_case_for_private.style = camel_case
44+
# Defining the 'all_methods' symbol group
45+
dotnet_naming_symbols.all_methods.applicable_kinds = method
46+
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public
47+
dotnet_naming_symbols.public_symbols.required_modifiers = readonly
48+
# Defining the 'first_word_upper_case_style' naming style
49+
dotnet_naming_style.camel_case_style.capitalization = camel_case
50+
51+
# Defining the 'all_methods_must_be_camel_case' naming rule, by setting the
52+
# symbol group to the 'public symbols' symbol group,
53+
dotnet_naming_rule.all_methods_must_be_camel_case.symbols = all_methods
54+
# setting the naming style to the 'first_word_upper_case_style' naming style,
55+
dotnet_naming_rule.all_methods_must_be_camel_case.style = camel_case_style
56+
# and setting the severity.
57+
dotnet_naming_rule.all_methods_must_be_camel_case.severity = warning
58+
59+
# Due clean code suggestion
60+
[*.{cs,vb}]
61+
dotnet_diagnostic.IDE0054.severity = none
62+
dotnet_diagnostic.IDE0074.severity = none

.vscode/settings.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
2-
"sonarlint.connectedMode.project": {
3-
"connectionId": "sir-gon",
4-
"projectKey": "sir-gon_algorithm-exercises-csharp"
5-
},
6-
"editor.defaultFormatter": "ms-dotnettools.csdevkit",
7-
"editor.formatOnSave": true
2+
"sonarlint.connectedMode.project": {
3+
"connectionId": "sir-gon",
4+
"projectKey": "sir-gon_algorithm-exercises-csharp"
5+
},
6+
"editor.formatOnSave": true,
7+
"[csharp]": {
8+
"editor.defaultFormatter": "ms-dotnettools.csharp"
9+
},
10+
"[github-actions-workflow]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
}
813
}

algorithm-exercises-csharp-test/src/Hello.Test.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace algorithm_exercises_csharp;
44
public class HelloWorldTest
55
{
66
[TestMethod]
7-
public void TestInstance()
7+
public void testInstance()
88
{
9-
HelloWorld a = HelloWorld.Create();
10-
HelloWorld b = HelloWorld.Create();
9+
HelloWorld a = HelloWorld.create();
10+
HelloWorld b = HelloWorld.create();
1111

1212
Type knownType = typeof(HelloWorld);
1313
Type resultType = a.GetType();
@@ -28,10 +28,10 @@ public void TestInstance()
2828
}
2929

3030
[TestMethod]
31-
public void TestHello()
31+
public void testHello()
3232
{
3333
string expected = "Hello World!";
34-
string result = HelloWorld.Hello();
34+
string result = HelloWorld.hello();
3535

3636
Assert.AreEqual(expected, result);
3737

algorithm-exercises-csharp-test/src/hackerrank/projecteuler/Euler001.Test.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public class Euler001TestCase
1717
];
1818

1919
[TestMethod]
20-
public void Euler001ProblemTest()
20+
public void euler001Test()
2121
{
2222
int result;
2323

2424
foreach (Euler001TestCase test in tests)
2525
{
26-
result = Euler001Problem.Euler001(test.a, test.b, test.n);
26+
result = Euler001.euler001(test.a, test.b, test.n);
2727
Assert.AreEqual(test.answer, result);
2828
}
2929
}

algorithm-exercises-csharp-test/src/hackerrank/projecteuler/Euler002.Test.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public class Euler002TestCase
1515
];
1616

1717
[TestMethod]
18-
public void Euler002ProblemTest()
18+
public void euler002Test()
1919
{
2020
int result;
2121

2222
foreach (Euler002TestCase test in tests)
2323
{
24-
result = Euler002Problem.Euler002(test.n);
24+
result = Euler002.euler002(test.n);
2525
Assert.AreEqual(test.answer, result);
2626
}
2727
}

algorithm-exercises-csharp-test/src/hackerrank/projecteuler/Euler003.Test.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public class Euler003TestCase
2121
];
2222

2323
[TestMethod]
24-
public void Euler003ProblemTest()
24+
public void euler003Test()
2525
{
2626
int? result;
2727

2828
foreach (Euler003TestCase test in tests)
2929
{
30-
result = Euler003Problem.Euler003(test.n);
30+
result = Euler003.euler003(test.n);
3131
Assert.AreEqual(test.answer, result);
3232
}
3333
}

algorithm-exercises-csharp-test/src/hackerrank/warmup/SolveMeFirst.Test.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace algorithm_exercises_csharp;
44
public class SolveMeFirstTest
55
{
66
[TestMethod]
7-
public void TestSolveMeFirst()
7+
public void testSolveMeFirst()
88
{
99
int expectedAnswer = 5;
1010
int a = 2;

algorithm-exercises-csharp/src/Hello.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ namespace algorithm_exercises_csharp;
44

55
public class HelloWorld
66
{
7-
const string message = "Hello World!";
7+
const string __message = "Hello World!";
88

99
[ExcludeFromCodeCoverage]
1010
protected HelloWorld() { }
1111

12-
public static string Hello()
12+
public static string hello()
1313
{
14-
return HelloWorld.message;
14+
return __message;
1515
}
1616

17-
public static HelloWorld Create()
17+
public static HelloWorld create()
1818
{
1919
return new HelloWorld();
2020
}

algorithm-exercises-csharp/src/hackerrank/projecteuler/Euler001.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;
44

55
using System.Diagnostics.CodeAnalysis;
66

7-
public class Euler001Problem
7+
public class Euler001
88
{
99
[ExcludeFromCodeCoverage]
10-
protected Euler001Problem() { }
10+
protected Euler001() { }
1111

12-
public static int SuOfArithmeticProgression(int n, int d)
12+
public static int sumOfArithmeticProgression(int n, int d)
1313
{
1414
int new_n = n / d;
1515

1616
return new_n * (1 + new_n) * d / 2;
1717
}
1818

19-
public static int GCD(int u, int v)
19+
public static int gcd(int u, int v)
2020
{
2121
if (v != 0)
2222
{
23-
return GCD(v, u % v);
23+
return gcd(v, u % v);
2424
}
2525
return u;
2626
}
2727

2828
// Function to find the sum of all multiples of a and b below n
29-
public static int Euler001(int a, int b, int n)
29+
public static int euler001(int a, int b, int n)
3030
{
3131
// Since, we need the sum of multiples less than N
3232
int new_n = n - 1;
33-
int lcm = a * b / GCD(a, b);
33+
int lcm = a * b / gcd(a, b);
3434

35-
return SuOfArithmeticProgression(new_n, a) +
36-
SuOfArithmeticProgression(new_n, b) -
37-
SuOfArithmeticProgression(new_n, lcm);
35+
return sumOfArithmeticProgression(new_n, a) +
36+
sumOfArithmeticProgression(new_n, b) -
37+
sumOfArithmeticProgression(new_n, lcm);
3838
}
3939
}

algorithm-exercises-csharp/src/hackerrank/projecteuler/Euler002.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;
44

55
using System.Diagnostics.CodeAnalysis;
66

7-
public class Euler002Problem
7+
public class Euler002
88
{
99
[ExcludeFromCodeCoverage]
10-
protected Euler002Problem() { }
10+
protected Euler002() { }
1111

12-
public static int FiboEvenSum(int n)
12+
public static int fiboEvenSum(int n)
1313
{
1414
int total = 0;
1515
int fibo;
@@ -32,8 +32,8 @@ public static int FiboEvenSum(int n)
3232
}
3333

3434
// Function to find the sum of all multiples of a and b below n
35-
public static int Euler002(int n)
35+
public static int euler002(int n)
3636
{
37-
return FiboEvenSum(n);
37+
return fiboEvenSum(n);
3838
}
3939
}

algorithm-exercises-csharp/src/hackerrank/projecteuler/Euler003.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;
44

55
using System.Diagnostics.CodeAnalysis;
66

7-
public class Euler003Problem
7+
public class Euler003
88
{
99
[ExcludeFromCodeCoverage]
10-
protected Euler003Problem() { }
10+
protected Euler003() { }
1111

12-
public static int? PrimeFactor(int n)
12+
public static int? primeFactor(int n)
1313
{
1414
if (n < 2)
1515
{
@@ -42,8 +42,8 @@ protected Euler003Problem() { }
4242
}
4343

4444
// Function to find the sum of all multiples of a and b below n
45-
public static int? Euler003(int n)
45+
public static int? euler003(int n)
4646
{
47-
return PrimeFactor(n);
47+
return primeFactor(n);
4848
}
4949
}

0 commit comments

Comments
 (0)