29
\$\begingroup\$

Input a non-empty array with \$n\$ positive integers. Test if the input array contains every integer in \$1\cdots n\$.

In case you prefer 0-indexed numbers, you may choose to input an array of non-negative integers, and test if the input array contains every integer in \$0\cdots (n-1)\$ instead. All testcases and formula listed below use 1-index. You may need to adjust them if you choose this option.

Input / Output

Input is an array \$A\$ with \$n\$ positive integers:

$$ A = \left[A_1,\dots,A_n\right] $$ $$ \forall i \in \left[1,\dots,n\right]: A_i>0 $$

Output if input \$A\$ satisfies:

$$ \forall i \in \left[1,\dots,n\right]: i \in A $$

Output would be two distinct values, or truthy vs falsy values (swap meaning of truthy / falsy is allowed).

Rules

  • This is , shortest code wins. And since this is code-golf, don't worry about time / memory complexity of your code. You may even timeout on TIO as long as your program works when giving it more time to run.

Testcases

Truthy

1
1,2
2,1
1,3,2
3,1,2
1,2,3,4,5,6,7,8,9,10,11,12
12,11,10,9,8,7,6,5,4,3,2,1
6,3,8,12,1,10,4,2,7,9,5,11
16,37,14,15,23,8,29,35,21,6,5,34,38,9,36,26,24,32,28,7,20,33,39,12,30,27,40,22,11,41,42,1,10,19,2,25,17,13,3,18,31,4

Falsy

