Skip to main content
added 424 characters in body
Source Link
Ted
  • 2.4k
  • 7
  • 33

Update 2025-06-04: Thanks for the submissions everyone! It seems like a lot of the solutions are quite slow / timeout for the 100 length test case, so I don't think any will be able to do the 10k. Probably my fault for not specifying in the rules originally, but if anyone can create a more efficient solution which can solve the 10k within the time limit applied by TIO (60s) that would be the winner in my eyes. I may have a crack at it myself but I'm quite busy at the moment. I believe treating this as a graph problem will be helpful.


You will be provided with a list of numbers. Your goal is to visit each index of the list once (and only once). Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

You will be provided with a list of numbers. Your goal is to visit each index of the list once (and only once). Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

Update 2025-06-04: Thanks for the submissions everyone! It seems like a lot of the solutions are quite slow / timeout for the 100 length test case, so I don't think any will be able to do the 10k. Probably my fault for not specifying in the rules originally, but if anyone can create a more efficient solution which can solve the 10k within the time limit applied by TIO (60s) that would be the winner in my eyes. I may have a crack at it myself but I'm quite busy at the moment. I believe treating this as a graph problem will be helpful.


You will be provided with a list of numbers. Your goal is to visit each index of the list once (and only once). Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

Became Hot Network Question
added 235 characters in body
Source Link
Ted
  • 2.4k
  • 7
  • 33

Code golf scoring

  • Code golf scoring
  • You may start at any index
  • You do not need to move off the finally visited element.
  • An element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)
  • You may only visit each element once

Here are some test cases with 10k elements. The first line is a traversible list. The second line is the order in which the first line can be traversed. The third line is a non-traversible list.

Code golf scoring

  • You may start at any index
  • You do not need to move off the finally visited element.
  • An element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)
  • You may only visit each element once
  • Code golf scoring
  • You may start at any index
  • You do not need to move off the finally visited element.
  • An element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)
  • You may only visit each element once

Here are some test cases with 10k elements. The first line is a traversible list. The second line is the order in which the first line can be traversed. The third line is a non-traversible list.

added 40 characters in body
Source Link
Ted
  • 2.4k
  • 7
  • 33

You will be provided with a list of numbers. Your goal is to visit each index of the list once (and only once). Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

  • You may start at any index
  • You do not need to move off the finally visited element.
  • anAn element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)
  • You may only visit each element once

You will be provided with a list of numbers. Your goal is to visit each index of the list. Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

  • You may start at any index
  • You do not need to move off the finally visited element.
  • an element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)

You will be provided with a list of numbers. Your goal is to visit each index of the list once (and only once). Starting from some element, you must look at the value stored in that element, and then move that many spaces left or right (if it is possible to do so within the bounds of the list).

  • You may start at any index
  • You do not need to move off the finally visited element.
  • An element is "visited" once it has been landed on (i.e.: passing over an element doesn't count as visiting it)
  • You may only visit each element once
added 115 characters in body
Source Link
Ted
  • 2.4k
  • 7
  • 33
Loading
edited tags
Source Link
Ted
  • 2.4k
  • 7
  • 33
Loading
edited tags
Link
Ted
  • 2.4k
  • 7
  • 33
Loading
Source Link
Ted
  • 2.4k
  • 7
  • 33
Loading