Skip to content

Commit 7fbd289

Browse files
author
Gonzalo Diaz
committed
[REWRITE] .NET C# coding style. Code fixed.
1 parent d577163 commit 7fbd289

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 10 additions & 10 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 5 additions & 5 deletions
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)