+ 2

traverse(walk) matrix with tuple of indices

https://code.sololearn.com/c1cy7YgWB47T/?ref=app how would i be able to go from one index to another kind of confused as to how its done i know its just the (x,y) value + or - 1, but not sure on how to do it seems like it should be easy but it isnt this time i guess it gets kind of crazy with method above as you are dealing with 2 sets of nested list/tuple https://code.sololearn.com/c7A23933A4a4/?ref=app

12th Jul 2021, 2:54 PM
ren[paused]
ren[paused] - avatar
10 odpowiedzi
+ 7
ren[paused] , not quiet clear for me where your struggle is. ▪︎you have (in version 1 of your code) a list of tuples, where each tuple contains the indices that are needed when you want to address an element from the input list. ▪︎in the second version you have these indices in a dict. so what is missing now? can you describe what your code should do in general?
12th Jul 2021, 4:24 PM
Lothar
Lothar - avatar
+ 7
ren[paused] , i would like to recommend that you read the article from Stackoverflow as well: ▪︎ https://stackoverflow.com/questions/1620940/determining-neighbours-of-cell-two-dimensional-list#1621118
12th Jul 2021, 5:34 PM
Lothar
Lothar - avatar
+ 2
https://code.sololearn.com/ctZ9wzeh7eE8/?ref=app in general your idea is the gold standard. u must additionally check, if you leave the matrix with a move. so this code is an exot.
12th Jul 2021, 5:19 PM
Oma Falk
Oma Falk - avatar
+ 2
ren[paused] don't try! Try to become familiar with them. They are fast and yeees.... "precompiled". A coder recently was fired because of not using builtins. The code was regarded as low quality.
12th Jul 2021, 5:37 PM
Oma Falk
Oma Falk - avatar
+ 1
i kind of figured it out in 2.1 in order to explain this by accident but objective is this- but wonder if a better way exists example matrix [ [1,2,3], [4,5,6], [7,8,9] ] given a set of x,y indices figure out what numbers are adjacent up down left right to a number within the matrix. so if u want 5 in the matrix input would be (xindex,yindex) or (1,1). The result would be 2,4,6,8 as those are up down left right from that number. hope it helps hard for me to explain fully time constraint atm
12th Jul 2021, 4:51 PM
ren[paused]
ren[paused] - avatar
+ 1
thanks for the addl resources!!!
12th Jul 2021, 5:36 PM
ren[paused]
ren[paused] - avatar
12th Jul 2021, 3:59 PM
ren[paused]
ren[paused] - avatar
0
thanks for your input i am trying to accomplish without builtins
12th Jul 2021, 5:28 PM
ren[paused]
ren[paused] - avatar
0
its more thinking of constructs practice. i have a lot to learn im not planning on skipping anything :) i know this is not good in production :D
12th Jul 2021, 6:09 PM
ren[paused]
ren[paused] - avatar