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

Uiua, 46 44 … 35 34 bytes

crossed out 44 is still regular 44 :(

⊏↧5/◇+\+{⇌,¤,⊞=.⟜=}⇡+1×2.:$  -\|/O

Try it! I submitted this on the day of the 2024 solar eclipse, which is fitting for a challenge about the sun. (Edit - the eclipse was beautiful! I saw it at around 85%-90% coverage)

Certainly my most well-golfed Uiua submission to-date. I have had a lot of different ideas and methods to save bytes and frequently switched much of the approach around a lot, but finally I have this at a state where I'd be happy if I don't find anything more.

Omnikar's very clever idea in the Uiua discord to use /+\+ instead of multiplying each term by a different factor helped me save 3 bytes! 38 → 35

Explanation:

Note: This explanation is very slightly outdated, but the strategy is the same, just a few things shifted around.

Consider the input 3. We double this and add 1 to get the side length 7, and take the range from 0 up to it.

[0 1 2 3 4 5 6]

Underneath this we push a copy with a mask of where the original input appears, and a "fixed" (wrapped in an array) copy of that.

[0 0 0 1 0 0 0]    [[0 0 0 1 0 0 0]]    [0 1 2 3 4 5 6]

Using the range at the top of the stack, push the identity matrix and a reversed copy.

                                        [[1 0 0 0 0 0 0]   [[0 0 0 0 0 0 1]
                                         [0 1 0 0 0 0 0]    [0 0 0 0 0 1 0]
                                         [0 0 1 0 0 0 0]    [0 0 0 0 1 0 0]
[0 0 0 1 0 0 0]    [[0 0 0 1 0 0 0]]     [0 0 0 1 0 0 0]    [0 0 0 1 0 0 0]
                                         [0 0 0 0 1 0 0]    [0 0 1 0 0 0 0]
                                         [0 0 0 0 0 1 0]    [0 1 0 0 0 0 0]
                                         [0 0 0 0 0 0 1]]   [1 0 0 0 0 0 0]]

Take their cumulative sums:

[[0 0 0 0 0 0 1]   [[1 0 0 0 0 0 1]   [[1 0 0 0 0 0 1]   [[1 0 0 1 0 0 1]
 [0 0 0 0 0 1 0]    [0 1 0 0 0 1 0]    [0 1 0 0 0 1 0]    [0 1 0 1 0 1 0]
 [0 0 0 0 1 0 0]    [0 0 1 0 1 0 0]    [0 0 1 0 1 0 0]    [0 0 1 1 1 0 0]
 [0 0 0 1 0 0 0]    [0 0 0 2 0 0 0]    [1 1 1 3 1 1 1]    [1 1 1 4 1 1 1]
 [0 0 1 0 0 0 0]    [0 0 1 0 1 0 0]    [0 0 1 0 1 0 0]    [0 0 1 1 1 0 0]
 [0 1 0 0 0 0 0]    [0 1 0 0 0 1 0]    [0 1 0 0 0 1 0]    [0 1 0 1 0 1 0]
 [1 0 0 0 0 0 0]]   [1 0 0 0 0 0 1]]   [1 0 0 0 0 0 1]]   [1 0 0 1 0 0 1]]

Notice that adding the fixed version of the list adds to each column, while the non-fixed version adds to each row.

Now, we sum the cumulative sums:

[[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