blob: 5bef60c5cdbf65b44cac8f8ce423fc90090909f1 (
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
26
27
|
#! /usr/bin/env perl
use strict;
use feature 'say';
use Getopt::Long;
use List::Util qw(all sum);
use Algorithm::Combinatorics 'combinations';
die "At least 3 values" unless @ARGV > 2;
die "Integers only" unless all { $ ~= /^\d+$/ } @ARGV;
my $A = shift(@ARGV);
for my $combination (combinations(\@ARGV, 2))
{
my $sum = @$combination[0] - @$combination[1];
if (abs($sum) == $A)
{
say 1;
exit;
}
}
say 0;
|