Created
August 19, 2014 13:46
-
-
Save boyanov83/1f631c599f0960c1c6dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class NightmareOnCodeStreet | |
{ | |
static void Main() | |
{ | |
string input = Console.ReadLine(); | |
input = input.TrimStart('-'); | |
long count = 0; | |
long sum = 0; | |
long resultCount = 0; | |
char[] digits = new char[input.Length]; | |
foreach (var item in input) | |
{ | |
if (count % 2 == 1) | |
{ | |
digits[count] = item; | |
} | |
count++; | |
} | |
for (int i = 0; i < digits.Length; i++) | |
{ | |
if (i % 2 == 1) | |
{ | |
sum += long.Parse(digits[i].ToString()); | |
resultCount++; | |
} | |
} | |
Console.WriteLine("{0} {1}",resultCount, sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment