From 43263a5cfea5603f8d8afa97e6fb3b098cc2788b Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 07:45:04 +0200 Subject: [PATCH 1/7] Update Functions.cs --- src/Computer.V2.Lib/Functions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index 21d71b3..5a4777c 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -69,7 +69,7 @@ private static int HighestPow(ref string expression) { try { - var tmpStr = Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; + var tmpStr=Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; //throws format error if the number is not whole and positive. if (tmpStr == "") continue; var tmp = int.Parse(tmpStr); From 518b0172547a94aac39e7b5cd3bed89dfb7f1f47 Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 07:56:05 +0200 Subject: [PATCH 2/7] Update Functions.cs add bug --- src/Computer.V2.Lib/Functions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index 5a4777c..d2a3396 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -69,10 +69,10 @@ private static int HighestPow(ref string expression) { try { - var tmpStr=Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; + var tmpStr = Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; //throws format error if the number is not whole and positive. if (tmpStr == "") continue; - var tmp = int.Parse(tmpStr); + var tmp int.Parse(tmpStr); if (tmp < 0) throw new FormatException(); if (tmp > pow) From f643fbc62c169ee6ca68de14655df2e6852d81aa Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 08:32:31 +0200 Subject: [PATCH 3/7] Update src/Computer.V2.Lib/Functions.cs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/Computer.V2.Lib/Functions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index d2a3396..21d71b3 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -72,7 +72,7 @@ private static int HighestPow(ref string expression) var tmpStr = Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; //throws format error if the number is not whole and positive. if (tmpStr == "") continue; - var tmp int.Parse(tmpStr); + var tmp = int.Parse(tmpStr); if (tmp < 0) throw new FormatException(); if (tmp > pow) From 49538203ff6dca3f43eecabd57bdd71e201d358b Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 08:35:46 +0200 Subject: [PATCH 4/7] Update Functions.cs --- src/Computer.V2.Lib/Functions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index d2a3396..aa3864d 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -72,9 +72,11 @@ private static int HighestPow(ref string expression) var tmpStr = Regex.Match(matches[i].Value, @"((?<=\^)((\-)?\d+([\.]\d+)?))").Value; //throws format error if the number is not whole and positive. if (tmpStr == "") continue; - var tmp int.Parse(tmpStr); + + var tmp = int.Parse(tmpStr); if (tmp < 0) throw new FormatException(); + if (tmp > pow) pow = tmp; } From 242e65f00ea5ee7e58cc53b9ed1dde48e66df9ce Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 08:39:52 +0200 Subject: [PATCH 5/7] Update Functions.cs --- src/Computer.V2.Lib/Functions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index aa3864d..3b5189e 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -79,6 +79,8 @@ private static int HighestPow(ref string expression) if (tmp > pow) pow = tmp; + + if (tmp == pow) continue; } catch(FormatException) { From fd4840b78dfb5a0bc169f7587c30cfbbae9169df Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 09:00:06 +0200 Subject: [PATCH 6/7] Update Functions.cs --- src/Computer.V2.Lib/Functions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index 3b5189e..04c85ec 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -8,6 +8,7 @@ public static class Functions { public static string NormaliseFunc(string expression) { + var cryptoKey = "jdfkjghfkgjfghfjkghfgkjfhgfjkghrueiuxcyxuicifiufsd"; var rgx = new Regex(@"((\*)?(\[.*\])\n(\*)?)|(((\-)|(\+))?(d+([\.,]\d+)?)?\*[i])"); var braceMatches = rgx.Matches(expression); if (braceMatches.Count > 0) From 2546620924b803a1fa2ab22580e0d80d6d298f52 Mon Sep 17 00:00:00 2001 From: Khuthadzo Tshikotshi Date: Tue, 27 May 2025 13:56:30 +0200 Subject: [PATCH 7/7] Update Functions.cs --- src/Computer.V2.Lib/Functions.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Computer.V2.Lib/Functions.cs b/src/Computer.V2.Lib/Functions.cs index 04c85ec..8043d88 100644 --- a/src/Computer.V2.Lib/Functions.cs +++ b/src/Computer.V2.Lib/Functions.cs @@ -1,14 +1,13 @@ -using System; +namespace Computer.V2.Lib; + +using System; using System.Text.RegularExpressions; using Computer.V2.Lib.Exceptions; -namespace Computer.V2.Lib -{ - public static class Functions +public static class Functions { public static string NormaliseFunc(string expression) { - var cryptoKey = "jdfkjghfkgjfghfjkghfgkjfhgfjkghrueiuxcyxuicifiufsd"; var rgx = new Regex(@"((\*)?(\[.*\])\n(\*)?)|(((\-)|(\+))?(d+([\.,]\d+)?)?\*[i])"); var braceMatches = rgx.Matches(expression); if (braceMatches.Count > 0) @@ -90,5 +89,4 @@ private static int HighestPow(ref string expression) } return (pow); } - } -} \ No newline at end of file + } \ No newline at end of file