Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 335 characters in body
Source Link
Sara J
  • 3.9k
  • 19
  • 38

jq, 20 bytes

[range(max)+1]==sort

Try it online!

Explanation

 max # Get the maximum of the input
 range( ) # Generate the non-negative integers below that
 +1 # Add 1 to each of them
[ ] # Collect as list
 sort # Sort the input list
 == # Compare the two lists

jq, 20 bytes

[range(max)+1]==sort

Try it online!

jq, 20 bytes

[range(max)+1]==sort

Try it online!

Explanation

 max # Get the maximum of the input
 range( ) # Generate the non-negative integers below that
 +1 # Add 1 to each of them
[ ] # Collect as list
 sort # Sort the input list
 == # Compare the two lists
Source Link
Sara J
  • 3.9k
  • 19
  • 38

jq, 20 bytes

[range(max)+1]==sort

Try it online!

AltStyle によって変換されたページ (->オリジナル) /