Refactor Day04 min instruction length loop for readability and efficiency
This commit is contained in:
1 parent
e643951d0e
commit
7e120081c1
1 file changed
+2
-4
+2
-4
@@ -29,14 +29,12 @@ public class Day04 : IPuzzleSolver<long>
|
||||
|
||||
private static int GetMinInstructionLength(string barcode)
|
||||
{
|
||||
for (var i = 0; i < barcode.Length; i++)
|
||||
for (var i = 1; i <= barcode.Length; i++)
|
||||
{
|
||||
var pattern = barcode[0..Math.Min(i+1, barcode.Length)];
|
||||
var pattern = barcode[0..i];
|
||||
if(CreatesBarcode([..pattern], barcode))
|
||||
{
|
||||
return pattern.Length;
|
||||
}
|
||||
}
|
||||
return barcode.Length;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user