• + 2 comments
    public static int equal(List<Integer> arr) {
            // Store all the possibilities
            int[] possibilities = new int[5];
            // Start with the minimum element
            int minimum = Collections.min(arr);
            for (int i = 0; i < possibilities.length; i++) {
                for (int k : arr) {
                    int diff = k - minimum;
                    int stepsRequired = diff / 5 + (diff % 5) / 2 + ((diff % 5) % 2) / 1;
                    possibilities[i] += stepsRequired;
                }
                minimum--;
            }
            // Return the minimum number out of all the possibilities
            return Arrays.stream(possibilities).min().getAsInt();
        }