Ad
  • Default User Avatar

    Heck, it doesn't even need to be what you would normally consider a pathfinding algorithm. All you're looking for is whether or not there -is- a path.

  • Default User Avatar

    You dont need to Dijkstra's. That algorithm is for finding the shortest paths in weighted graph.

  • Custom User Avatar

    So Dijkstra's algo? Then if I undestand correctly, we need to write the algo here in this kata?

  • Custom User Avatar

    Search for pathfinding algorithm maybe?

  • Custom User Avatar

    #Language:Python
    #Path Finder #1
    #https://www.codewars.com/kata/path-finder-number-1-can-you-reach-the-exit/
    I have been trying all day, can't seem to figure out the algorithm.
    Can I get a hint somehow? I don't understand how to get the right algorithm

  • Custom User Avatar

    or you just correct your code/algo. :p

    I agree that the requirement is worded in a weird way, though everything is fine about the task.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Python

    There should be another couple of tests like:

    1. [[]] and [2]
    2. [2] and [[]]

    Because I wrote a conditional where it checks if the first item in the original list is a list and it passed the first test above and failed the second. Although it should have failed both the tests above.
    The problem was that this conditional assumed that the first item of the second list was also a list even though it wasn't.

  • Custom User Avatar

    Oh, I see it now. They are three elements in the list. I saw a similar issue downstairs, but couldn't realise it.

  • Custom User Avatar

    hi,

    That's not an issue, that's a question (issues are for internal problems to the kata or flaws in the logic or the tests, ... Here, you just didn't get what you're asked for).

    Other than that: always provide the language when posting for either an issue or a question.

    For your current problem, don't consider your code but the actual tests (you're trying to patch an implementation that clearly isn't matching the specs of the problem, so you won't get far doing so):

    • [1,'[',']'] same as ['[',']',1] => how could this be anything else than true? there is no nesting, here.
    • [1,[1,1]] not same as [[2,2],2] => ofc it's not the same, since the nesting isn't done at the same index in the original array.
  • Custom User Avatar

    What should this test case return? True or False?
    For me, it returns False. And when I try the reversing the list and then checking the structure, I get an error there.
    I am not sure how to handle this. I raised an issue, but maybe I misunderstood?

  • Custom User Avatar

    The last test fails:

    Testing to see if you tried a certain short-cut
    [1,'[',']'] same as ['[',']',1]: False should equal True

    So, that means the solution should also consider arrays with similar nested structure when run backwards.

    But if I modify my solution to accomodate that, I get an error for this test:

    [1,[1,1]] not same as [[2,2],2]: True should equal False

    What's going on? What am I missing?