aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/deadmarshal/d/ch1.d
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-199/deadmarshal/d/ch1.d')
-rw-r--r--challenge-199/deadmarshal/d/ch1.d21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-199/deadmarshal/d/ch1.d b/challenge-199/deadmarshal/d/ch1.d
new file mode 100644
index 0000000000..1e552b09d5
--- /dev/null
+++ b/challenge-199/deadmarshal/d/ch1.d
@@ -0,0 +1,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));
+}
+