3 kyu

Path Finder #3: the Alpinist

1,270 of 3,193evk
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • MohamDah Avatar

    Had to learn Dijkstra's algorithm and Min Heap for this. Great kata.

  • ArpadGBondor Avatar

    The tests passed, but I keep getting this warning.

    tests/Fixture.cs(125,23): warning CS0659: 'SolutionTest.RefFinder.Tup' overrides Object.Equals(object o) but does not override Object.GetHashCode()

    Am I doing something wrong?

  • riggedveda Avatar

    I have a 100 test cases pass before I hit the timeout. Just to get a sense of how close I am, how many total tests are there? 7 initial + 100 random, or much more than that?

  • Ubzugajir Avatar

    This comment has been hidden.

  • artem-totality Avatar

    It has been interesting to learn and apply graph algoritm!

  • PagetWGHS Avatar

    Hmm. I have an A* solution that is nice and quick, and passes the vast majority of tests, but occasionally fails to produce the right answer, and when it fails the given answer is always 2 higher than the correct answer!

    I've been going crazy trying to work out what the common factor is on the failed tests. Why would it always be 2 out?!

  • maartene Avatar

    A Swift port would be welcome please. :)

  • gtcar1984 Avatar

    Please, help. I don´t know if its a language barrier or if I'm not that familiaryzed with this kind of problem, but I can't understand what kind of data I'm recieving a what I have to find.

  • zwhy Avatar

    I'd love some help from any Rubyists here for this kata!

    How do I get someone to look at my code? Do I just post it here?

    Any help appreciated!

  • Late347 Avatar

    does up and down climbs count equal weight of difference if starting from 9 -> 8 -> 7 differences would be still = 3 between these?

    is it the same as going from 7->8->7 differences would still be 3?

  • zwhy Avatar

    Everything is passing on the final tests, except there is always just one of the random ones failing. Yet all the other random ones pass.

    e.g. 19 random ones with maze row length up to the mid-20's will pass, then 1 maze with length similar to this will fail. And next time, a random test with maze of the same size as the previous failure will pass, but a maze of different length will fail. And the failure is always just off the mark by 1-5 ish.

    (by row length, I mean N)

    Something is not right here, that doesn't make sense?

    I've spent ages on this, (and have learned a bunch about different sorting algorithms so I've really enjoyed doing it) but now I just really want to submit it. Is there some condition I've not covered? How do I get someone to look at my code? Do I just post it here?

    Any help appreciated! I'm coding in Ruby. Thanks in advance.

  • gilbertgeorge Avatar

    Rust translation

    Available for review.

  • Quark Fox Avatar

    It was a nice kata! Learned in the process! Thanks evk, Thanks Hobovsky!!

  • Quark Fox Avatar

    trying to solve this kata in two ways, about 75% passing tests, those failing are deflected by 2 mostly, one or two are 4, don't understand what am i doing wrong!!!

  • xenois Avatar

    After hours of trying to optimize my algo to pass the "timeout" error, I came to the conclusion that Javascript unshift sucks

  • Sterbanchik Avatar

    I'm confused. My code passes all given sample tests but fails on random ones. What could be the problem?

  • bocherry Avatar

    There seems to be an issue with Python implementation that is working and solving on my local machine but not on the server. Can someone give me a hand? :-)

  • Madjosz Avatar
  • godwinko Avatar

    Clojure translation.

    Please review & approve, thanks a lot!!

  • mconatser Avatar

    On the js version of this my code passes tests fine until the big mazes. Mine finishes quickly enough with my implementation but I always end up with a little bit smaller final climb round than the expected. Does anyone have any ideas why that might be?

  • hua-zhi-wan Avatar

    DP is totally WRONG!

  • Ognian Mirev Avatar

    Well I'm clearly not understanding something.

    Why is this supposed to be 7 climb rounds?

    1

    20

    79

    2-1 + 7-2 + 9-7 = 8 by my logic.

  • WHMeng123 Avatar

    This comment has been hidden.

  • amir650 Avatar

    This comment has been hidden.

  • dorku Avatar

    Nice kata, just a small hint for people who are getting timeouts: A simple depth first search of breadth first search won't work. Timeout tests are designed to eliminate them.

  • Lip_6 Avatar

    Well... I found this one pretty tough

  • Persa Avatar

    This comment has been hidden.

  • mounim.ayoub Avatar

    Very nice kata, and very nice series as well

  • billgewrgoulas Avatar

    tricky description but the problem is way easier than it seems. All in all a very enjoyable kata!

  • schebotar Avatar

    I implemeted simple Dijkstra algorithm and it works fine for little test cases. But it is not fast enough for random test. Should I try Binary heap for Dijkstra or there is a better way?

  • brokenelevator Avatar

    I think it might be helpful to add below maze to basic tests.
    It would cover most/all bases apart from performance.
    At the very least, it would have been for me (in C++).

    707777
    707007
    707077
    707070
    707077
    777007

    Answer: 0

  • TTT_master Avatar

    99X99 maze is the real problem. Call stack gonna crash. So cycle takes more then 12s to do it and then throws an error message. Have no idea how to do it. Because we gona check all the paths to know the shortest.

  • markkraay Avatar

    Any suggestions for debugging? My tests seem to be failing one particular type of input.

  • brrandon13 Avatar

    This comment has been hidden.

  • fisicoedu Avatar

    I didn't understand what the kata is asking me to do :(

  • hugo.probo Avatar

    Did anyone has passed this using C#? I got TLE when at least more than 99x99 size. Or I should use such more optimize language like C++.

    May I know the maximum size for test case?

  • Tigerhub779 Avatar

    This comment has been hidden.

  • kuchaguangjie Avatar

    This serial is so well designed to guide programmer to Graph searching algorithms, really nice !!!

    BTW, wondering why I get 182 points for a 3kyu kata ... shouldn't it be 30 ?

  • Marcel1971 Avatar

    I want to like this kata. But I don't understand why I have to manipulate strings and deal with newline characters in the input. It distracts from the problem at hand. (C++)

  • JaywalkerZA Avatar

    I really don't fully understand the problem, and I think I need some help. My understanding is that the grid is a top-down view of a map, and the cells with numbers on them are showing their "altitude". So assuming my understanding of the problem is correct, the simplest of tests is expecting the following to return 2:

    010 010 010

    But I can only see how this could return 1. To get from 0,0 to n-1,n-1 you only need to climb once. Please can someone help me understand the question better?

  • johndoe235 Avatar

    I need some more clarification on "Number of climb rounds between adjacent locations is defined as difference of location altitudes (ascending or descending).".I'm looking at the test examples and I still don't get it.I know that I can solve it but I just don't understand what is being asked of me.

  • Toemmsche Avatar

    This comment has been hidden.

  • Wicktor Avatar

    This is a bit stupid, I've change back to Java8, so that way I don't get the time out. At least not always. I am quite sure the solutions runtime are quite different on each platform.

    Also, the same code passes 3 out of 5 times. There are many ways I can further optimize the code, but that are some trade of. And speed optimazition was not the initial goal of this kata, at least that was not market.

  • fibonaccios Avatar

    Awsome kata! Finished all the series and I learned some much from them...

  • DunetsNM Avatar

    Liked it. However I'm either missing a more efficient algorithm or Kata needs OPTIMIZATION tag. I coded a very concise solution using C# LINQ but had to optimize it down to low-level imperative style to fit the timeout, I passed it eventually in 7 sec but the idea and O(N) is about the same as in initial solution.

  • tortar Avatar

    I learnt a lot from this problem , thank you !

  • suarezali75 Avatar

    Pleasantly challenging!!! Good job evk!

  • coding106 Avatar

    I do not understand one of the sample test cases. How does the test case for f equal 0? Based off the description and other sample test cases, should it be 28? My reasoning is that you climb down 7, move right 2 to climb up 7 and climb down 7, move right until right boundary, then move down until you reach location (N-1)(N-1), where you climb up 7 and exit. So 7 + 7 + 7 + 7 = 28. Am I doing this wrong?

  • monstaber Avatar

    That was challenging but awesome.

    If anyone wants to do performance testing in their local environment, this can help:

    function testMap(size){ var hundo = ''; for (i=0; i<size; i++) { for (j=0; j<size; j++) { hundo += Math.floor(Math.random()*10); } hundo += '\n'; } console.log('Map of size '+size+'x'+size+' generated. Running pathFinder...'); console.time('pathFinder'); var answer = pathFinder(hundo.slice(0, -1)); console.timeEnd('pathFinder'); return answer; }

  • zanidip Avatar

    Got this error while attempting my code in Python : (7 Success, then this error :)


    Traceback (most recent call last): File "main.py", line 92, in do() File "main.py", line 91, in do Test.assert_equals(path_finder(field[:]), solution(field)) File "main.py", line 14, in solution moves = list(map(lambda x: [x[0], x[1], abs(tmap[x[0]][x[1]] - tmap[a][b]) + mmap[a][b]], moves)) TypeError: 'list' object is not callable


    Even with a minimalistic code like that I got the error :

    def path_finder(maze): return 0

  • egoods Avatar

    This comment has been hidden.

  • B4rrCH Avatar

    For the C# version, something seems broken for larger mazes. I can pass all the tests up to a 99x99 grid in about 2.2s, but I time out if I had not hardcoded an (obviously wrong) answer for larger mazes. My solution does work fine for a 100x100 maze I put in the sample tests manually (and completes that test in less than 100ms). I'm not sure where the issue lies.

  • DindonSauvage Avatar

    This comment has been hidden.

  • Sasha Markov Avatar

    What's the upper limit of N? (C#)

  • catsx3 Avatar

    For clarity, please update your instructions to note that the map is given as a string and not a matrix.

  • KataSideKick Avatar

    C# Translation added.Please review and approve~

  • StijnJvT Avatar

    This comment has been hidden.

  • WAXM62 Avatar

    my c++ code is returning "exit code 139" when i attempt. is that a timeout error?

  • Coldsewoo Avatar

    This comment has been hidden.

  • foxportal Avatar

    This comment has been hidden.

  • joebien Avatar

    Why are solutions locked for this and not the other Pathfinder problems? I'm so close.

  • smokinhiro Avatar

    I enjoyed this kata! I just did a C++ Translation. Your review is appreciated :)

  • TimoSci Avatar

    Is this Kata especially hard in Ruby because Ruby is slow? I have optimized and optimized and my code still isn't fast enough.

  • james-k-polk Avatar

    Description is complete gibberish. Any chance of getting someone who has completed this to rewrite it?

  • Blind4Basics Avatar

    ruby translation

    Please review and approve

  • nguyentrung0904 Avatar

    This comment has been hidden.

  • Calgiles3 Avatar

    Don't understand this TC: testArea(0, 777000 007000 007000 007000 007000 007777);

    By the Spec, shouldn't this return 28?

  • Torkel Avatar

    Python tests are too strict, or JS is too lenient..

  • bradfox2 Avatar

    This comment has been hidden.

  • Flooo Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    Java translation!

    Please review and approve (Note: I included my slight change of the description I suggested below, tell me if you want I remove it or not).

  • Blind4Basics Avatar
    • Same here about the formatting of the sample tests in python (multiline strings would be better)
    • that could be cool to give a bit more about the definition of the number of climb rounds...: maybe add descending or ascending in the description?
  • FArekkusu Avatar

    Python translation. Please, review it.

    NOTE: the amount of tests is tripled (3 tests per each size from 1x1 to 50x50). The validation function is not super efficient but it only takes 2700-2800 ms, therefore the actual time limit will be around 9200-9300 ms (the numbers are average, just in case I'd say the lower limit is around 9 sec). If you think I'm going overkill, I can make it lighter, but it would be too easy for a 3 kyu kata IMHO.

  • dayfine Avatar

    My code is not fast enough for the final large mazes. Any suggestion?

  • BAov Avatar

    Very good kata's series! It made me to study the algorithms for finding the shortest paths between nodes in graphs.

  • dcieslak Avatar

    Approved!