aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-09-08 21:15:48 +0100
committerGitHub <noreply@github.com>2024-09-08 21:15:48 +0100
commit88b393512839ee311a24dfd2cc2b909a1455eafe (patch)
treec76965bd7cb6babcd6e137ceeb195bf62d4fb597
parentc27f53ea3c7c6b8cd8a30c6ecb4894364e07f6ec (diff)
parent39a4bf3929118980e89cc48b05c7846fff5cb8ff (diff)
downloadperlweeklychallenge-club-88b393512839ee311a24dfd2cc2b909a1455eafe.tar.gz
perlweeklychallenge-club-88b393512839ee311a24dfd2cc2b909a1455eafe.tar.bz2
perlweeklychallenge-club-88b393512839ee311a24dfd2cc2b909a1455eafe.zip
Merge pull request #10795 from wambash/challenge-week-285
Challenge week 285
-rw-r--r--challenge-285/wambash/elixir/ch-2.exs30
-rw-r--r--challenge-285/wambash/raku/ch-1.raku19
2 files changed, 49 insertions, 0 deletions
diff --git a/challenge-285/wambash/elixir/ch-2.exs b/challenge-285/wambash/elixir/ch-2.exs
new file mode 100644
index 0000000000..499304306b
--- /dev/null
+++ b/challenge-285/wambash/elixir/ch-2.exs
@@ -0,0 +1,30 @@
+defmodule Change do
+ defp _making({0,_}),do: [1]
+ defp _making({_,[]}),do: [0]
+ defp _making({amount, [hc| coins]}) when hc > amount, do: _making({amount,coins})
+ defp _making({amount, coins}) do
+ coins
+ |> Enum.flat_map(fn
+ x -> _making(
+ {
+ amount - x,
+ coins |> Enum.drop_while( & &1 > x )
+ }
+ )
+ end)
+ end
+ def making(w) do
+ _making(w) |> Enum.sum
+ end
+end
+
+ExUnit.start()
+
+defmodule ChangeTest do
+ use ExUnit.Case
+ test "Change" do
+ assert Change.making({9,[50,25,10,5,1]}) == 2
+ assert Change.making({100,[50,25,10,5,1]}) == 292
+ assert Change.making({15,[50,25,10,5,1]}) == 6
+ end
+end
diff --git a/challenge-285/wambash/raku/ch-1.raku b/challenge-285/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..dc74e10a33
--- /dev/null
+++ b/challenge-285/wambash/raku/ch-1.raku
@@ -0,0 +1,19 @@
+#!/usr/bin/env raku
+
+multi no_connection (+@ ($from, $to)) { $to }
+multi no_connection (+@routes) {
+ my :(@from, @to) := [Z] @routes;
+
+ @to.first: { $_ ∉ @from }
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is no_connection(<B C>, <D B>, <C A>), 'A';
+ is no_connection(<A Z>), 'Z';
+ done-testing;
+}
+
+multi MAIN (+@routes) {
+ say no_connection +@routes
+}