[Community Puzzle] Treasure hunt

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @lhm,validated by @DGITAlley,@vpoulailleau and @natrian.
If you have any issues, feel free to ping them.

My solution is accepted, but I know that it is not a good solution (and it failed the 5th test case). Check the validator to fix this bug. If you have any more question, just write me, :slight_smile:

path finding in easy? isnt it too much?

10 Likes

Hello @DGITAlley ,
I implemented a recursive function and solved all testcases, but do not pass the Validator#1. I have no idea why. How can I find out what the problem is?

1 Like

Hi @Duck8008135 ,

With expert mode enabled in your settings, try the following custom input test case (it is not validator #1 but it is very similar) :

3 3
X##
 8#
2 7

Expected output : 15

4 Likes

@b0n5a1 thanks, found my error.
I had an error like this in my function: copy_list = list instead of copy_list = list.copy()

2 Likes

Yeah how is this easy? How to determine path on first try??

Edit: nvm its finding the maximum.Still.

Hello everyone ! I am working on Treasure Hunt. I have some issues because I am first finding where “X” is thanks to a list. I did it in Python, it works well for the first test, but it “takes too much time” for the other tests (2 “for” loops and 1 while or if). It forces me to do it otherwise but for now, I don’t know how to start my way from “X” without knowing its coordinates in the map.
Could you help me please ?

Thanks :slight_smile:

As you are reading the inputs line by line, you should at the same time count which line it is. When you get to the line which contains “X”, you check at which position it is in that line. Combining the two pieces of information together, you get to know the coordinates of “X”. Basically, the above can be achieved with 1 or 2 for-loops.

1 Like

I think this is a pretty hard problem for beginners and should probably be classified as Medium.
(I solved this with a recursive search)

2 Likes

It definetly not an easy problem and it should be marked as recursion too because everyone solve it that way. Not the level of an easy problem

1 Like

I didn’t use recursion in my solution.

1 Like

I didn’t use recursion either, and also I think this puzzle could become a lot cooler if the post-submission benchmark pushed the limits a little.

In university we’d often get a “training set” of problems that we could code against, but then the (hidden) evaluation set would include corner cases, degenerate examples etc.

I’ve looked at a few solutions here and indeed I see a lot of recursion going on. Would be cool if the hidden test set could just throw a map of 1000x1000 in there to see which solutions hold up.
Likewise, my queue based solution is definitely extremely memory hungry (I basically treated the whole thing as an abstract state search) so it might fall down for larger instances of the problem as well.

Plus, every solution I have seen does an exhaustive search of the state space, which might make them slow in big and degenerate examples.

Even though this is an “easy” puzzle to solve, it’s actually pretty interesting to solve it well. I think generally the scoring post-submission could reflect that. If we’re worried about frustrating beginners (which is a valid concern) then these hard cases could be listed separately on the scoring page, with a note “These are hard stretch goals. Come back later to finish these off.”

Or there could just be a “v2” of this puzzle where the test set is much, much harder.

If validator 1 is similar to this then I think it is not fear fro mthe creator as the test is not giving any situation like this one.
Here you have to look for various directions by going back to initial map as marking last positions would block you to get 7 +8 if you pass throug 2 first.
Any of the tests are requiring that, it is then the reason of my fail…
Please care on generating similar constraints on test than on validators else people can’t develop correctly…

Yes but…say that directly to lazy creator and validators who did not care about checking and testing…not to me.

I really enjoyed this problem, but (IMO) there is no way this should be classified as easy. I didn’t use recursion - I used a queue. I used a DFS path finding approach, but you have to keep track of the max treasure recovered so far at each node and also whether or not the path tries to include an already visited node. How is the skill “Arrays” the only thing listed? That makes no sense.