Skip to main content
added 1003 characters in body
Source Link
dingledooper
  • 23.4k
  • 1
  • 40
  • 130

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to len(a)-1.

Python 3, 30 bytes

As @ovs suggested, we can save a byte by switching the definition of truthy and falsey. A valid permutation returns a falsey value, and truthy otherwise.

lambda a:{*a}^{*range(len(a))} 

Try it online!

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to len(a)-1.

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to len(a)-1.

Python 3, 30 bytes

As @ovs suggested, we can save a byte by switching the definition of truthy and falsey. A valid permutation returns a falsey value, and truthy otherwise.

lambda a:{*a}^{*range(len(a))} 

Try it online!

grammar
Source Link
dingledooper
  • 23.4k
  • 1
  • 40
  • 130

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to the len(a)-1.

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to the len(a)-1.

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to len(a)-1.

added 29 characters in body
Source Link
dingledooper
  • 23.4k
  • 1
  • 40
  • 130

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 10 to the length of \$ a \$len(a)-1.

Python 3, 31 bytes

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 1 to the length of \$ a \$.

Python 3, 31 bytes

Input is \$ 0 \$-indexed.

lambda a:{*a}=={*range(len(a))} 

Try it online!

This is the most obvious implementation I could think of. It compares the set of \$ a \$ to the set of numbers from 0 to the len(a)-1.

Source Link
dingledooper
  • 23.4k
  • 1
  • 40
  • 130
Loading