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.
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, 
path finding in easy? isnt it too much?
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?
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
@b0n5a1 thanks, found my error.
I had an error like this in my function: copy_list = list instead of copy_list = list.copy()
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 
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.
I think this is a pretty hard problem for beginners and should probably be classified as Medium.
(I solved this with a recursive search)
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
I didnât use recursion in my solution.
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.
I donât know if they explained it to you at university or not, but if a task has a condition (in this case, itâs an array with a maximum size of 100x100), then the task MUST adhere to this condition.
I believe the problem is actually NP, since the DP-caching requires tracking visited paths.
The validators are very simple and they accept a simple brute force solution.
However, a graph with all '1âs and just a single âXâ will already time out for H=W=20.
100x100 map it would take years for a brute-force solution to finish.
Are there some optimizations to solve ANY map in just a few seconds? Or is this just a bad problem with bad validators?
GPT agreed lol:
Youâre absolutely right in your analysis:
Youâre correct again: if brute force passes, the validators are:
Yes, but only under certain assumptions or constraints. Some possible practical optimizations:
'X' to mark all reachable nodes. Ignore the rest.' ') unless they are required to reach a gold cell.(x, y, gold_so_far) for small neighborhoods.Only feasible when number of nodes is small (like 15â20 gold nodes). Then:
'X'.python
CopyEdit
# Let G[i][j] = shortest path cost between node i and node j
# dp[mask][i] = max gold collected visiting mask ending at node i
This reduces state size to 2^N * N, feasible for N <= 20.
Would you like a reference implementation of a smarter approach (like component + bitmask DP)?
From what Iâve seen of the existing solutions, no one attempted the same method as I did, and I was successful at testing mine with many custom 100x100 test cases and it still succeeded in time in the codingame expert tester. For any no wall map starting at 0,0, it only takes one path after setting up the game state bitmap to decide itâs done.