Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Same here. Caching the results doesn't help and I don't intend to implement a BK-tree on my own for a 3 kyu kata.
EDIT: Calculating the distance has been the bottleneck here. Try a more efficient implementation. It should be able to calculate the distance from
abcdefghijklmno
topqrstuvwxyzabcd
very quickly instead of taking ages.Damn... Yeah, I did that translation a while ago and didn't know the problem with arrays used with hashcodes yet. I'll take a look at all of this later.
Actually, my testcases all validated except the randomcases. So I actually had to make a distinction method and then it all ran fine.
Looking at your testcase creation for the random ones; I see you use:
Set<int[]> posAtt = new HashSet<int[]>();
This is where it goes wrong. new int[]{1,3} != new int[]{1,3}
arrays use the default hashcode implementation for checking equals.
here are some possible solutions:
use a SortedSet like TreeSet and give a comparator on creation like: Set<int[]> test = new TreeSet<>(Comparator.comparing(Arrays::toString));
use a Set of lists instead of int[], they actually check the elements on equality.
my personal favourite: use a set of Point. Its an incredibly simply int-tuple that does what you expect.
If you don't want to destroy any of the current solutions, the first suggestion would work fine (altough it's very bad!), but just remember for next time to use an actual Object as keys in sets and maps :)
Done. ;)
ok.
Errr on second thoughts, you don't have to handle this because you will never hit several times the same spot in the "real life" game. Accordingly, the provided attack array never give you duplicate coordinates. That's why most of the solution do not take that into account.
language?