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();
      }
    }
  • 11 using System;
    22 using System.Linq;
    33 using System.Collections.Generic;
    44
    55 namespace Kumite
    66 {
    77 public class Problem
    88 {
    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();
    1313 }
    1414 }
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();
        }
      }
    }
  • 11 using System;
    22 using System.Linq;
    33 using System.Collections.Generic;
    44
    55 namespace Kumite
    66 {
    77 public class Problem
    88 {
    99 public static int SumDigitsOf(long integer)
    1010 {
    11 return integer.GetDigits().Sum();
    11+ return (int)(from ch in integer.ToString()
    12+ where Char.IsDigit(ch)
    13+ select Char.GetNumericValue(ch)).Sum();
    1212 }
    1313 }
    14
    15 public static class LongExtensions
    16 {
    17 public static IEnumerable<int> 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
    3131 }
Fundamentals
Code
Diff
  • using System;
    
    public class Kata
        {
            public  static int Opposite(int number) => number/-1;
        }
  • 11 using System;
    22
    33 public class Kata
    44 {
    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;
    1010 }