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 9 characters in body
Source Link
digEmAll
  • 5.1k
  • 15
  • 22

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

Note:
5 bytes are wasted because in rankrank function the default handling strategy forin case of ties is "average their ranks" instead of any other of the other possibilities... argh!

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

Note:
5 bytes are wasted because in rank function the default handling strategy for ties is "average their ranks" instead of any other of the possibilities... argh!

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

Note:
5 bytes are wasted because in rank function the default handling strategy in case of ties is "average their ranks" instead of any of the other possibilities... argh!

added 173 characters in body
Source Link
digEmAll
  • 5.1k
  • 15
  • 22

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

Note:
5 bytes are wasted because in rank function the default handling strategy for ties is "average their ranks" instead of any other of the possibilities... argh!

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

Note:
5 bytes are wasted because in rank function the default handling strategy for ties is "average their ranks" instead of any other of the possibilities... argh!

added 6 characters in body
Source Link
digEmAll
  • 5.1k
  • 15
  • 22

R, (削除) 23 (削除ここまで) 2227 bytes

any(rank(x<-scan(),,'f')-x)

Try it online! Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

R, (削除) 23 (削除ここまで) 22 bytes

any(rank(x<-scan())-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

R, 27 bytes

any(rank(x<-scan(),,'f')-x)

Try it online!

Returns FALSE for Truthy, TRUE for FALSY (just to shave one byte)

Explanation:

If the array containing the rank of each value is equal to the input array, then it's a permutation of 1..n

added 102 characters in body
Source Link
digEmAll
  • 5.1k
  • 15
  • 22
Loading
Source Link
digEmAll
  • 5.1k
  • 15
  • 22
Loading

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