21 lines
530 B
C#
21 lines
530 B
C#
namespace AdventOfCode;
|
|
|
|
public class CalibratorEvaluator
|
|
{
|
|
public static int ObtainLineCalibration(string line)
|
|
{
|
|
var firstDigit = -1;
|
|
var lastDigit = -1;
|
|
|
|
foreach (var character in line)
|
|
{
|
|
if (char.IsDigit(character))
|
|
{
|
|
firstDigit = firstDigit == -1 ? (int)char.GetNumericValue(character) : firstDigit;
|
|
lastDigit = (int)char.GetNumericValue(character);
|
|
}
|
|
}
|
|
|
|
return firstDigit * 10 + lastDigit;
|
|
}
|
|
} |