Ad
Code
Diff
  • using System;
    
    public class Program
    {
      public static int FindSquaresInArray(int[] arr)
      {
        int sum = 0;
        for (int i = 0; i < arr.Length; i++)
        {
          sum += arr[i] * arr[i];
        }
        return sum;
      }
    }
    
    • using System;
    • public class Program
    • {
    • public static int FindSquaresInArray(int[] arr)
    • {
    • int sum = 0;
    • for (int i = 0; i < arr.Length; i++)
    • {
    • for (int j = 0; j < arr[i]; j++)
    • {
    • sum += arr[i];
    • }
    • sum += arr[i] * arr[i];
    • }
    • return sum;
    • }
    • }
Code
Diff
  • public static class Kata
    {
        public static int SameCase(char a, char b)
        {
            if (!char.IsLetter(a) || !char.IsLetter(b))
            {
                return -1;
            }
    
            return char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
        }
    }
    
    • public static class Kata
    • {
    • public static int SameCase(char a, char b)
    • {
    • if (!IsLetter(a) || !IsLetter(b))
    • if (!char.IsLetter(a) || !char.IsLetter(b))
    • {
    • return -1;
    • }
    • return IsUpper(a) == IsUpper(b) ? 1 : 0;
    • }
    • private static bool IsLetter(char c)
    • {
    • return (uint)(c - 'A') <= ('Z' - 'A') || (uint)(c - 'a') <= ('z' - 'a');
    • }
    • private static bool IsUpper(char c)
    • {
    • return (uint)(c - 'A') <= ('Z' - 'A');
    • return char.IsUpper(a) == char.IsUpper(b) ? 1 : 0;
    • }
    • }