aboutsummaryrefslogtreecommitdiff
path: root/ch-1.pl
diff options
context:
space:
mode:
authorFung Cheok Yin <61836418+E7-87-83@users.noreply.github.com>2020-04-17 21:17:23 +0800
committerGitHub <noreply@github.com>2020-04-17 21:17:23 +0800
commitf26433607d167aae47039537124ae0a00607a2ba (patch)
treeca1223d28634b409912641ae1d48daa52a0cf43e /ch-1.pl
parentab5ca0309aeb72e6373df1935ed46f4d77945ecd (diff)
downloadperlweeklychallenge-club-f26433607d167aae47039537124ae0a00607a2ba.tar.gz
perlweeklychallenge-club-f26433607d167aae47039537124ae0a00607a2ba.tar.bz2
perlweeklychallenge-club-f26433607d167aae47039537124ae0a00607a2ba.zip
Rename ch-1.pl to challenge-056/cheok-yin-fung/perl/ch-1.pl
Diffstat (limited to 'ch-1.pl')
-rw-r--r--ch-1.pl28
1 files changed, 0 insertions, 28 deletions
diff --git a/ch-1.pl b/ch-1.pl
deleted file mode 100644
index f33a6aff99..0000000000
--- a/ch-1.pl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl
-use strict;
-
-# Usage: $ ch-1.pl (number of terms) (diff-k) (LIST of N sorted integers, from small to large)
-# ch-1.pl 3 1 1 2 3
-
-my $N = shift @ARGV;
-my $DIFFK = shift @ARGV;
-
-die "not enough terms or too many terms" if $N != $#ARGV+1;
-
-my @A = @ARGV;
-
-my @B;
-
-for (1..$N-1) {
- push @B, $A[$_] - $A[$_-1];
-}
-
-for (0..$N-2) {
- my $diff = 0;
- my $pointer = $_+1;
- while ($pointer < $N and $diff <= $DIFFK) {
- $diff += $B[$pointer-1];
- print $pointer, " ", $_, "\n" if $diff==$DIFFK;
- $pointer++;
- }
-}