Help for this page

Select Code to Download


  1. or download this
    my @tests = (
        [[2,7,11,15], 9, [0,1]],
    ...
        [[3,3], 6, [0,1]],
        [[3,3], 6, [1,0]],
    );
    
  2. or download this
    for my $test (@tests) {
        is_deeply
            sort_arrayref(two_sum($test->[INPUT], $test->[TARGET])),
            sort_arrayref($test->[EXPECTED]);
    }
    
  3. or download this
    sub sort_arrayref {
        my ($aref) = @_;
    
        return [ sort { $a <=> $b } @$aref ];
    }
    
  4. or download this
    1..6
    ok 1
    ...
    ok 4
    ok 5
    ok 6