ben
/
aoc
1
0
Fork 0

make logic clearer
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2023-12-01 12:53:24 -05:00
parent 45d69702c2
commit fb2c66e47e
1 changed files with 6 additions and 6 deletions

View File

@ -27,14 +27,14 @@ public class Day01() : Day(2023, 1, "Trebuchet?!")
foreach (var (digit, spelled) in _singleDigits.Indexed()) foreach (var (digit, spelled) in _singleDigits.Indexed())
{ {
if (i + spelled.Length - 1 >= line.Length || line[i..(i + spelled.Length)] != spelled) if (i + spelled.Length - 1 < line.Length && line[i..(i + spelled.Length)] == spelled)
continue; {
digits.Add(digit);
digits.Add(digit); break;
break; }
} }
} }
return digits.First() * 10 + digits.Last(); return digits.First() * 10 + digits.Last();
}); });
} }