Skip to main content
Commonmark migration
Source Link

Logo, 155 bytes

Graphical solution, implemented as a function

#Logo, 155 bytes ##Graphical solution, implemented as a function II retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

#Logo, 155 bytes ##Graphical solution, implemented as a function I retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

Logo, 155 bytes

Graphical solution, implemented as a function

I retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#Logo, 155 bytes ##Graphical solution, implemented as a function I retooled my answer for Alphabet TriangleAlphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

#Logo, 155 bytes ##Graphical solution, implemented as a function I retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

#Logo, 155 bytes ##Graphical solution, implemented as a function I retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes

Source Link
GuitarPicker
  • 1.1k
  • 7
  • 11

#Logo, 155 bytes ##Graphical solution, implemented as a function I retooled my answer for Alphabet Triangle and changed the angles around a bit. As before, r draws a line of characters. This time, the b function draws a box by drawing one straight edge and one diagonal, rotating, and repeating four times. This causes the diagonals to be drawn twice (on top of each other), but it was less code than handling it separately. This answer also properly handles even numbers. I had to add special handling for an input of 1 to prevent it from going forward.

I implemented it as a function, b which takes the size as an argument:

pu
to r:n:b:l repeat:n[rt:b label "A lt:b if repcount>1[fd:l]] end
to b:s
repeat 4[rt 90
r:s 90-heading 20 rt 135
r:s 90-heading 20*sqrt 2 rt 45]
end

Try it out on Calormen.com's Logo interpreter. To call it, append a line and call b in the following format:

b 7

Sample of size 7

... or try the sampler platter, which draws four samples in sizes 5, 7, 9, and 11, rotating 90 degrees in between:

repeat 4[
  b repcount*2+3
  rt 90
]

Sample of multiple sizes