export function areEqual<T>(arr1: ReadonlyArray<T>, arr2: ReadonlyArray<T>) {
  return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
}

export function difference<T>(arr1: ReadonlyArray<T>, arr2: ReadonlyArray<T>) {
  if (arr1.length !== arr2.length) return null;

  const changes = [];
  // eslint-disable-next-line unicorn/no-for-loop
  for (let i = 0; i < arr1.length; i += 1) {
    if (arr1[i] !== arr2[i]) {
      changes.push(i);
    }
  }

  return changes;
}

export function isSorted(arr: Array<number>) {
  return arr.every((value, index, array) => !index || array[index - 1] <= value);
}
