Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

This answer uses the same logic as @Theo's Python answer@Theo's Python answer, but with strings of "L" and "R" instead of numbers, as Scratch's (and thus tosh's) list capabilities are awful.

Now we get to the path generation code. It uses the same logic as @Theo's Python answer@Theo's Python answer, except with strings of "R" and "L" instead of numbers, and we use nested loops instead of list comprehensions.

This answer uses the same logic as @Theo's Python answer, but with strings of "L" and "R" instead of numbers, as Scratch's (and thus tosh's) list capabilities are awful.

Now we get to the path generation code. It uses the same logic as @Theo's Python answer, except with strings of "R" and "L" instead of numbers, and we use nested loops instead of list comprehensions.

This answer uses the same logic as @Theo's Python answer, but with strings of "L" and "R" instead of numbers, as Scratch's (and thus tosh's) list capabilities are awful.

Now we get to the path generation code. It uses the same logic as @Theo's Python answer, except with strings of "R" and "L" instead of numbers, and we use nested loops instead of list comprehensions.

Source Link
BookOwl
  • 301
  • 2
  • 8

tosh, 518 bytes

tosh is Scratch, but with text instead of blocks. At 518 bytes, this answer is probably even worse than Java.

This answer uses the same logic as @Theo's Python answer, but with strings of "L" and "R" instead of numbers, as Scratch's (and thus tosh's) list capabilities are awful.

You can run it as a Scratch project here. (tosh compiles to Scratch projects)

when flag clicked set path to "R" go to x: -50 y: 100 point in direction 90 pen down set pen size to 2 clear repeat 9 set path copy to path set path to join (path) "R" set i to length of path copy repeat length of path copy if letter i of path copy = "R" then set path to join (path) "L" else set path to join (path) "R" end change i by -1 end end set i to 0 repeat length of path change i by 1 if letter i of path = "R" then turn cw 90 degrees else turn ccw 90 degrees end move 7 steps end 

Explanation:

when flag clicked set path to "R" go to x: -50 y: 100 point in direction 90 pen down set pen size to 2 clear 

This first part makes the program run when the green flag is clicked (when flag clicked), sets the path variable to "R", and gets the sprite and stage in the proper state to be ready to draw.

repeat 9 set path copy to path set path to join (path) "R" set i to length of path copy repeat length of path copy if letter i of path copy = "R" then set path to join (path) "L" else set path to join (path) "R" end change i by -1 end end 

Now we get to the path generation code. It uses the same logic as @Theo's Python answer, except with strings of "R" and "L" instead of numbers, and we use nested loops instead of list comprehensions.

set i to 0 repeat length of path change i by 1 if letter i of path = "R" then turn cw 90 degrees else turn ccw 90 degrees end move 7 steps end 

Finally, we draw the path by going through each letter of the path variable and turning left or right depending on the letter.