4 kyu

A Knight's Tour

127 of 183emef
Description
Loading description...
Algorithms
View
AllIssues5QuestionsSuggestions4Show Resolved
  • Please sign in or sign up to leave a comment.
  • artem-totality Avatar

    This comment has been hidden.

  • trashy_incel Avatar

    the description could mention that it does not matter whether our path is open or closed (a closed tour is one in which the knight can reach the starting position from the final position)

  • montoyama Avatar

    This one rattled my mind for days! I wanted to solve with no consultations on the problem. This led me to a brute force approach which, predictably, failed for lack of time and resources. Then I looked a bit for hints and came across Warnsdorrf's rule. Things turned around quickly! So, my only suggestion on this kata would be to hint that this requires a strong grasp on solving with algorithms and heuristics, which we might need to research.

  • alexc19 Avatar

    Fun kata, thank you. I was able to solve this as a particular case of a more general problem.

    A couple of suggestions to improve the description:

    • explain that the coordinates range from 0 to n - 1 (typically, in chess, rows and columns range from 1 to n);
    • at least for Python, the expected result is a list of tuples, not a "2D array".
  • Quark Fox Avatar

    is there anything wrong with sample tests in Python? sample tests timesout my solution for the kata, though i've already passed the kata,would you please take a look? i mean i was confident so i tried the attempt button anyway, but imagine someone stuck there and unnecessarily changing their code!

  • micah.py Avatar

    this is hard

  • Stefan30 Avatar

    The example tests for JS are broken, but it is funny because the author actually wrote that as a comment in there XDD

  • pl3onasm Avatar

    A challenge version someone? :)

  • FArekkusu Avatar

    Python 3.8 should be enabled.

  • ejini战神 Avatar

    splendid kata ~~ learned a lot from this one ^^

  • Harleigh Avatar

    Really fun Kata! Just an absolute blast to solve!

  • chapmanmartind Avatar

    A bit unrelated - could the author tell me what he used to make the visualization tool? I've been looking to get into basic visualizations. Thanks.

  • fibonaccios Avatar

    Great Kata!

  • David Gildour Avatar

    Fun kata, but to my surprise my solution failed one test in sample cases (start (2, 2)), yet passed all the regular tests without any problems. It would be helpful to know what does validate_tour actually do.

  • FArekkusu Avatar

    Python 3 should be enabled.

  • ricardorolim Avatar

    It should be mentioned that the expected Python result is a list of tuples, not a 2D array as stated in the description.

  • Voile Avatar

    Approved

  • docgunthrop Avatar

    JavaScript translation appears broken. Couple problems with this kata.

    First, the sample tests are broken. It will always return the following message:

    TypeError: Cannot read property 'forEach' of undefined at Object.handleError

    at ContextifyScript.Script.runInThisContext at Object.exports.runInThisContext

    Second, my solution appears to pass the test, but the following error keeps coming up for all solutions (replace [0,2] with any [x,y] starting values; it applies to all cases):

    Path does not start at correct position - Expected: [0, 2], instead got: [0, 2]
    
  • cacr Avatar

    My solution is able to find a tour quickly if it exists, but would be extremely slow if a solution doesn't exist, even on a 5 x 5 grid (this would surely timeout on codewars) Maybe it would be worth mentioning in the description that tests will cover only cases where at least a solution exists.

    Else this is a fun Kata :)

  • ChristianECooper Avatar

    It might be worth explicitly saying that the solution does not have to be tour that can cycle. (I.e. the last position in your list does not have to be able to move to the start position, making the tour repeatable)