Skip to content

Instantly share code, notes, and snippets.

@boyanov83
Created August 19, 2014 13:46
Show Gist options
  • Save boyanov83/1f631c599f0960c1c6dc to your computer and use it in GitHub Desktop.
Save boyanov83/1f631c599f0960c1c6dc to your computer and use it in GitHub Desktop.
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