package am.aua.utils; import java.util.stream.IntStream; public class ArrayUtils { public static int indexOf(int[] arr, int val) { return IntStream.range(0, arr.length).filter(i -> arr[i] == val).findFirst().orElse(-1); } public static int getCol(int num, int[] arr, int width) { int idx = indexOf(arr, num); return idx % width; } public static int getRow(int num, int[] arr, int width) { int idx = indexOf(arr, num); return idx / width; } }