Skip to main content
Commonmark migration
Source Link

#Befunge, 277 269 bytes

Befunge, 277 269 bytes

&6*4+00p&:55+*3+10p2%20pv@
6+5:g03%*54:::<<0+55p03:<<v%*54++55:\p04:**`+3g03g00`\g01+*3!g02\-*84g+3+!\%
48*+,1+:10g`!#^_$,1+:00g-|>30g:2+6%\3-!+3+g48*-\:2`\20g3*+10g\`*30g2`**40g!*+
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just merge the results.

So for each x,y coordinate that has to be output, we first need to determine what character should be rendered for an odd column, by mapping the x,y output coordinates to u,v coordinates in the cube diagram as follows:

u = x%20
v = (y+5)%6 + (y==0)

The addition of (y==0) is to handle the special case of the first line. But we also need to make sure we aren't rendering the last few lines at the bottom of the column, and the last few characters on the end of each row. This is achieved by multiplying output character with the expression:

(y > h-3) && (x > w-3*!(columns%2))

The !(columns%2) in the width calculation is because the amount we need to trim off the end is dependent on whether the total column count is even or odd.

We then do a second calculation to determine what character should be rendered for an even column, mapping the u,v coordinates as follows:

u = (x+10)%20
v = (y+2)%6 + (y==3)

This is the same basic calculation as used for the odd columns, but offset slightly. And as before, we need to make sure we don't render some of the characters on the boundaries - this time the first few lines at the top of the column, as well as some characters at the beginning and end of each row. The expression we multiply in this case is:

(y > 2) && (x > 2) && (x < w-3*(columns%2))

Having calculated these two potential output characters, the final value used is:

char1 + (char2 * !char1) + 32

In other words, if char1 is zero we need to output char2, otherwise we output char1. If both are non-zero, we're just going to output char1, but that's fine because they'd both be the same value anyway. Also note that these character values are offset by 32 (hence the addition of 32) so that zero will always end up as a space.

#Befunge, 277 269 bytes

&6*4+00p&:55+*3+10p2%20pv@
6+5:g03%*54:::<<0+55p03:<<v%*54++55:\p04:**`+3g03g00`\g01+*3!g02\-*84g+3+!\%
48*+,1+:10g`!#^_$,1+:00g-|>30g:2+6%\3-!+3+g48*-\:2`\20g3*+10g\`*30g2`**40g!*+
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just merge the results.

So for each x,y coordinate that has to be output, we first need to determine what character should be rendered for an odd column, by mapping the x,y output coordinates to u,v coordinates in the cube diagram as follows:

u = x%20
v = (y+5)%6 + (y==0)

The addition of (y==0) is to handle the special case of the first line. But we also need to make sure we aren't rendering the last few lines at the bottom of the column, and the last few characters on the end of each row. This is achieved by multiplying output character with the expression:

(y > h-3) && (x > w-3*!(columns%2))

The !(columns%2) in the width calculation is because the amount we need to trim off the end is dependent on whether the total column count is even or odd.

We then do a second calculation to determine what character should be rendered for an even column, mapping the u,v coordinates as follows:

u = (x+10)%20
v = (y+2)%6 + (y==3)

This is the same basic calculation as used for the odd columns, but offset slightly. And as before, we need to make sure we don't render some of the characters on the boundaries - this time the first few lines at the top of the column, as well as some characters at the beginning and end of each row. The expression we multiply in this case is:

(y > 2) && (x > 2) && (x < w-3*(columns%2))

Having calculated these two potential output characters, the final value used is:

char1 + (char2 * !char1) + 32

In other words, if char1 is zero we need to output char2, otherwise we output char1. If both are non-zero, we're just going to output char1, but that's fine because they'd both be the same value anyway. Also note that these character values are offset by 32 (hence the addition of 32) so that zero will always end up as a space.

Befunge, 277 269 bytes

&6*4+00p&:55+*3+10p2%20pv@
6+5:g03%*54:::<<0+55p03:<<v%*54++55:\p04:**`+3g03g00`\g01+*3!g02\-*84g+3+!\%
48*+,1+:10g`!#^_$,1+:00g-|>30g:2+6%\3-!+3+g48*-\:2`\20g3*+10g\`*30g2`**40g!*+
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just merge the results.

So for each x,y coordinate that has to be output, we first need to determine what character should be rendered for an odd column, by mapping the x,y output coordinates to u,v coordinates in the cube diagram as follows:

u = x%20
v = (y+5)%6 + (y==0)

The addition of (y==0) is to handle the special case of the first line. But we also need to make sure we aren't rendering the last few lines at the bottom of the column, and the last few characters on the end of each row. This is achieved by multiplying output character with the expression:

(y > h-3) && (x > w-3*!(columns%2))

The !(columns%2) in the width calculation is because the amount we need to trim off the end is dependent on whether the total column count is even or odd.

We then do a second calculation to determine what character should be rendered for an even column, mapping the u,v coordinates as follows:

u = (x+10)%20
v = (y+2)%6 + (y==3)

This is the same basic calculation as used for the odd columns, but offset slightly. And as before, we need to make sure we don't render some of the characters on the boundaries - this time the first few lines at the top of the column, as well as some characters at the beginning and end of each row. The expression we multiply in this case is:

(y > 2) && (x > 2) && (x < w-3*(columns%2))

Having calculated these two potential output characters, the final value used is:

char1 + (char2 * !char1) + 32

In other words, if char1 is zero we need to output char2, otherwise we output char1. If both are non-zero, we're just going to output char1, but that's fine because they'd both be the same value anyway. Also note that these character values are offset by 32 (hence the addition of 32) so that zero will always end up as a space.

