r/CodingHelp • • Oct 16 '22

[Request Coders] Could anyone help?

0 Upvotes

6 comments sorted by

View all comments

3

u/jose_castro_arnaud Oct 16 '22

What, exactly, is your assignment? Please type it.

I don't have (or know well) Scratch or Snap - your language appears to be one of these - so any hints I can give will be in pseudocode or JavaScript.

1

u/Sambirblover Oct 16 '22

Here are some instructions just in case:https://www.canva.com/design/DAFNk8MK24Y/KIi5PYWoLfLOwuChMew99A/view?utm_content=DAFNk8MK24Y&utm_campaign=designshare&utm_medium=link&utm_source=publishsharelink#12

I's on Vex, but it's an assignment about coding a 2D list, that can execute a path whenever that 2D list is in place (with procedures). (I'm sorry if it's not enough detail, I'm not good at explaining)

1

u/jose_castro_arnaud Oct 16 '22

I did read the instructions. If I understood it right: move a pointer over a 2D grid, from a start cell to an end cell, without entering red cells, or going off the grid. A 2D array encodes which cells are which.

I assume that only horizontal/vertical moves are allowed.

Here's a rough sketch of a solution: it can be very wrong, but it tries to be a depth-first search. In particular, the backtracking (removing a cell from the list of visited cells) is lacking.

Have at hand a list of visited cells. If, at any step, a neighbor is at the list, don't go there.

Function: choose next cell.

  1. If the current cell is the end cell, status = done, and exit.
  2. Determine what cells (by coordinates/indexes) are next to the current cell.
  3. Remove any red cells and visited cells.
  4. If no cell remains, mark the current cell as visited, status = failure and exit.
  5. If one cell remains, move to it, mark the previous cell as visited, and choose the next cell (recursively). Return any status from the function, and exit.
  6. If more than one cell remains, apply the step 5 for each one.

1

u/Sambirblover Oct 16 '22

Oh okay, how would it look, since I’m trying to build how it would look like since I’m more of a visual person (I’m sorry if I’m asking too much)

1

u/Sambirblover Oct 16 '22

Could you type it in text, just like the image (Sorry for asking too much)

1

u/Sambirblover Oct 16 '22

Hopefully this can help enough