• + 1 comment

    Feel absolutely robbed on this one, this is an exercise that seemingly punishes efficiency. It should be comparing output AND operations, as I have completed 'Sample Test case 0' in the following operations: - 933 - 923 - 948 - 979 - 895 `

    Iteration: 933, Largest: 4657, Smallest: 4657, Arr: 4657, ...n

    • + 2 comments

      using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Serialization; using System.Text.RegularExpressions; using System.Text; using System;

      class Result {

      /*
       * Complete the 'equal' function below.
       *
       * The function is expected to return an INTEGER.
       * The function accepts INTEGER_ARRAY arr as parameter.
       */
      
      private static int GetDistributionGap(int largestDistribution, int smallestDistribution) {
          var gap = (largestDistribution - smallestDistribution);
      
          if (gap >= 5) {
              return 5;
          }
      
          if (gap >= 2) {
              return 2;
          }
      
          return 1;
      }
      
      public static int equal(List<int> arr, int operations = 0)
      {   
          var newDistributions = new List<int>(arr);
          var nextOperations = operations;
      
          var largestDistribution = arr.Max();
          var smallestDistribution = arr.Min();
      
          if (AnyDifferent(arr)) {    
              nextOperations = nextOperations + 1;
      
              // var largestDistribution = arr.Max();
              // var smallestDistribution = arr.Min();
      
              var requiredDistribution = GetDistributionGap(largestDistribution, smallestDistribution);
      
              for(int i = 0; i < arr.Count(); i++) {
                  var leftValue = arr[i];
                  if (leftValue < largestDistribution) {
                      newDistributions[i] = leftValue + requiredDistribution;
                  }
              }
          }
      
          if (nextOperations != operations) {
              return equal(newDistributions, nextOperations);
          }
      
          Console.WriteLine($"Iteration: {nextOperations}, Largest: {largestDistribution}, Smallest: {smallestDistribution}, Arr: {string.Join(", ", newDistributions)}");
          return nextOperations;
      }
      
      public static bool AnyDifferent(List<int> arr) {
          for(int i = 0; i < arr.Count; i++) {
              var comparable = arr[0];
              if (comparable != arr[i]) {
                  return true;
              }
          }
      
          return false;
      }
      

      }

      class Solution { public static void Main(string[] args) { TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);

          int t = Convert.ToInt32(Console.ReadLine().Trim());
      
          for (int tItr = 0; tItr < t; tItr++)
          {
              int n = Convert.ToInt32(Console.ReadLine().Trim());
      
              List<int> arr = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList();
      
              int result = Result.equal(arr);
      
              textWriter.WriteLine(result);
          }
      
          textWriter.Flush();
          textWriter.Close();
      }
      

      }

      • + 0 comments

        Equality is the principle that all individuals, regardless of their background, gender, race, or status, should have the same rights and opportunities. It emphasizes fairness and impartiality in access to resources, treatment, and decision-making. In practice, promoting equality requires removing barriers that prevent marginalized groups from fully participating in society and ensuring that everyone is treated with dignity and respect. Whether in education, the workplace, or legal systems, fostering an environment where equality is upheld leads to more inclusive, harmonious, and productive communities.