Task 1: Good Pairs You are given a list of integers, @list. Write a script to find the total count of Good Pairs: A pair (i, j) is called good if list[i] == list[j] and i < j. Example 1 Input: @list = (1,2,3,1,1,3) Output: 4 There are 4 good pairs found as below: (0,3) (0,4) (3,4) (2,5) Example 2 Input: @list = (1,2,3) Output: 0 Example 3 Input: @list = (1,1,1,1) Output: 6 Good pairs are below: (0,1) (0,2) (0,3) (1,2) (1,3) (2,3) MY NOTES: very easy. two nested for loops.. GUEST LANGUAGE: As a bonus, I also had a go at translating ch-1.pl into C (look in the C directory for the translation) Task 2: Good Triplets You are given an array of integers, @array and three integers $x,$y,$z. Write a script to find out total Good Triplets in the given array. A triplet array[i], array[j], array[k] is good if it satisfies the following conditions: a) 0 <= i < j < k <= n (size of given array) b) abs(array[i] - array[j]) <= x c) abs(array[j] - array[k]) <= y d) abs(array[i] - array[k]) <= z Example 1 Input: @array = (3,0,1,1,9,7) and $x = 7, $y = 2, $z = 3 Output: 4 Good Triplets are as below: (3,0,1) where (i=0, j=1, k=2) (3,0,1) where (i=0, j=1, k=3) (3,1,1) where (i=0, j=2, k=3) (0,1,1) where (i=1, j=2, k=3) Example 2 Input: @array = (1,1,2,2,3) and $x = 0, $y = 0, $z = 1 Output: 0 MY NOTES: not quite so easy, start with 3 nested for loops;-) GUEST LANGUAGE: As a bonus, I also had a go at translating ch-2.pl into C (look in the C directory for the translation)