Last active
November 25, 2019 23:19
-
-
Save ignaciomosca/2192ae9d6a542d5ba333c4358e7788ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func SamePices(used1,used2 []primitives.Attacks) { | |
u1:=append([]primitives.Attacks{},used1…) | |
u2:=append([]primitives.Attacks{},used2…) | |
for _,u := range [][]primitives.Attack{u1,u2} { | |
sort.Sort(u, func (i,j int) bool { | |
x,y:=u[i],u[j] | |
if x.Row()!=y.Row() { return x.Row()<y.Row() } | |
if x.Col()!=y.Col() { return x.Col()!=y.Col() } | |
return x.Name()<y.Name() | |
}) | |
} | |
for i := range u1 { | |
if u1[i].Name()!=u2[i].Name() || u1[i].Row()!=u2[i].Row() || u1[i].Col()!=u2[i].Col() { | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment