make logic clearer
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
45d69702c2
commit
fb2c66e47e
|
@ -27,14 +27,14 @@ public class Day01() : Day(2023, 1, "Trebuchet?!")
|
|||
|
||||
foreach (var (digit, spelled) in _singleDigits.Indexed())
|
||||
{
|
||||
if (i + spelled.Length - 1 >= line.Length || line[i..(i + spelled.Length)] != spelled)
|
||||
continue;
|
||||
|
||||
digits.Add(digit);
|
||||
break;
|
||||
if (i + spelled.Length - 1 < line.Length && line[i..(i + spelled.Length)] == spelled)
|
||||
{
|
||||
digits.Add(digit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return digits.First() * 10 + digits.Last();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue