### Adding the digits of an integer

Code
Diff
• ``````using System;
using System.Linq;
using System.Collections.Generic;

namespace Kumite
{
public class Problem
{
public static int SumDigitsOf(long integer) =>
Array.ConvertAll(integer.ToString().TrimStart('-').ToCharArray(),
c => (int)Char.GetNumericValue(c)).Sum();
}
}``````
•  1 1 using System; 2 2 using System.Linq; 3 3 using System.Collections.Generic; 4 4 5 5 namespace Kumite 6 6 { 7 7 public class Problem 8 8 { 9 − public static int SumDigitsOf(long integer) => (int)(from ch in integer.ToString() 10 − where Char.IsDigit(ch) 11 − select Char.GetNumericValue(ch)).Sum(); 12 − 9 + public static int SumDigitsOf(long integer) => 10 + Array.ConvertAll(integer.ToString().TrimStart('-').ToCharArray(), 11 + c => (int)Char.GetNumericValue(c)).Sum(); 13 13 } 14 14 }

### Adding the digits of an integer

Code
Diff
• ``````using System;
using System.Linq;
using System.Collections.Generic;

namespace Kumite
{
public class Problem
{
public static int SumDigitsOf(long integer)
{
return (int)(from ch in integer.ToString()
where Char.IsDigit(ch)
select Char.GetNumericValue(ch)).Sum();
}
}
}``````
•  1 1 using System; 2 2 using System.Linq; 3 3 using System.Collections.Generic; 4 4 5 5 namespace Kumite 6 6 { 7 7 public class Problem 8 8 { 9 9 public static int SumDigitsOf(long integer) 10 10 { 11 − return integer.GetDigits().Sum(); 11 + return (int)(from ch in integer.ToString() 12 + where Char.IsDigit(ch) 13 + select Char.GetNumericValue(ch)).Sum(); 12 12 } 13 13 } 14 − 15 − public static class LongExtensions 16 − { 17 − public static IEnumerable GetDigits(this long number) 18 − { 19 − number = Math.Abs(number); 20 − 21 − while (number > 9) 22 − { 23 − yield return (int)(number % 10); 24 − number /= 10; 25 − } 26 − 27 − yield return (int)number; 28 − } 29 − } 30 − 31 31 }

### Opposite number

Fundamentals
Code
Diff
• ``````using System;

public class Kata
{
public  static int Opposite(int number) => number/-1;
}``````
•  1 1 using System; 2 2 3 3 public class Kata 4 4 { 5 − public static int Opposite(int number) 6 − { 7 − // Happy Coding 8 − return number/-1; 9 − } 5 + public static int Opposite(int number) => number/-1; 10 10 }