using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("1test23"); //6 } else if (InputPattern == "Input2") { WillReturn.Add("2015"); //8 } else if (InputPattern == "Input3") { WillReturn.Add("1a2b3c4d5e6f7g8h90"); //45 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); string S = InputList[0]; Func wkFunc = pChar => { if ('1' <= pChar && pChar <= '9') return pChar - '1' + 1; return 0; }; Console.WriteLine(S.Sum(X => wkFunc(X))); } }