aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/deadmarshal/d/ch1.d
blob: 1e552b09d56a86691a978a47ec66a64874c70e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import std.stdio:writeln;

int good_pairs(int[] arr)
{
  int count = 0;
  for(size_t i = 0; i < arr.length; ++i)
    for(size_t j = i+1; j < arr.length; ++j)
      if(arr[i] == arr[j]) count++;
  return count;
}

void main()
{
  int[] a1 = [1,2,3,1,1,3];
  int[] a2 = [1,2,3];
  int[] a3 = [1,1,1,1];
  writeln(good_pairs(a1));
  writeln(good_pairs(a2));
  writeln(good_pairs(a3));
}