aboutsummaryrefslogtreecommitdiff
path: root/challenge-276/deadmarshal/d
diff options
context:
space:
mode:
authordeadmarshal <adeadmarshal@gmail.com>2024-07-05 10:58:08 +0330
committerdeadmarshal <adeadmarshal@gmail.com>2024-07-05 10:58:08 +0330
commit2a215d8b05fa5bbf1654ebdfe006b7e818053982 (patch)
tree54197a8ed639449bc4bd9d59bda4be8bcc5ca8ed /challenge-276/deadmarshal/d
parent5d778b7b2bef2a6a478857b573d7796ffc214f77 (diff)
downloadperlweeklychallenge-club-2a215d8b05fa5bbf1654ebdfe006b7e818053982.tar.gz
perlweeklychallenge-club-2a215d8b05fa5bbf1654ebdfe006b7e818053982.tar.bz2
perlweeklychallenge-club-2a215d8b05fa5bbf1654ebdfe006b7e818053982.zip
TWC276 raku and d solutions
Diffstat (limited to 'challenge-276/deadmarshal/d')
-rw-r--r--challenge-276/deadmarshal/d/ch1.d18
-rw-r--r--challenge-276/deadmarshal/d/ch2.d19
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-276/deadmarshal/d/ch1.d b/challenge-276/deadmarshal/d/ch1.d
new file mode 100644
index 0000000000..6ccb6559d0
--- /dev/null
+++ b/challenge-276/deadmarshal/d/ch1.d
@@ -0,0 +1,18 @@
+import std.stdio:writeln;
+
+int complete_day(int[] arr)
+{
+ int count = 0;
+ foreach(i;0..arr.length-1)
+ foreach(j;i+1..arr.length)
+ if((arr[i] + arr[j]) % 24 == 0) count++;
+ return count;
+}
+
+void main()
+{
+ writeln(complete_day([12,12,30,24,24]));
+ writeln(complete_day([72,48,24,55]));
+ writeln(complete_day([12,18,24]));
+}
+
diff --git a/challenge-276/deadmarshal/d/ch2.d b/challenge-276/deadmarshal/d/ch2.d
new file mode 100644
index 0000000000..dcbf95de1f
--- /dev/null
+++ b/challenge-276/deadmarshal/d/ch2.d
@@ -0,0 +1,19 @@
+import std.stdio:writeln;
+import std.algorithm:maxElement,filter,sum;
+import std.array:array;
+
+int maximum_frequency(int[] arr)
+{
+ int sum = 0;
+ int[int] h;
+ foreach(e;arr) h[e]++;
+ int max = h.values.maxElement;
+ return h.values.filter!(a => a == max).array.sum;
+}
+
+void main()
+{
+ writeln(maximum_frequency([1,2,2,4,1,5]));
+ writeln(maximum_frequency([1,2,3,4,5]));
+}
+