6 kyu
Routes in a square grid
177 of 581NaMe613
Loading description...
Fundamentals
Puzzles
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.
python new test framework is required. updated in this fork
Approved
Python 3 should be enabled.
Fixed
It's probably too late to do anything but this is quite similar to https://www.codewars.com/kata/paths-in-the-grid -- same solution works with only very minor tweaks
can you help me please . i don´t know what i have to do yet... (tell me what i need to know)
Given a
n x n
grid you need to find how many ways there are to get from the top left of the grid to the bottom right of the gridExample
n = 2
:The grid
The routes
Thus
routes(2)
should return 6.Maybe there are too much random tests for clojure. My solution passes 68 tests but it takes more than 10000ms and so overall execution fails.
Hi
I just tried my solution and it passed in 3458ms, so I don't think there is any problem with the tests : )
Well, never mind. I've done it better.
You should mention in the description that you can only move down or right by an increment of 1 at a time. When you mentioned that the side length was n, I first thought you meant the increment I could travel by was n which would mean just about everything is 2. The examples cleared that up. Haha.
I wrote my solution as a recursive algorithm and for very large squares the run time exceeds the limit.
Presumably you're after a non recursive solution?
Hi I wrote my code and it passes the test cases but while submitting the code, it says that there is something wrong with the code. So is there any difference between "submit" button and "run test" button? Why the code passes the test but i cant submit it?
after "submit" you have much more examples to test your method. In "your test cases" you can add more tests if you want. In some kata there are no tests at all and you have to write it yourself :)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Hi, thanks for the reply, I've updated the tests though I wasn't able to get
routesReturns
to work properly.Once again thanks.
Translated into JS (with smaller ranges, due to problems in handling number precision in said language) and thanks for bringing me back fond memories of a nice problem I found on Euler a while ago and that took me a while to solve :)
This comment has been hidden.
Hi,
Thanks for the tranlsation (approved).
As for the cheatability, I've added some fixed tests and renamed the solution code to something less guessable.
Then thanks again for considering my thoughts and giving us better and better training grounds :)
Why does the user need to return
None
if there isn't any route? Isn't0
sufficient? Keep in mind that some languages don't have dynamic types, and returningnull
instead of anint
in Java is a little bit awkward.Better change the result to
0
if the argument is non-positive.True, I've modified it accordingly
Thanks for all your feedback.
In Java one would probably throw an exception in case of a negative argument. As for 0, returning 1 would seem a logical option.
@bkaes
I've translated this kata into Haskell, as this is my first Haskell translation and you seem pretty good at Haskell I would really appreciate your feedback if you have the time.
Thanks.
Don't put your solution in the preloaded sections! Some languages allow you to show the currently defined variables, and then it's as simple as
user_solution = predefined_solution
.Correct me if I'm wrong but moving it to just before the test cases would prevent this?
Usually, yes. Depending on the language you might need to put in a clojure, but that's only necessary in some languages. You can think of scripting language (Ruby, Python, JS, CS) tests as
Ok I think I've sorted it out. Thanks for bringing it to my attention.
Python tests (and example tests) do not work.
I'm not sure what you mean,are you getting an error or just the wrong answers?
@Unnamed doesn't provide any information in what way the tests don't work. If he doesn't respond after a while, simply resolve the issue.
By the way, I think your tests are sufficient, but you could use one or two rather large test cases.
I don't remember what was wrong. It works now.