Skip to main content
edited body
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

APL, 18 16 bytes

{y[⍋y←∪,∘.×⍨⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

             ⍳⍵⍳⍵]}    ⍝ Get the integers from 1 to the input
         ∘.×⍨       ⍝ Compute the outer product of this with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue and saved 2 bytes thanks to Thomas Kwa!

APL, 18 16 bytes

{y[⍋y←∪,∘.×⍨⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

             ⍳⍵}    ⍝ Get the integers from 1 to the input
         ∘.×⍨       ⍝ Compute the outer product of this with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue and saved 2 bytes thanks to Thomas Kwa!

APL, 18 16 bytes

{y[⍋y←∪,∘.×⍨⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

             ⍳⍵]}   ⍝ Get the integers from 1 to the input
         ∘.×⍨       ⍝ Compute the outer product of this with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue and saved 2 bytes thanks to Thomas Kwa!

deleted 8 characters in body
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

APL, 1818 16 bytes

{y[⍋y←∪,x∘.×x←⍳⍵]×⍨⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

{y[⍋y←∪,x∘.×x←⍳⍵]}

             x←⍳⍵⍳⍵}   Define x to beGet the integers from 1 to the input
         x∘.××⍨       ⍝ Compute the outer product of xthis with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue and saved 2 bytes thanks to Thomas Kwa!

APL, 18 bytes

{y[⍋y←∪,x∘.×x←⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

{y[⍋y←∪,x∘.×x←⍳⍵]}

             x←⍳⍵}   Define x to be the integers from 1 to the input
         x∘.×       ⍝ Compute the outer product of x with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue thanks to Thomas Kwa!

APL, 18 16 bytes

{y[⍋y←∪,.×⍨⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

             ⍳⍵}     Get the integers from 1 to the input
         .×⍨       ⍝ Compute the outer product of this with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue and saved 2 bytes thanks to Thomas Kwa!

added 181 characters in body
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

APL, 1218 bytes

{y[⍋y←∪,x∘.×x←⍳⍵×x←⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

{y[⍋y←∪,x∘.×x←⍳⍵]}

             x←⍳⍵}  ⍝ Define x to be the integers from 1 to the input
         x∘.×       ⍝ Compute the outer product of x with itself
        ,           ⍝ Flatten into an array
{       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue thanks to Thomas Kwa!

APL, 12 bytes

{,x∘.×x←⍳⍵}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

       x←⍳⍵}  ⍝ Define x to be the integers from 1 to the input
   x∘.×       ⍝ Compute the outer product of x with itself
  ,           ⍝ Flatten into an array
{∪            ⍝ Select unique elements

APL, 18 bytes

{y[⍋y←∪,x∘.×x←⍳⍵]}

This is an unnamed monadic function. The output is in ascending order.

Explanation:

{y[⍋y←∪,x∘.×x←⍳⍵]}

             x←⍳⍵}  ⍝ Define x to be the integers from 1 to the input
         x∘.×       ⍝ Compute the outer product of x with itself
        ,           ⍝ Flatten into an array
       ∪            ⍝ Select unique elements
     y←             ⍝ Assign to y
 {y[⍋               ⍝ Sort ascending

Fixed an issue thanks to Thomas Kwa!

Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119
Loading