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

Uiua, 46 44 42 40 39 38 44 … 35 3534 bytes

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

Try it!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)

Explanation:

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

Uiua, 46 44 42 40 39 38 35 bytes

⊏↧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)

Explanation:

Uiua, 46 44 … 35 34 bytes

⊏↧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)

Explanation:

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

added 531 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76

Uiua, 46 44 42 40 39 3838 35 bytes

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

Try it!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)

At one point this borrowed some logic from randomra’s very clever J solutionCertainly 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 foundhave this at a shorter solution usingstate 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 method.factor helped me save 3 bytes! 38 → 35

Outdated explanationExplanation:

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]

FromUnderneath this we startpush a copy with a mask of where the identity matrixoriginal input appears, and a reversed"fixed" (wrapped in an array) copy: of that.

0[0 0 0 01 0 0 10]    1[[0 0 0 01 0 0 0
00]] 0 0 0 0[0 1 02 3 4 5 06]

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 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[[1 0 0 0 0 0 0]  0 0[[0 0 0 10 0 0 1]
0                                         [0 1 0 0 0 0 00]    0[0 0 0 0 0 1 00]
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 1 0 0 0 0]    [0 0 0 0 1 0 0 00]
0[0 0 0 01 0 0 00]    0[[0 0 0 1 0 0 0
00]] 0 0   [0 0 0 1 0 0 0]   0 [0 0 0 1 0 0 00]
1 1 1 1 1 1 1    0 0 0 1 0 0 0
0 0 0                       [0 0 0 0 1 0 0]   0 0[0 0 1 0 0 0 0]
0 0 0                                       [0 0 0 0 0 1 0]  0 0 0[0 1 0 0 0
0 0 0]
                                         [0 0 0 0 0 0 1]]   0[1 0 0 1 0 0 0 0]]

Then we take these 4 matrices in an array and multiply them by 1, 2, 3, and 4 respectivelyTake their cumulative sums:

0[[0 0 0 1 0 0 0 1]  0 0[[1 0 0 0 0 0
0 01]   [[1 0 10 0 0 0 1]  0 0[[1 0 0 01 0 0 1]
 [0 0 0 0 0 1 00] 0 0  [0 01 0 0 0 01 00] 0
0 0 0 [0 1 0 0 0 1 0] 2 2 2 2[0 21 20 21 0 1 0]
 [0 0 0 0 1 0 00] 0   0[0 0 01 0 01 0 0
00] 0   [0 0 1 0 01 0 0]  0 0 0[0 0 01 01 1 0 0]
0 [0 0 0 1 0 0 00]   0 0[0 0 0 02 0 0

3 00] 0 0 0 0[1 01 1 3 01 01 01] 0 0 0 [1 1 1 4 1 1 1]
0 3[0 0 01 0 0 0 0]  0 0 0[0 0 1 0 41 0
0 00] 3 0  [0 0 1 0 1 0 0]  0 0 0[0 0 41 01 1 0 0]
0 0[0 01 30 0 0 0 0]  0 0 0[0 41 0 0 0
0 01 00] 0 3 0 0[0 1 0 0 0 41 00] 0   [0 1 0 1 0 1 0]
0 0[1 0 0 0 30 0 0]]  0 4[1 0 0 0 0 0
0 1]]   [1 0 0 0 0 0 31]]   4[1 0 0 01 0 0 01]]

Sum them all togetherNotice 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[[3 0 0  1 0 0 4  4]
0 [0 3 0  1 0 4 0  0]
0 [0 0 3  1 4 0 0  0]
2 [2 2 2 10 2 2 2 2]
0 [0 0 4  1 3 0 0  0]
0 [0 4 0  1 0 3 00]
4 0[4 0 0 1 0 0 33]]
3[[3 0 0 1 0 0 4  4]
0 [0 3 0 1 0 4 0  0]
0 [0 0 3 1 4 0 0  0]
2 [2 2 2 5 2 2 2 2]
0 [0 0 4 1 3 0 0  0]
0 [0 4 0 1 0 3 00]
4 [4 0 0 1 0 0 33]]

Uiua, 46 44 42 40 39 38 bytes

⊏↧5/◇+×+1⇡4{⇌.⊞=.⊙⟜¤⟜=}⇡+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)

At one point this borrowed some logic from randomra’s very clever J solution, but I found a shorter solution using a different method.

Outdated explanation:

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

Uiua, 46 44 42 40 39 38 35 bytes

⊏↧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:

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]]
[[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]]
deleted 726 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76

Uiua, 46 44 42 40 3939 38 bytes

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

Try it! I’m submittingTry 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)

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,At one point this borrowsborrowed 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. (Keep in mind that although this submission is shorter than randomra's, that's not quite a fair comparison since that outputs to STDOUT and this returns a list of lines. J would save 6 bytes by outputting a character matrix.)

but I also havefound a 40 bytesshorter solution which doesn’t do any porting:

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

Try it!using a different method.

Explanation of the 40 bytesOutdated explanation:

Uiua, 46 44 42 40 39 bytes

⊏↧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. (Edit - the eclipse was beautiful! I saw it at around 85%-90% coverage)

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. (Keep in mind that although this submission is shorter than randomra's, that's not quite a fair comparison since that outputs to STDOUT and this returns a list of lines. J would save 6 bytes by outputting a character matrix.)

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:

Uiua, 46 44 42 40 39 38 bytes

⊏↧5/◇+×+1⇡4{⇌.⊞=.⊙⟜¤⟜=}⇡+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)

At one point this borrowed some logic from randomra’s very clever J solution, but I found a shorter solution using a different method.

Outdated explanation:

deleted 18 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 244 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 105 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 105 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 5 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 180 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 348 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 2098 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 101 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
added 6 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76
Loading