Skip to main content
9 of 14
added 105 characters in body
noodle person
  • 10.3k
  • 1
  • 22
  • 76

Uiua, 46 44 42 40 39 bytes

crossed out 44 is still regular 44 :(

⊏↧5/+×+1⇡4⇌=0[⍉.⊞⟜⊃-+.]-⇡+1×2.:$  /\-|O

Try it! I’m submitting this on the day of the 2024 solar eclipse, which is fitting for a challenge about the sun.

I also like that all of my improvements have been by 2 bytes each :) This time I only saved a single byte. Still, 1 is better than 0!

As of my revision 42 → 40 bytes, this borrows some logic from randomra’s very clever J solution. This still isn’t a direct port as some parts didn’t translate so well to Uiua.

I also have a 40 bytes solution which doesn’t do any porting:

⊏↧5/+×+1⇡4[⍉,⇌,]↯⧻.:⊞=.⟜=⇡+1×2.:$  -/|\O

Try it!

Explanation of the 40 bytes:

Consider the input 3. We double this and add 1 to get the side length 7.

From this we start with the identity matrix, and a reversed copy:

0 0 0 0 0 0 1    1 0 0 0 0 0 0
0 0 0 0 0 1 0    0 1 0 0 0 0 0
0 0 0 0 1 0 0    0 0 1 0 0 0 0
0 0 0 1 0 0 0    0 0 0 1 0 0 0
0 0 1 0 0 0 0    0 0 0 0 1 0 0
0 1 0 0 0 0 0    0 0 0 0 0 1 0
1 0 0 0 0 0 0    0 0 0 0 0 0 1

Also make the array of this many zeros with a 1 at the position of the original input:

0 0 0 1 0 0 0

Create a square matrix of this, and a transposed copy:

0 0 0 0 0 0 0    0 0 0 1 0 0 0
0 0 0 0 0 0 0    0 0 0 1 0 0 0
0 0 0 0 0 0 0    0 0 0 1 0 0 0
1 1 1 1 1 1 1    0 0 0 1 0 0 0
0 0 0 0 0 0 0    0 0 0 1 0 0 0
0 0 0 0 0 0 0    0 0 0 1 0 0 0
0 0 0 0 0 0 0    0 0 0 1 0 0 0

Then we take these 4 matrices in an array and multiply them by 1, 2, 3, and 4 respectively:

0 0 0 1 0 0 0   0 0 0 0 0 0 0
0 0 0 1 0 0 0   0 0 0 0 0 0 0
0 0 0 1 0 0 0   0 0 0 0 0 0 0
0 0 0 1 0 0 0   2 2 2 2 2 2 2
0 0 0 1 0 0 0   0 0 0 0 0 0 0
0 0 0 1 0 0 0   0 0 0 0 0 0 0
0 0 0 1 0 0 0   0 0 0 0 0 0 0

3 0 0 0 0 0 0   0 0 0 0 0 0 4
0 3 0 0 0 0 0   0 0 0 0 0 4 0
0 0 3 0 0 0 0   0 0 0 0 4 0 0
0 0 0 3 0 0 0   0 0 0 4 0 0 0
0 0 0 0 3 0 0   0 0 4 0 0 0 0
0 0 0 0 0 3 0   0 4 0 0 0 0 0
0 0 0 0 0 0 3   4 0 0 0 0 0 0

Sum them all together:

3 0 0  1 0 0 4  
0 3 0  1 0 4 0  
0 0 3  1 4 0 0  
2 2 2 10 2 2 2 
0 0 4  1 3 0 0  
0 4 0  1 0 3 0
4 0 0  1 0 0 3

We’re going to index these numbers into a string to get each character, and that 10 is going to get in the way, so take the minimum of the results and 5:

3 0 0 1 0 0 4  
0 3 0 1 0 4 0  
0 0 3 1 4 0 0  
2 2 2 5 2 2 2 
0 0 4 1 3 0 0  
0 4 0 1 0 3 0
4 0 0 1 0 0 3

Finally index these into a string so that 0 becomes a space, 1 becomes |, 2 becomes -, 3 becomes \, 4 becomes /, and 5 becomes O:

\  |  /
 \ | / 
  \|/  
---O---
  /|\  
 / | \ 
/  |  \
noodle person
  • 10.3k
  • 1
  • 22
  • 76