Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public int getMetric(State state) {
  2. int sum = 0;
  3. for (int x = 0; x < this.rows; x++) {
  4. for (int y = 0; y < this.columns; y++) {
  5. Point point = findCoordinate(state, this.array[x][y]);
  6. sum = (x-point.x) + (y- point.y);
  7. }
  8. }
  9. return sum;
  10. }
  11.  
  12. private Point findCoordinate(State state, int value) {
  13. for (int i = 0; i < this.rows; i++) {
  14. for (int j = 0; j < columns; j++) {
  15. if (value == state.array[i][j]) {
  16. return new Point(i, j);
  17. }
  18. }
  19. }
  20. throw new NullPointerException("Coordinate not found");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement