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.
Just to let you know, your function reports that all the strings pairs listed below are anagrams, and of course there are an infinite number of other cases that it reports false positive.
mn, lo ---
ws, cg ---
cr, du ---
rw, fc ---
ro, jw ---
yp, gn ---
va, ox ---
dc, pw ---
yh, vg ---
te, hy ---
qq, cc ---
Thanks for the feedback. I was running your code to test it... maybe I made a mistake and forgot to compile and it was somebody else's code :) I'll check again when I've got a moment.
Are you sure? b7 to a8 return 4.
If begin OR end position is a corner point (A1,A8,H1,H8) AND BOTH row and col are 1 step, we've a minimum of 4 moves.
This covers the moves A1-->B2; B2-->A1; H1-->G2; G2-->H1; A8-->B7; B7-->A8; H8-->G7; G7-->H8
For all other 1-1 moves, you will not fall in the second IF case and it returns 2 moves.
I play with the ASCII value: 'a' = 65, 'b' = 66... 'h' = 72; '1' = 49, '2' = 50,... '9' = 57
It doesn't matter if we move from a to b or b to a as ABS(66-65) == ABS(65-66) == 1; same for the digits.
Sorry to say, it fails on 4 tests:
Fail: b7 to a8 - returned 2 should be 4
Fail: b8 to a7 - returned 4 should be 2
Fail: g7 to h8 - returned 2 should be 4
Fail: g8 to h7 - returned 4 should be 2
Need extra test case...
do_test("ADAD", "BCBC", false);
ExOR approaches are passing on current test cases.
Brilliant solution, one to remember!