Skip to main content
Added a function signature to conform to rules
Source Link

Uiua, 77 bytes 9 bytes (SBCS)

<+|1<+/∘⊏⍖. 

Try it online!Try it online!

Explanation:

## (Top of stack on the left) ## Stack: [1 3 2]   . # Copy input ## Stack: [1 3 2] [1 3 2]   ⍖ # Index array by descending value ## Stack: [1 2 0] [1 3 2]   ⊏ # Order the input ## Stack: [3 2 1]   /∘ # Put the elements on the stack ## Stack: 1 2 3   + # Add the top two items ## Stack: 3 3  < # Test whether the second item is less than the first ## Stack: 0 |1 # Function signature 

In the example, I've had to "spell out" theEdit: Added function each time rather than use a binding, because it would require 5 moresignature (2 extra bytes) to annotate the signature:conform to rules. Thanks to @Bubbler.

Triangle ← (|1 <+/∘⊏⍖.) 

Uiua, 7 bytes (SBCS)

<+/∘⊏⍖. 

Try it online!

Explanation:

## (Top of stack on the left) ## Stack: [1 3 2] . # Copy input ## Stack: [1 3 2] [1 3 2] ⍖ # Index array by descending value ## Stack: [1 2 0] [1 3 2] ⊏ # Order the input ## Stack: [3 2 1] /∘ # Put the elements on the stack ## Stack: 1 2 3 + # Add the top two items ## Stack: 3 3 < # Test whether the second item is less than the first ## Stack: 0 

In the example, I've had to "spell out" the function each time rather than use a binding, because it would require 5 more bytes to annotate the signature:

Triangle ← (|1 <+/∘⊏⍖.) 

Uiua, 7 bytes 9 bytes (SBCS)

|1<+/∘⊏⍖. 

Try it online!

Explanation:

## (Top of stack on the left) ## Stack: [1 3 2]   . # Copy input ## Stack: [1 3 2] [1 3 2]   ⍖ # Index array by descending value ## Stack: [1 2 0] [1 3 2]   ⊏ # Order the input ## Stack: [3 2 1]   /∘ # Put the elements on the stack ## Stack: 1 2 3   + # Add the top two items ## Stack: 3 3  < # Test whether the second item is less than the first ## Stack: 0 |1 # Function signature 

Edit: Added function signature (2 extra bytes) to conform to rules. Thanks to @Bubbler.

Source Link

Uiua, 7 bytes (SBCS)

<+/∘⊏⍖. 

Try it online!

Explanation:

## (Top of stack on the left) ## Stack: [1 3 2] . # Copy input ## Stack: [1 3 2] [1 3 2] ⍖ # Index array by descending value ## Stack: [1 2 0] [1 3 2] ⊏ # Order the input ## Stack: [3 2 1] /∘ # Put the elements on the stack ## Stack: 1 2 3 + # Add the top two items ## Stack: 3 3 < # Test whether the second item is less than the first ## Stack: 0 

In the example, I've had to "spell out" the function each time rather than use a binding, because it would require 5 more bytes to annotate the signature:

Triangle ← (|1 <+/∘⊏⍖.)