Skip to content

Develop #33

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

Merged
merged 4 commits into from
May 16, 2024
Merged
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
24 changes: 19 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,22 @@ indent_size = 2

[*.cs]
#IDE1006
dotnet_naming_style.camel_case.capitalization = camel_case
dotnet_naming_symbols.private_symbols.applicable_accessibilities = private
dotnet_naming_rule.camel_case_for_private.severity = warning
dotnet_naming_rule.camel_case_for_private.symbols = private_symbols
dotnet_naming_rule.camel_case_for_private.style = camel_case
# Defining the 'all_methods' symbol group
dotnet_naming_symbols.all_methods.applicable_kinds = method
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public
dotnet_naming_symbols.public_symbols.required_modifiers = readonly
# Defining the 'first_word_upper_case_style' naming style
dotnet_naming_style.camel_case_style.capitalization = camel_case

# Defining the 'all_methods_must_be_camel_case' naming rule, by setting the
# symbol group to the 'public symbols' symbol group,
dotnet_naming_rule.all_methods_must_be_camel_case.symbols = all_methods
# setting the naming style to the 'first_word_upper_case_style' naming style,
dotnet_naming_rule.all_methods_must_be_camel_case.style = camel_case_style
# and setting the severity.
dotnet_naming_rule.all_methods_must_be_camel_case.severity = warning

# Due clean code suggestion
[*.{cs,vb}]
dotnet_diagnostic.IDE0054.severity = none
dotnet_diagnostic.IDE0074.severity = none
17 changes: 11 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"sonarlint.connectedMode.project": {
"connectionId": "sir-gon",
"projectKey": "sir-gon_algorithm-exercises-csharp"
},
"editor.defaultFormatter": "ms-dotnettools.csdevkit",
"editor.formatOnSave": true
"sonarlint.connectedMode.project": {
"connectionId": "sir-gon",
"projectKey": "sir-gon_algorithm-exercises-csharp"
},
"editor.formatOnSave": true,
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp"
},
"[github-actions-workflow]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
10 changes: 5 additions & 5 deletions algorithm-exercises-csharp-test/src/Hello.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace algorithm_exercises_csharp;
public class HelloWorldTest
{
[TestMethod]
public void TestInstance()
public void testInstance()
{
HelloWorld a = HelloWorld.Create();
HelloWorld b = HelloWorld.Create();
HelloWorld a = HelloWorld.create();
HelloWorld b = HelloWorld.create();

Type knownType = typeof(HelloWorld);
Type resultType = a.GetType();
Expand All @@ -28,10 +28,10 @@ public void TestInstance()
}

[TestMethod]
public void TestHello()
public void testHello()
{
string expected = "Hello World!";
string result = HelloWorld.Hello();
string result = HelloWorld.hello();

Assert.AreEqual(expected, result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public class Euler001TestCase
];

[TestMethod]
public void Euler001ProblemTest()
public void euler001Test()
{
int result;

foreach (Euler001TestCase test in tests)
{
result = Euler001Problem.Euler001(test.a, test.b, test.n);
result = Euler001.euler001(test.a, test.b, test.n);
Assert.AreEqual(test.answer, result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class Euler002TestCase
];

[TestMethod]
public void Euler002ProblemTest()
public void euler002Test()
{
int result;

foreach (Euler002TestCase test in tests)
{
result = Euler002Problem.Euler002(test.n);
result = Euler002.euler002(test.n);
Assert.AreEqual(test.answer, result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class Euler003TestCase
];

[TestMethod]
public void Euler003ProblemTest()
public void euler003Test()
{
int? result;

foreach (Euler003TestCase test in tests)
{
result = Euler003Problem.Euler003(test.n);
result = Euler003.euler003(test.n);
Assert.AreEqual(test.answer, result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace algorithm_exercises_csharp;
public class SolveMeFirstTest
{
[TestMethod]
public void TestSolveMeFirst()
public void testSolveMeFirst()
{
int expectedAnswer = 5;
int a = 2;
Expand Down
8 changes: 4 additions & 4 deletions algorithm-exercises-csharp/src/Hello.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ namespace algorithm_exercises_csharp;

public class HelloWorld
{
const string message = "Hello World!";
const string __message = "Hello World!";

[ExcludeFromCodeCoverage]
protected HelloWorld() { }

public static string Hello()
public static string hello()
{
return HelloWorld.message;
return __message;
}

public static HelloWorld Create()
public static HelloWorld create()
{
return new HelloWorld();
}
Expand Down
20 changes: 10 additions & 10 deletions algorithm-exercises-csharp/src/hackerrank/projecteuler/Euler001.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;

using System.Diagnostics.CodeAnalysis;

public class Euler001Problem
public class Euler001
{
[ExcludeFromCodeCoverage]
protected Euler001Problem() { }
protected Euler001() { }

public static int SuOfArithmeticProgression(int n, int d)
public static int sumOfArithmeticProgression(int n, int d)
{
int new_n = n / d;

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

public static int GCD(int u, int v)
public static int gcd(int u, int v)
{
if (v != 0)
{
return GCD(v, u % v);
return gcd(v, u % v);
}
return u;
}

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

return SuOfArithmeticProgression(new_n, a) +
SuOfArithmeticProgression(new_n, b) -
SuOfArithmeticProgression(new_n, lcm);
return sumOfArithmeticProgression(new_n, a) +
sumOfArithmeticProgression(new_n, b) -
sumOfArithmeticProgression(new_n, lcm);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;

using System.Diagnostics.CodeAnalysis;

public class Euler002Problem
public class Euler002
{
[ExcludeFromCodeCoverage]
protected Euler002Problem() { }
protected Euler002() { }

public static int FiboEvenSum(int n)
public static int fiboEvenSum(int n)
{
int total = 0;
int fibo;
Expand All @@ -32,8 +32,8 @@ public static int FiboEvenSum(int n)
}

// Function to find the sum of all multiples of a and b below n
public static int Euler002(int n)
public static int euler002(int n)
{
return FiboEvenSum(n);
return fiboEvenSum(n);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace algorithm_exercises_csharp.hackerrank.prohecteuler;

using System.Diagnostics.CodeAnalysis;

public class Euler003Problem
public class Euler003
{
[ExcludeFromCodeCoverage]
protected Euler003Problem() { }
protected Euler003() { }

public static int? PrimeFactor(int n)
public static int? primeFactor(int n)
{
if (n < 2)
{
Expand Down Expand Up @@ -42,8 +42,8 @@ protected Euler003Problem() { }
}

// Function to find the sum of all multiples of a and b below n
public static int? Euler003(int n)
public static int? euler003(int n)
{
return PrimeFactor(n);
return primeFactor(n);
}
}
Loading