aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/asherbhs/raku/ch-2.raku
blob: 34ea95a91b405be8003da568d8331e64d8d6d8b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
sub count-equal-divisible(Int:D @ints, Int:D $k --> Int:D) {
	my $n = 0;
	for 0 ..^ @ints -> $i {
		for $i + 1 ..^ @ints -> $j {
			$n++ if @ints[$i] == @ints[$j] && ($i %% $k || $j %% $k)
		}
	}
	return $n
}

say count-equal-divisible Array[Int].new(3, 1, 2, 2, 2, 1, 3), 2;
say count-equal-divisible Array[Int].new(1, 2, 3),             1;