Advertisement
dvulakh

check_costas.go

Mar 4th, 2020
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.46 KB | None | 0 0
  1. package check_costas
  2.  
  3. //import "fmt"
  4.  
  5. func IsConsistent(perm []int) bool {
  6.     m := len(perm)
  7.     for _, n := range perm {
  8.         if n > m {
  9.             m = n;
  10.         }
  11.     }
  12.     vect := make([][]bool, 2 * m)
  13.     for i, _ := range vect {
  14.         vect[i] = make([]bool, 2 * m)
  15.     }
  16.     for i, x := range perm {
  17.         for j, y := range perm {
  18.             if (i == j) {
  19.                 continue
  20.             }
  21.             if vect[m + j - i][m + y - x] {
  22.                 return false
  23.             }
  24.             vect[m + j - i][m + y - x] = true
  25.         }
  26.     }
  27.     return true
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement