Skip to content

Commit 315031b

Browse files
author
Gonzalo Diaz
committed
WIP
1 parent aaf1d24 commit 315031b

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

src/algorithm_exercises_csharp/hackerrank/warmup/MiniMaxSum.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

5-
using System.Diagnostics.CodeAnalysis;
6-
75
public static class MiniMaxSum
86
{
97
public static string miniMaxSum(List<int> arr)
108
{
9+
ArgumentNullException.ThrowIfNull(arr);
10+
1111
if (arr.Count == 0)
1212
{
1313
throw new ArgumentException("Parameter cannot be empty", nameof(arr));
@@ -25,6 +25,6 @@ public static string miniMaxSum(List<int> arr)
2525
tmax = Math.Max(tmax, value);
2626
}
2727

28-
return string.Format("{0} {1}", tsum - tmax, tsum - tmin);
28+
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1}", tsum - tmax, tsum - tmin);
2929
}
3030
}

src/algorithm_exercises_csharp/hackerrank/warmup/PlusMinus.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

55
using System.Globalization;
6-
using System.Diagnostics.CodeAnalysis;
76

87
public static class PlusMinus
98
{
109
public static string plusMinus(List<int> arr)
1110
{
11+
ArgumentNullException.ThrowIfNull(arr);
12+
1213
int positives = 0;
1314
int negatives = 0;
1415
int zeros = 0;

src/algorithm_exercises_csharp/hackerrank/warmup/SimpleArraySum.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

5-
using System.Diagnostics.CodeAnalysis;
6-
75
public static class SimpleArraySum
86
{
97
public static int simpleArraySum(int[] inputs)
108
{
9+
ArgumentNullException.ThrowIfNull(inputs);
10+
1111
var total = 0;
1212

1313
foreach (int i in inputs)

src/algorithm_exercises_csharp/hackerrank/warmup/SolveMeFirst.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

5-
using System.Diagnostics.CodeAnalysis;
6-
75
public static class SolveMeFirst
86
{
97
public static int solveMeFirst(int _a, int _b)

src/algorithm_exercises_csharp/hackerrank/warmup/Staircase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

55
using System.Text;
6-
using System.Diagnostics.CodeAnalysis;
76

87
public static class Staircase
98
{
@@ -29,6 +28,6 @@ public static string staircase(int _n)
2928

3029
result.Add(line.ToString());
3130
}
32-
return String.Join("\n", result);
31+
return string.Join("\n", result);
3332
}
3433
}

src/algorithm_exercises_csharp/hackerrank/warmup/TimeConversion.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace algorithm_exercises_csharp.hackerrank.warmup;
44

5-
using System.Diagnostics.CodeAnalysis;
6-
75
public static class TimeConversion
86
{
97
public static string timeConversion(string _s)
108
{
9+
ArgumentNullException.ThrowIfNull(_s);
10+
1111
string meridian = _s[^2..];
12-
meridian = meridian.ToLower();
12+
meridian = meridian.ToLowerInvariant();
1313

1414
string time_str = _s[0..(_s.Length - 2)];
1515
List<string> time = [.. time_str.Split(":")];
1616

17-
int hour = Int32.Parse(time[0]);
17+
int hour = Int32.Parse(time[0], System.Globalization.CultureInfo.InvariantCulture);
1818

1919
if (hour >= 12)
2020
{
@@ -25,7 +25,7 @@ public static string timeConversion(string _s)
2525
hour += 12;
2626
}
2727

28-
time[0] = String.Format("{0:00}", hour);
29-
return String.Join(":", time);
28+
time[0] = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:00}", hour);
29+
return string.Join(":", time);
3030
}
3131
}

0 commit comments

Comments
 (0)