Skip to content

Commit 659ca17

Browse files
authored
Merge pull request #76 from sir-gon/develop
Develop
2 parents 997d4c4 + fa9541c commit 659ca17

File tree

2 files changed

+29
-12
lines changed
  • algorithm-exercises-csharp/src/hackerrank/projecteuler
  • algorithm-exercises-csharp-base/src

2 files changed

+29
-12
lines changed

algorithm-exercises-csharp-base/src/Logger.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace algorithm_exercises_csharp;
55

66
public sealed class LoggerSingleton
77
{
8-
private static readonly Lazy<LoggerSingleton> _instance = new Lazy<LoggerSingleton>(() => new LoggerSingleton());
8+
private static readonly Lazy<LoggerSingleton> _instance = new(() => new LoggerSingleton());
99

1010
public static LoggerSingleton Instance => _instance.Value;
1111

@@ -26,7 +26,7 @@ private LoggerSingleton()
2626
{
2727
builder
2828
.AddConsole()
29-
.SetMinimumLevel(logLevel); // Configura el nivel mínimo de logging
29+
.SetMinimumLevel(logLevel); // set minimum logging level
3030
});
3131

3232
Logger = loggerFactory.CreateLogger("GlobalLogger");
@@ -47,23 +47,31 @@ public static ILogger getLogger()
4747
return LoggerSingleton.Instance.Logger;
4848
}
4949

50-
public static void info(string message)
50+
public static void info(string message, params object?[] args)
5151
{
52-
LoggerSingleton.Instance.Logger.LogInformation(message);
52+
#pragma warning disable CA2254 // Template should be a static expression
53+
LoggerSingleton.Instance.Logger.LogInformation(message, args);
54+
#pragma warning restore CA2254 // Template should be a static expression
5355
}
5456

55-
public static void warning(string message)
57+
public static void warning(string message, params object?[] args)
5658
{
59+
#pragma warning disable CA2254 // Template should be a static expression
5760
LoggerSingleton.Instance.Logger.LogWarning(message);
61+
#pragma warning restore CA2254 // Template should be a static expression
5862
}
5963

60-
public static void error(string message)
64+
public static void error(string message, params object?[] args)
6165
{
66+
#pragma warning disable CA2254 // Template should be a static expression
6267
LoggerSingleton.Instance.Logger.LogError(message);
68+
#pragma warning restore CA2254 // Template should be a static expression
6369
}
6470

65-
public static void debug(string message)
71+
public static void debu(string message, params object?[] args)
6672
{
73+
#pragma warning disable CA2254 // Template should be a static expression
6774
LoggerSingleton.Instance.Logger.LogDebug(message);
75+
#pragma warning restore CA2254 // Template should be a static expression
6876
}
6977
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,33 @@ protected Euler002() { }
1111

1212
public static int fiboEvenSum(int n)
1313
{
14-
int total = 0;
14+
Log.info("fiboEvenSum({n})", n);
15+
16+
int i = 0;
17+
int even_sum = 0;
1518
int fibo;
1619
int fibo1 = 1;
1720
int fibo2 = 1;
1821

1922
while (fibo1 + fibo2 < n)
2023
{
2124
fibo = fibo1 + fibo2;
22-
fibo1 = fibo2;
23-
fibo2 = fibo;
25+
26+
Log.info("Fibonacci({i}) = {fibo}", i, fibo);
2427

2528
if (fibo % 2 == 0)
2629
{
27-
total += fibo;
30+
even_sum += fibo;
2831
}
32+
33+
fibo1 = fibo2;
34+
fibo2 = fibo;
35+
i += 1;
2936
}
3037

31-
return total;
38+
Log.info("Problem 0002 result: {even_sum}", even_sum);
39+
40+
return even_sum;
3241
}
3342

3443
// Function to find the sum of all multiples of a and b below n

0 commit comments

Comments
 (0)