34 lines
862 B
C#
34 lines
862 B
C#
namespace part1;
|
|
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
int sum = 0;
|
|
|
|
string letters = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
StreamReader sr = new StreamReader("input");
|
|
String line = sr.ReadLine();
|
|
//Continue to read until you reach end of file
|
|
while (line != null)
|
|
{
|
|
line = line.ToLower();
|
|
|
|
foreach(char letter in letters) {
|
|
line = line.Replace(letter.ToString(), string.Empty);
|
|
}
|
|
|
|
sum += Int32.Parse(line[0].ToString()) * 10;
|
|
sum += Int32.Parse(line.Last().ToString());
|
|
|
|
Console.WriteLine($"Line: {line} - Sum: {sum}");
|
|
line = sr.ReadLine();
|
|
}
|
|
//close the file
|
|
sr.Close();
|
|
|
|
Console.WriteLine($"Total Sum: {sum}");
|
|
}
|
|
}
|