4 kyu
A Knight's Tour
127 of 183emef
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
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)
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.
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:
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!
works fine on my side
I updated the tests in python. Your solution atually times out in some situations x6x at 2,2, apparently)
Sample tests are now also in the full test suite, and I added some random tests.
Ya, i just checked, and on 6X6 all the other 35 points make a tour with my piece of code but not (2, 2), so i guess i am extremely lucky!! anyway i just noticed the way i followed, actually just ment to make a successful tour not necessary from any point of start, so as this kata is actually over for me, can you please refer me to any material (video or journal) by learning which i can make someting that will solve any knight's tour, i mean from any board or any point, or atleast code better than my code!!(i am not yet very good at reading others code). Thanks for solving the issue, and also for noticing and checking my code.
you'll find stuff about knight's tour all over the place on the internet. For more precise stuff, you can search for the name I used in my python solution:
..._DP
Thanks!
Alhamdulillah, solved it again, this time with no obscured fail!! found the problem and modified it! and crossed all obstacle you set!!
This comment has been hidden.
this is hard
The example tests for JS are broken, but it is funny because the author actually wrote that as a comment in there XDD
.
A challenge version someone? :)
Python 3.8 should be enabled.
splendid kata ~~ learned a lot from this one ^^
Really fun Kata! Just an absolute blast to solve!
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.
Great Kata!
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 doesvalidate_tour
actually do.Python 3 should be enabled.
Done
It should be mentioned that the expected Python result is a list of tuples, not a 2D array as stated in the description.
Thank you! I spent several hours on fixing "Invaild tour moves" before I saw your comment.
Wish someone kind to fix this description.
Approved
\o/ 2 dan! \o/
Congrats ;)
Thanks ;-)
JavaScript translation appears broken. Couple problems with this kata.
First, the sample tests are broken. It will always return the following message:
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):Unfortunately, it appears the original author is no longer active on CW (last seen ~9 months ago), so I made some updates to the kata. The changes I've made apply to the JavaScript translation.
Notes on my updates for this kata:
1 - The sample test cases should be ignored; as for clarification on how to complete the kata, the description itself should suffice.
2 - The initial problem with the test validating start position is now fixed.
3 - I've added 10 random tests using a
12 x 12
board.This comment has been hidden.
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 :)
Certain well-known algorithms can fail the Knight's Tour, depending on factors like size of the board (larger sizes, like a
200x200
board, for example). In this kata, the board sizes are 6,8,12, and 16 units in size so the majority of algorithms should work.I'm not sure if there is a case where no solution is possible; regardless, your suggestion has been added to the description.
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)
It would seem that making that distinction would only be necessary if it were a requirement (that is, if the kata actually required a result that made the tour repeatable, rather than vice versa).