2
12
1,1
1,3
2,3
3,3
2,1,3,2
1,4,3,1
4,1,2,4
1,2,2,5,5
1,3,3,3,5
8,7,5,3,4,1,6
5,7,1,4,6,1,8,3
6,3,5,4,7,1,8,1,2
6,5,3,8,2,7,9,4
1,1,1,1,1,1,1,1
1,5,9,13,11,7,3
14,6,12,4,10,8,16,2
34,33,38,17,35,11,36,31,28,14,6,15,18,2,19,40,29,41,9,1,27,23,20,32,26,25,37,8,13,30,39,7,5,3,21,4,11,16,10,22,12,24
38,27,20,23,31,6,2,24,21,31,33,7,26,12,14,17,3,2,28,31,5,23,28,27,37,32,7,39,22,6,35,42,19,3,35,17,35,40,22,13,27,7
\$\endgroup\$
10
  • \$\begingroup\$ is empty list falsy? \$\endgroup\$
    – Razetime
    Jun 24 at 6:45
  • 7
    \$\begingroup\$ @Razetime IMO, empty list should be truthy. But anyway, empty list is excluded from testcases, and it is undefined behavior to your program. \$\endgroup\$
    – tsh
    Jun 24 at 6:48
  • \$\begingroup\$ How do you feel about restricting to n<10? It would make the elements to check finite and all single digit. And that would allow lots of wacky tarpits to solve it and not require as high a computational class! I think the spirit would still be preserved, and I can’t think of any way it could be used to hardcode or “cheat” that wouldn’t just be longer than doing it “right,” for the languages that can do it. \$\endgroup\$
    – AviFS
    Jun 24 at 8:20
  • 2
    \$\begingroup\$ @AviFS If your language doesn't support decimal number I/O, you can use character value I/O. If it doesn't support that either, you can take it in binary or unary. Computational class is not a problem; taking lots of time or memory is allowed by default (even if it can't be run to completion realistically on any machine). You're even allowed to handwave the inputs exceeding the limit of the built-in integer representation. So I don't see any extra benefit of restricting the input size to <10. \$\endgroup\$
    – Bubbler
    Jun 24 at 9:13
  • 1
    \$\begingroup\$ Would outputting 0 for one result or any other integer for the other be acceptable? \$\endgroup\$
    – Shaggy
    Jun 24 at 14:03

40 Answers 40

13
\$\begingroup\$

J, 7 bytes

-:/:@/:

Try it online!

Ninja'd by hyper-neutrino :(

Takes zero-based input. Applying Grade Up twice to a vector gives a "ranking" of each element, so that 0 is the smallest, 1 is the next smallest, ... up to n-1, breaking ties by giving a smaller number to the one appearing first. A vector is a permutation if and only if the ranking is identical to itself.

J, 7 bytes

2|C.!.2

Try it online!

Takes zero-based input. C.!.2 is a built-in for "cycle parity". It gives 1 if a permutation has even number of swaps, -1 if odd, and 0 if not a valid permutation. I take it modulo 2 to convert all nonzero results to 1 (the only truthy value in J).

Even if error/non-error output were allowed, it is too bad that permutation-related built-ins A. and C. don't error on all possible non-permutations.

J, 7 bytes

#\-:/:~

Try it online!

Takes one-based input. #\ is a golfing trick for getting 1..n, which is compared to the sorted array /:~ of the original.


If output by erroring/non-erroring is allowed:

J, 3 bytes

C.~

Try it online!

Takes zero-based input. Abuses dyadic form of C., whose left argument must strictly be a permutation. It throws an index error otherwise.

\$\endgroup\$
13
\$\begingroup\$

Risky, 7 bytes 7 bytes and a palindrome

1_??!0:0!??_1

Try it online!

Explanation

1   sort
_
?         input
?     filter by
!       factorial
0         0
: =
0   range
!       length
?         input
?     find first number such that
_
1         1
\$\endgroup\$
12
\$\begingroup\$

Haskell (1 indexed), 29 bytes

Courtesy of AZTECCO

g l=all(`elem`l)[1..length l]

Try it online!

Haskell (0 indexed), 42 32 31 bytes

Lynn saved one byte with the pointfree solution.

all.(.fst).flip elem<*>zip[0..]

Try it online!

I tried a bunch of creative stuff with scans, folds and zips, but the boring solution ended up being the shortest.

Both of these check that every integer in the available range is in the list. The first is 1 to the length of the list, the second is 0 to 1 less than the length of the list.

\$\endgroup\$
8
  • \$\begingroup\$ There's a shorter solution without import :) \$\endgroup\$
    – xnor
    Jun 24 at 12:58
  • \$\begingroup\$ @xnor Ah indeed. And much shorter. \$\endgroup\$
    – Grain Ghost
    Jun 24 at 13:04
  • \$\begingroup\$ With sorting, this pointfree saves a byte, using flipped output: Try it online! \$\endgroup\$
    – xnor
    Jun 24 at 13:07
  • 1
    \$\begingroup\$ Looks like all.(.fst).flip elem<*>zip[0..] is a hair shorter. \$\endgroup\$
    – Lynn
    Jun 24 at 16:37
  • 2
    \$\begingroup\$ If I'm not missing something..Try it online! \$\endgroup\$
    – AZTECCO
    Jun 24 at 17:55
11
\$\begingroup\$

APL (Dyalog Unicode), 5 bytes

⊢≡⍋∘⍋

Try it online!

-4 bytes thanks to Bubbler by turning this into a train and via using ⍵≡ to match the whole array instead of ∧/⍵= to match element-wise and then reduce by AND.

⊢≡⍋∘⍋    Train
 ≡         Check equality between
⊢         (Right argument ⍵) and
  ⍋∘⍋    Composed function {⍋⍋⍵}; grade up twice

Grading up twice gives the minimum permutation of length X that has the same (non-strict) ordering as the original - so, if the permutation of the right order is the same as the original, then the original was that permutation and thus a permutation.

\$\endgroup\$
4
  • \$\begingroup\$ You can delete ∧/ and change = (element-wise equals) to (entire array match). The train version is ⊢≡⍋∘⍋. \$\endgroup\$
    – Bubbler
    Jun 24 at 6:39
  • \$\begingroup\$ @Bubbler Ah, I should've looked for that built-in instead of using ∧/= :P thanks! \$\endgroup\$
    – hyper-neutrino
    Jun 24 at 6:40
  • \$\begingroup\$ May I use this for APLcart? (This entails relinquishing all rights to the code.) \$\endgroup\$
    – Adám
    Jun 24 at 7:01
  • 2
    \$\begingroup\$ @Adám Sure, that's cool with me and I checked with Bubbler too :) \$\endgroup\$
    – hyper-neutrino
    Jun 24 at 14:54
11
\$\begingroup\$

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!

\$\endgroup\$
1
  • \$\begingroup\$ If you swap truthy and falsy outputs (as allowed in the post), the == can be a ^. \$\endgroup\$
    – ovs
    Jun 24 at 8:12
10
\$\begingroup\$

JavaScript (ES6), 30 bytes

Expects 0-indexed values. Returns a Boolean value.

a=>a.every(x=>(a[~x]^=1)/a[x])

Try it online!

Commented

We test whether all values are less than the length \$N\$ of the input array and make sure that there is no duplicate. Both conditions are satisfied iff the array consists of all values from \$0\$ to \$N-1\$.

a =>             // a[] = input array
  a.every(x =>   // For each value x in a[]:
    (a[~x] ^= 1) //   ~x is -x - 1, which is guaranteed to be negative
                 //   Therefore, a[~x] is a property (such as '-1') of
                 //   the underlying object of a[], which can be safely
                 //   used to store values that were already encountered
                 //   If a[~x] XOR 1 is not equal to 1, we have a
                 //   duplicate value
    / a[x]       //   We also make sure that a[x] is defined, which
                 //   means that x < a.length
                 //   The possible cases are:
                 //     1 / n, n > 0 is a truthy number  \__ success
                 //     1 / 0 is +Infinity (also truthy) /
                 //     1 / undefined is NaN (falsy)     \
                 //     0 / n, n > 0 is 0 (falsy)         |_ failed
                 //     0 / 0 is NaN (falsy)              |
                 //     0 / undefined is NaN (falsy)     /
  )              // End of every()
\$\endgroup\$
10
\$\begingroup\$

Julia 1.5, 6 bytes

This is a built-in, so it's quite easy for Julia

isperm

Use it like this: isperm([6,3,8,12,1,10,4,2,7,9,5,11])

\$\endgroup\$
1
  • 3
    \$\begingroup\$ That's almost Mathematica-level surprising! \$\endgroup\$
    – ojdo
    Jun 25 at 8:22
9
\$\begingroup\$

Zsh, 18 12 bytes

>$@;<{1..$#}

Attempt This Online!

Outputs via exit code: 0 for a permutation and 1 for not a permutation

Explanation:

  • >: create files called
    • $@: each command-line argument
  • {1..$#}: range from 1 to the number of command-line arguments
  • <: try to read from each of those numbers as a file

If any command fails, then that means one of the files in the range didn't exist, so it's not a valid permutation, and zsh will exit with status 1.

\$\endgroup\$
7
\$\begingroup\$

Factor + math.unicode, 24 23 bytes

[ dup length iota ⊃ ]

Try it online!

0-indexed to save a byte. Is the input a superset of \$[0, |input|)\$?

\$\endgroup\$
6
\$\begingroup\$

R, 26 24 bytes

-2 bytes thanks to pajonk.

all(seq(x<-scan())%in%x)

Try it online!

If input is of length at least 2, seq(x) outputs the integers from 1 to length(x); if input is of length 1, it outputs the integers from 1 to x. Return TRUE iff all those integers are elements of x.

\$\endgroup\$
3
  • \$\begingroup\$ I don't think the ! is necessary here. \$\endgroup\$
    – pajonk
    Jun 24 at 7:58
  • \$\begingroup\$ @pajonk Indeed, thanks! \$\endgroup\$ Jun 24 at 8:01
  • \$\begingroup\$ And now we can do all(seq(x<-scan())%in%x) \$\endgroup\$
    – pajonk
    Jun 24 at 8:02
6
\$\begingroup\$

Ruby, 21 bytes

->a{a|[*1..a.max]==a}

Try it online!

-1 byte thanks to ovs!

-3 bytes thanks to Razetime!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I'm not completely sure, but ->a{a|[*1..a.max]==a} might work. \$\endgroup\$
    – ovs
    Jun 24 at 8:19
  • \$\begingroup\$ @ovs seems to be working! \$\endgroup\$
    – user100752
    Jun 24 at 8:20
5
\$\begingroup\$

Python 3, 33 bytes

lambda x:max(*x,len(x))^len({*x})
  1. Check uniqueness: len(x) = len(set(x))
  2. For unique set: max(x) == len(x) iff x = 1...n

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Jelly, 3 bytes

Ṣ⁼J

Try it online!

Ṣ⁼J   Monadic Link
Ṣ     1-chain: sort the input
 ⁼J   2,1-chain: is (the input sorted) equal to (range on the length of the input)?
\$\endgroup\$
4
\$\begingroup\$

Brachylog, 3 bytes

o~⟦

Try it online!

0-indexed. Succeeds or fails.

o      The input sorted
 ~⟦    is the range from 0 to something inclusive.

Note that this can not be golfed to ⟦p with reversed input, as it fails to terminate for cases it should reject:

⟦     Choose an integer. Is the range from 0 to it inclusive
 p    a permutation of the input?
\$\endgroup\$
4
\$\begingroup\$

Pyth, 3 bytes

UIS

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Wow... I had a 6 byter, had no idea U had that use. Nice! \$\endgroup\$
    – hakr14
    Jun 24 at 17:19
4
\$\begingroup\$

Red, 46 bytes

func[a][i: 0 until[alter a i: 1 + i]single? a]

Try it online!

increments a counter as long as the counter is found in the list, and then checks it against the length.

1 = length? is used as a polyfill for single? in the latest Red version.

-5 bytes from tsh.

-5 bytes from Galen Ivanov.

\$\endgroup\$
5
  • \$\begingroup\$ Maybe i >(length? a)? \$\endgroup\$
    – tsh
    Jun 24 at 7:00
  • \$\begingroup\$ yes, it works. Thanks. \$\endgroup\$
    – Razetime
    Jun 24 at 7:16
  • \$\begingroup\$ Once again, alter (plus reversal of logic) helps to get rid of 5 bytes: func[a][i: 0 until[alter a i: 1 + i]single? a]. (single? doesn't work in TIO, must be replaced by 1 = lenght? a) \$\endgroup\$ Jun 24 at 18:18
  • 1
    \$\begingroup\$ only one more answer for an alter hattrick :P \$\endgroup\$
    – Razetime
    Jun 25 at 3:46
  • \$\begingroup\$ @Razetime haha, yes! \$\endgroup\$ Jun 25 at 6:42
4
\$\begingroup\$

Zsh, 13 bytes

: >$@<{1..$#}

Try it online!

:              noop command to prevent hanging while waiting for input
  >$@          create a file for every argument
     <{1..$#}  read every file between 1 and the number of arguments

Since the redirects are handled left-to-right, we create the files before trying to read them. If we encounter a number for which no file exists (for example on zsh x.zsh 4 1 2), we get the following error:

no such file or directory: 3

and receive exit code 1. If it was indeed a permutation, we exit cleanly with code 0.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf, and nice first answer! I've edited your answer slightly to include a link to Try it online! so that others can test your solution. Don't worry about not being able to comment, we encourage new users to post solutions, even if they're golfs of current ones :) \$\endgroup\$ Jun 25 at 12:16
4
\$\begingroup\$

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!

\$\endgroup\$
4
  • \$\begingroup\$ -1: any(rank(x<-scan())-x) swapping thruthy and falsy. (TIO link too long for the comment) \$\endgroup\$
    – pajonk
    Jun 24 at 7:54
  • 1
    \$\begingroup\$ @pajonk: I was just changing it while you were posting your comment ! :D \$\endgroup\$
    – digEmAll
    Jun 24 at 7:55
  • 1
    \$\begingroup\$ I think this fails on input 1,3,3,3,5. \$\endgroup\$ Jun 24 at 7:57
  • \$\begingroup\$ @RobinRyder: you're right... damn, I always forget that rank default for ties is avg... \$\endgroup\$
    – digEmAll
    Jun 24 at 8:02
3
\$\begingroup\$

Perl 5, 38 bytes

sub{!grep!{map+($_,1),@_}->{$_},1..@_}

Try it online!

\$\endgroup\$
2
3
\$\begingroup\$

Wolfram Language (Mathematica), 22 20 bytes

Sort@#==Range@Max@#&

-2 bytes, thanks to @ZaMoC:

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 20 bytes \$\endgroup\$
    – ZaMoC
    Jun 24 at 8:22
3
\$\begingroup\$

Java (JDK), 43 bytes

a->a.sorted().reduce(1,(x,y)->y==x?x+1:0)>0

Try it online!

Explanations

This answer is a Predicate<IntStream> and requires that the input contains no 0.

First this code sorts the input stream. The reduce method then makes sure that each consecutive number is encountered, and return the last encountered number. x always contains the next expected number, or 0 if we got an unexpected number. 1 is the first parameter of the reduce method as it's the first expected number. Given that 0, or any negative number, is not allowed in the IntStream, when 0 is returned for the first time, it will always be returned for the remaining of the process.

\$\endgroup\$
0
2
\$\begingroup\$

Charcoal, 6 bytes

¬⁻Eθκθ

Try it online! Link is to verbose version of code. 0-indexed. Outputs a Charcoal boolean, i.e. - for permutation, nothing if not. Explanation:

   θ    Input array
  E     Map over elements
    κ   Current index
 ⁻      Remove values found in
     θ  Input array
¬       Check that nothing is left
        Implicitly print

(Mapping over the input indices is golfier than creating a range.)

\$\endgroup\$
2
\$\begingroup\$

JavaScript (Node.js), 40 38 bytes

s=>s.sort((a,b)=>a-b).some((x,i)=>x^i)

Try it online!

Returns true for invalid and false for valid. Put a ! before the s.sort for the otherway round. Takes input 0-indexed.

\$\endgroup\$
5
  • \$\begingroup\$ 0-indexed is allowed, so you can remove ++. \$\endgroup\$
    – user100690
    Jun 24 at 7:51
  • \$\begingroup\$ (a,b)=>a-b -> a=>b=>a-b from this tip \$\endgroup\$
    – Razetime
    Jun 24 at 8:15
  • \$\begingroup\$ @razetime that wont work for the sort function \$\endgroup\$
    – user100752
    Jun 24 at 8:18
  • \$\begingroup\$ oh, too bad..... \$\endgroup\$
    – Razetime
    Jun 24 at 8:19
  • \$\begingroup\$ @RecursiveCo. thanks! \$\endgroup\$
    – emanresu A
    Jun 24 at 9:02
2
\$\begingroup\$

jq, 20 49 36 bytes

length==max and max==(unique|length)

Try it online!

Thanks to tsh and xigoi for catching mistakes in the previous attempts...

Third time is the charm perhaps?

Since the rules limit the numbers to "positive integers", there's no need to test the minimum. Making sure the largest number in the list, the size of the original list and the size of a de-dup'd list are all the same is sufficient. So that's what this version does.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Failed on [1,1,1] \$\endgroup\$
    – tsh
    Jun 24 at 9:25
  • \$\begingroup\$ Re-written to actually do what the challenge called for... \$\endgroup\$
    – cnamejj
    Jun 24 at 10:10
  • \$\begingroup\$ Maybe [1,3,3]? \$\endgroup\$
    – tsh
    Jun 24 at 10:39
  • 1
    \$\begingroup\$ I think it should be == instead of -. \$\endgroup\$
    – xigoi
    Jun 24 at 16:35
2
\$\begingroup\$

Raku, 14 bytes

{$_∖bag ^$_}

0-based.

Try it online!

  • $_ is the list argument to the function.
  • ^$_ is a list of numbers from 0 to one less than the size of the input list.
  • bag ^$_ is a bag (a set with multiplicity) of that list of those sequential numbers.
  • is the set difference operator. The left argument, the input list, is coerced to a bag because the right argument is a bag, from which one instance of each of the sequential numbers is removed. The result will be an empty bag only if the input list contained exactly one number from zero up to one less than its size. An empty bag is falsey in a boolean context, and a non-empty bag is truthy.
\$\endgroup\$
2
  • \$\begingroup\$ Dear lord I've got to learn Raku properly at some point. I'm a Perl 5 golfer, and Raku baffles me half the time. \$\endgroup\$ Jun 25 at 2:31
  • \$\begingroup\$ @SilvioMayolo I love golfing in Raku, since you rarely need weird tricks to keep the byte count down--the built-ins suffice for so many things. \$\endgroup\$
    – Sean
    Jun 25 at 8:14
2
\$\begingroup\$

C (gcc), 95 73 72 bytes

r,t,i,j;f(a,n)int*a;{for(r=i=n;i--;r*=!t)for(t=j=n;j--;)t*=i!=a[j];n=r;}

Try it online!

Inputs a pointer to an array \$a\$ of zero-based integers and its length \$n\$ (since C pointers to arrays carry no length information).
Returns a truthy value if all \$0\dots (n-1)\$ integers are present or a falsey value otherwise.

Explanation

Goes through all the numbers \$0\dots (n-1)\$ (in reverse order) and tests to see if they're in \$a\$.

Saved a whopping 19 bytes thanks to AZTECCO!!!

\$\endgroup\$
3
  • \$\begingroup\$ @AZTECCO Figured out how to golf it with t=j=n, for some reason (overflow/underflow I'm guessing) couldn't get this to work with t*=i-a[j]. \$\endgroup\$
    – Noodle9
    Jun 25 at 12:15
  • \$\begingroup\$ Great! Idk.. It worked for me \$\endgroup\$
    – AZTECCO
    Jun 25 at 12:28
  • \$\begingroup\$ @AZTECCO It fails on the second to last test. Have gone through it and t flips to \$0\$ without i-a[j]==0 while the code is testing for the presence of 41 (which isn't there). \$\endgroup\$
    – Noodle9
    Jun 25 at 12:29
2
\$\begingroup\$

Stax, 5 bytes

c%R|}

Run and debug it

Explanation:

     ; Implicit input onto top of stack
c    ; Copy top of stack
%    ; Length of top of stack
R    ; Make range [1 .. n]
|}   ; Compare top two elements of stack. Arrays are different orderings of same elements?
     ; Implicit output of truthy/falsy

Could probably save a byte somewhere.

\$\endgroup\$
1
  • \$\begingroup\$ oc%R- exists, but i don't think there's away to get this to pack. \$\endgroup\$
    – Razetime
    Jun 29 at 5:12
2
\$\begingroup\$

Japt, 4 3 bytes

0-based

Íe¶

Try it or run all test cases

Saved a byte thanks to Etheryte pointing out one of my own favourite tricks that I somehow forgot!

Íe¶     :Implicit input of array
Í       :Sort
 e      :Every?
  ¶     :  Equal to its 0-based index

Japt -x, 2 bytes

0-based. Outputs 0 for true or any other integer for false.

í-

Try it or run all test cases

í-     :Implicit input of array
í      :Interleave with 0-based indices
 -     :Reduce each by subtraction
       :Implicit output of sum of resulting array
\$\endgroup\$
2
  • \$\begingroup\$ You can use a shortcut for sorting for 3 bytes: Íe¶ \$\endgroup\$
    – Etheryte
    Jun 24 at 20:04
  • \$\begingroup\$ @Etheryte, of course I can :facepalm: One of my own favourite tricks and I fecking forgot it! Thanks :) \$\endgroup\$
    – Shaggy
    Jun 25 at 20:45
2
\$\begingroup\$

05AB1E, 3 bytes

{āQ

Try it online!

{āQ  # full program
  Q  # is...
 ā   # implicit input...
{    # sorted...
  Q  # equal to...
 ā   # [1, 2, 3, ..., length of...
     # implicit input...
{    # sorted...
 ā   # ]...
  Q  # ?
     # implicit output
\$\endgroup\$
1
\$\begingroup\$

C# (Visual C# Interactive Compiler), 46 bytes

a=>{a.Sort();int i=1;return a.All(x=>x==i++);}

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ 1,1,1,1,1,1 should be false \$\endgroup\$
    – tsh
    Jun 24 at 7:38
  • \$\begingroup\$ The third test case in your TIO link should be false. That said, removing Distinct should fix it. \$\endgroup\$
    – Bubbler
    Jun 24 at 7:50
  • \$\begingroup\$ I had one of the falsey test cases with my truthy ones, that's what tripped me up, thanks \$\endgroup\$
    – LiefdeWen
    Jun 24 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.