aboutsummaryrefslogtreecommitdiff
path: root/challenge-260/kjetillll/perl/ch-1.pl
blob: 31298d37a99f01b4711297c995c0addd1feadd86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use List::Util uniq; use strict; use warnings;

sub f {
    my %count;
    $count{ $_ }++ for @_;
    0 + ( values %count == uniq values %count )
}



#========== Test ========================================
use Test::More tests=>3;
is( f( @{ $$_{input} } ), $$_{output} ) for
    {
        input  => [1,2,2,1,1,3],
        output => 1
    },
    {
        input => [1,2,3],
        output => 0
    },
    {
        input => [-2,0,1,-2,1,1,0,1,-2,9],
        output => 1
    };