Managed to save a few bytes, and added a more detailed explanation.
Source Link
James Holderness
  • 8.9k
  • 2
  • 23
  • 44

#Befunge, 277277 269 bytes

<  v0p02%2p01+3*+55&6*4+00p&:&p00+4*6&55+*3+10p2%20pv@
 @_>>6+5:30p55+0>>g03%*54:::45*%30g<<0+55p03:5+6%\!+3+g48*-\20g!3*+10g\`00g30g3+`**<<v%*54++55:40p\\p04:55++45*%v
  ^**`+3g03g00`\g01+*3!g02\-g00:+1*84g+3+!\%
48*+,$_^#`g011+:+1,+*84+*10g`!g04**`2g03*`\g01+*3g02\`2#^_$,1+:\00g-*84g+3+|>30g:2+6%\3-!+3+g48*-3\%6+2\:g03<2`\20g3*+10g\`*30g2`**40g!*+
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just dealmerge the results.

So for each x,y coordinate that has to be output, we first need to determine what character should be rendered for an odd column, by mapping the x,y output coordinates to u,v coordinates in the cube diagram as follows:

u = x%20
v = (y+5)%6 + (y==0)

The addition of (y==0) is to handle the special case of the first line. But we also need to make sure we aren't rendering the last few lines at the bottom of the column, and the last few characters on the end of each row. This is achieved by multiplying output character with the overlapexpression:

(y > h-3) && (x > w-3*!(columns%2))

The (which was fairly straightforward)!(columns%2) in the width calculation is because the amount we need to trim off the end is dependent on whether the total column count is even or odd.

There's still roomWe then do a second calculation to determine what character should be rendered for further golfingan even column, mapping the u,v coordinates as follows:

u = (x+10)%20
v = (y+2)%6 + (y==3)

This is the same basic calculation as used for the odd columns, but offset slightly. And as before, we need to make sure we don't render some of the characters on the boundaries - this time the first few lines at the top of the column, as well as some characters at the beginning and end of each row. The expression we multiply in this case is:

(y > 2) && (x > 2) && (x < w-3*(columns%2))

Having calculated these two potential output characters, the final value used is:

char1 + (char2 * !char1) + 32

In other words, if char1 is zero we need to output char2, otherwise we output char1. If both are non-zero, we're just going to output char1, but that's fine because they'd both be the same value anyway. Also note that these character values are offset by 32 (hence the addition of 32) so that zero will always end up as a startspace.

#Befunge, 277 bytes

<  v0p02%2p01+3*+55:&p00+4*6&
 @_>>:30p55+0>>:::45*%30g:5+6%\!+3+g48*-\20g!3*+10g\`00g30g3+`**:40p\:55++45*%v
  ^!-g00:+1,$_^#`g01:+1,+*84+*!g04**`2g03*`\g01+*3g02\`2:\-*84g+3+!-3\%6+2:g03<
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just deal with the overlap (which was fairly straightforward).

There's still room for further golfing, but this is a start.

#Befunge, 277 269 bytes

&6*4+00p&:55+*3+10p2%20pv@
6+5:g03%*54:::<<0+55p03:<<v%*54++55:\p04:**`+3g03g00`\g01+*3!g02\-*84g+3+!\%
48*+,1+:10g`!#^_$,1+:00g-|>30g:2+6%\3-!+3+g48*-\:2`\20g3*+10g\`*30g2`**40g!*+
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just merge the results.

So for each x,y coordinate that has to be output, we first need to determine what character should be rendered for an odd column, by mapping the x,y output coordinates to u,v coordinates in the cube diagram as follows:

u = x%20
v = (y+5)%6 + (y==0)

The addition of (y==0) is to handle the special case of the first line. But we also need to make sure we aren't rendering the last few lines at the bottom of the column, and the last few characters on the end of each row. This is achieved by multiplying output character with the expression:

(y > h-3) && (x > w-3*!(columns%2))

The !(columns%2) in the width calculation is because the amount we need to trim off the end is dependent on whether the total column count is even or odd.

We then do a second calculation to determine what character should be rendered for an even column, mapping the u,v coordinates as follows:

u = (x+10)%20
v = (y+2)%6 + (y==3)

This is the same basic calculation as used for the odd columns, but offset slightly. And as before, we need to make sure we don't render some of the characters on the boundaries - this time the first few lines at the top of the column, as well as some characters at the beginning and end of each row. The expression we multiply in this case is:

(y > 2) && (x > 2) && (x < w-3*(columns%2))

Having calculated these two potential output characters, the final value used is:

char1 + (char2 * !char1) + 32

In other words, if char1 is zero we need to output char2, otherwise we output char1. If both are non-zero, we're just going to output char1, but that's fine because they'd both be the same value anyway. Also note that these character values are offset by 32 (hence the addition of 32) so that zero will always end up as a space.

Source Link
James Holderness
  • 8.9k
  • 2
  • 23
  • 44

#Befunge, 277 bytes

<  v0p02%2p01+3*+55:&p00+4*6&
 @_>>:30p55+0>>:::45*%30g:5+6%\!+3+g48*-\20g!3*+10g\`00g30g3+`**:40p\:55++45*%v
  ^!-g00:+1,$_^#`g01:+1,+*84+*!g04**`2g03*`\g01+*3g02\`2:\-*84g+3+!-3\%6+2:g03<
  /\      \
 /  \      \
/    \ _____\
\    /      /
 \  /      /
  \/_____ /
    _____

Try it online!

This question looked deceptively easy, but the edge cases turned out to be more complicated than I had originally anticipated. The best approach I could come up with was to handle the odd and even columns as separate renderings, and then just deal with the overlap (which was fairly straightforward).

There's still room for further golfing, but this is a start.