From 15e8ffd9daeb40667b1fb2b76dece74e471450ea Mon Sep 17 00:00:00 2001 From: Packy Anderson Date: Mon, 22 Sep 2025 23:59:20 -0400 Subject: Challenge 340 solutions by Packy Anderson * Raku that is finally Raku-ish * Perl * Python that kinda looks like Raku * Elixir that is starting to look like Elixir 1 blog post --- challenge-340/packy-anderson/README.md | 2 +- challenge-340/packy-anderson/blog.txt | 1 + challenge-340/packy-anderson/elixir/ch-1.exs | 33 ++++++++++++++++++++++ challenge-340/packy-anderson/elixir/ch-2.exs | 41 ++++++++++++++++++++++++++++ challenge-340/packy-anderson/perl/ch-1.pl | 28 +++++++++++++++++++ challenge-340/packy-anderson/perl/ch-2.pl | 31 +++++++++++++++++++++ challenge-340/packy-anderson/python/ch-1.py | 29 ++++++++++++++++++++ challenge-340/packy-anderson/python/ch-2.py | 27 ++++++++++++++++++ challenge-340/packy-anderson/raku/ch-1.raku | 28 +++++++++++++++++++ challenge-340/packy-anderson/raku/ch-2.raku | 31 +++++++++++++++++++++ 10 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 challenge-340/packy-anderson/blog.txt create mode 100755 challenge-340/packy-anderson/elixir/ch-1.exs create mode 100755 challenge-340/packy-anderson/elixir/ch-2.exs create mode 100755 challenge-340/packy-anderson/perl/ch-1.pl create mode 100755 challenge-340/packy-anderson/perl/ch-2.pl create mode 100755 challenge-340/packy-anderson/python/ch-1.py create mode 100755 challenge-340/packy-anderson/python/ch-2.py create mode 100755 challenge-340/packy-anderson/raku/ch-1.raku create mode 100755 challenge-340/packy-anderson/raku/ch-2.raku diff --git a/challenge-340/packy-anderson/README.md b/challenge-340/packy-anderson/README.md index 1013ff24f7..7af85bca11 100644 --- a/challenge-340/packy-anderson/README.md +++ b/challenge-340/packy-anderson/README.md @@ -23,4 +23,4 @@ ## Blog Post -[Perl Weekly Challenge: Points? What's the diff?](https://packy.dardan.com/b/bN) +[Perl Weekly Challenge: Rising in Num](https://packy.dardan.com/b/bj) diff --git a/challenge-340/packy-anderson/blog.txt b/challenge-340/packy-anderson/blog.txt new file mode 100644 index 0000000000..f0268a9a3f --- /dev/null +++ b/challenge-340/packy-anderson/blog.txt @@ -0,0 +1 @@ +https://packy.dardan.com/b/bj \ No newline at end of file diff --git a/challenge-340/packy-anderson/elixir/ch-1.exs b/challenge-340/packy-anderson/elixir/ch-1.exs new file mode 100755 index 0000000000..65013250fc --- /dev/null +++ b/challenge-340/packy-anderson/elixir/ch-1.exs @@ -0,0 +1,33 @@ +#!/usr/bin/env elixir + +defmodule PWC do + def duplicate_removal(str) do + match = Regex.run(~r/(\p{L})\1/, str, capture: :first) + if match do + String.replace(str, match, "", global: false) + |> duplicate_removal + else + str + end + end + + def solution(str) do + IO.puts("Input: $str = '#{str}'") + IO.puts("Output: '#{duplicate_removal(str)}'") + end +end + +IO.puts("Example 1:") +PWC.solution("abbaca") + +IO.puts("\nExample 2:") +PWC.solution("azxxzy") + +IO.puts("\nExample 3:") +PWC.solution("aaaaaaaa") + +IO.puts("\nExample 4:") +PWC.solution("aabccba") + +IO.puts("\nExample 5:") +PWC.solution("abcddcba") diff --git a/challenge-340/packy-anderson/elixir/ch-2.exs b/challenge-340/packy-anderson/elixir/ch-2.exs new file mode 100755 index 0000000000..73a47e15f8 --- /dev/null +++ b/challenge-340/packy-anderson/elixir/ch-2.exs @@ -0,0 +1,41 @@ +#!/usr/bin/env elixir + +defmodule PWC do + def ascending(list) when is_list(list) and length(list) == 1, + do: "true" + + def ascending([head | list]) do + if head < List.first(list) do + ascending(list) + else + "false" + end + end + + def ascending_num(str) do + Regex.scan(~r/\d+/, str, capture: :first) + |> List.flatten + |> Enum.map(fn n -> String.to_integer(n) end) + |> ascending + end + + def solution(str) do + IO.puts("Input: $str = '#{str}'") + IO.puts("Output: #{ascending_num(str)}") + end +end + +IO.puts("Example 1:") +PWC.solution("The cat has 3 kittens 7 toys 10 beds") + +IO.puts("\nExample 2:") +PWC.solution("Alice bought 5 apples 2 oranges 9 bananas") + +IO.puts("\nExample 3:") +PWC.solution("I ran 1 mile 2 days 3 weeks 4 months") + +IO.puts("\nExample 4:") +PWC.solution("Bob has 10 cars 10 bikes") + +IO.puts("\nExample 5:") +PWC.solution("Zero is 0 one is 1 two is 2") diff --git a/challenge-340/packy-anderson/perl/ch-1.pl b/challenge-340/packy-anderson/perl/ch-1.pl new file mode 100755 index 0000000000..80cb0b4f84 --- /dev/null +++ b/challenge-340/packy-anderson/perl/ch-1.pl @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +use v5.40; + +sub duplicateRemoval($str) { + return $str + unless $str =~ s/([a-z])\g1//; + duplicateRemoval($str); +} + +sub solution($str) { + say "Input: \$str = '$str'"; + say "Output: '@{[duplicateRemoval($str)]}'"; +} + +say "Example 1:"; +solution("abbaca"); + +say "\nExample 2:"; +solution("azxxzy"); + +say "\nExample 3:"; +solution("aaaaaaaa"); + +say "\nExample 4:"; +solution("aabccba"); + +say "\nExample 5:"; +solution("abcddcba"); diff --git a/challenge-340/packy-anderson/perl/ch-2.pl b/challenge-340/packy-anderson/perl/ch-2.pl new file mode 100755 index 0000000000..0dc1b498f1 --- /dev/null +++ b/challenge-340/packy-anderson/perl/ch-2.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +use v5.40; + +sub ascendingNum($str) { + my @list = $str =~ /(\d+)/g; + while (@list > 1) { + return 'false' if $list[0] >= $list[1]; + shift @list; + } + return 'true'; +} + +sub solution($str) { + say "Input: \$str = '$str'"; + say "Output: @{[ascendingNum($str)]}"; +} + +say "Example 1:"; +solution("The cat has 3 kittens 7 toys 10 beds"); + +say "\nExample 2:"; +solution("Alice bought 5 apples 2 oranges 9 bananas"); + +say "\nExample 3:"; +solution("I ran 1 mile 2 days 3 weeks 4 months"); + +say "\nExample 4:"; +solution("Bob has 10 cars 10 bikes"); + +say "\nExample 5:"; +solution("Zero is 0 one is 1 two is 2"); diff --git a/challenge-340/packy-anderson/python/ch-1.py b/challenge-340/packy-anderson/python/ch-1.py new file mode 100755 index 0000000000..4b0733e391 --- /dev/null +++ b/challenge-340/packy-anderson/python/ch-1.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import re + +def duplicate_removal(strval): + m = re.search(r'([a-z])\1', strval) + if not m: return strval + return duplicate_removal( + strval.replace(m.group(0), '', count=1) + ) + +def solution(strval): + print(f"Input: $str = '{strval}'") + print(f"Output: '{duplicate_removal(strval)}'") + +print('Example 1:') +solution("abbaca") + +print('\nExample 2:') +solution("azxxzy") + +print('\nExample 3:') +solution("aaaaaaaa") + +print('\nExample 4:') +solution("aabccba") + +print('\nExample 5:') +solution("abcddcba") diff --git a/challenge-340/packy-anderson/python/ch-2.py b/challenge-340/packy-anderson/python/ch-2.py new file mode 100755 index 0000000000..55b4f2b288 --- /dev/null +++ b/challenge-340/packy-anderson/python/ch-2.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +def ascending_num(strval): + list = [ int(n) for n in strval.split() if n.isnumeric() ] + while len(list) > 1: + if list[0] >= list[1]: return False + list.pop(0) + return True + +def solution(strval): + print(f"Input: $str = '{strval}'") + print(f"Output: {ascending_num(strval)}") + +print('Example 1:') +solution("The cat has 3 kittens 7 toys 10 beds") + +print('\nExample 2:') +solution("Alice bought 5 apples 2 oranges 9 bananas") + +print('\nExample 3:') +solution("I ran 1 mile 2 days 3 weeks 4 months") + +print('\nExample 4:') +solution("Bob has 10 cars 10 bikes") + +print('\nExample 5:') +solution("Zero is 0 one is 1 two is 2") diff --git a/challenge-340/packy-anderson/raku/ch-1.raku b/challenge-340/packy-anderson/raku/ch-1.raku new file mode 100755 index 0000000000..9bd7914c33 --- /dev/null +++ b/challenge-340/packy-anderson/raku/ch-1.raku @@ -0,0 +1,28 @@ +#!/usr/bin/env raku +use v6; + +sub duplicateRemoval($str is copy) { + return $str + unless $str ~~ s/() {} $0//; + duplicateRemoval($str); +} + +sub solution($str) { + say "Input: \$str = '$str'"; + say "Output: '{duplicateRemoval($str)}'"; +} + +say "Example 1:"; +solution("abbaca"); + +say "\nExample 2:"; +solution("azxxzy"); + +say "\nExample 3:"; +solution("aaaaaaaa"); + +say "\nExample 4:"; +solution("aabccba"); + +say "\nExample 5:"; +solution("abcddcba"); diff --git a/challenge-340/packy-anderson/raku/ch-2.raku b/challenge-340/packy-anderson/raku/ch-2.raku new file mode 100755 index 0000000000..935d273a0b --- /dev/null +++ b/challenge-340/packy-anderson/raku/ch-2.raku @@ -0,0 +1,31 @@ +#!/usr/bin/env raku +use v6; + +sub ascendingNum($str) { + my @list = $str.comb(/\d+/); + while (@list.elems > 1) { + return False if @list[0] >= @list[1]; + @list.shift; + } + return True; +} + +sub solution($str) { + say "Input: \$str = '$str'"; + say "Output: {ascendingNum($str)}"; +} + +say "Example 1:"; +solution("The cat has 3 kittens 7 toys 10 beds"); + +say "\nExample 2:"; +solution("Alice bought 5 apples 2 oranges 9 bananas"); + +say "\nExample 3:"; +solution("I ran 1 mile 2 days 3 weeks 4 months"); + +say "\nExample 4:"; +solution("Bob has 10 cars 10 bikes"); + +say "\nExample 5:"; +solution("Zero is 0 one is 1 two is 2"); -- cgit From 9103f0d2752aafd44d250aea368defe79e2c22cd Mon Sep 17 00:00:00 2001 From: Packy Anderson Date: Tue, 30 Sep 2025 20:15:20 -0400 Subject: Challenge 341 solutions by Packy Anderson * Raku that is finally Raku-ish * Perl * Python that kinda looks like Raku * Elixir that is starting to look like Elixir 1 blog post --- challenge-341/packy-anderson/README.md | 2 +- challenge-341/packy-anderson/blog.txt | 1 + challenge-341/packy-anderson/elixir/ch-1.exs | 38 ++++++++++++++++++++-------- challenge-341/packy-anderson/elixir/ch-2.exs | 22 ++++++++-------- challenge-341/packy-anderson/perl/ch-1.pl | 28 ++++++++++++++------ challenge-341/packy-anderson/perl/ch-2.pl | 22 ++++++++++------ challenge-341/packy-anderson/python/ch-1.py | 38 +++++++++++++++++----------- challenge-341/packy-anderson/python/ch-2.py | 26 ++++++++----------- challenge-341/packy-anderson/raku/ch-1.raku | 28 ++++++++++++++------ challenge-341/packy-anderson/raku/ch-2.raku | 22 ++++++++++------ 10 files changed, 144 insertions(+), 83 deletions(-) diff --git a/challenge-341/packy-anderson/README.md b/challenge-341/packy-anderson/README.md index 1013ff24f7..704729b966 100644 --- a/challenge-341/packy-anderson/README.md +++ b/challenge-341/packy-anderson/README.md @@ -23,4 +23,4 @@ ## Blog Post -[Perl Weekly Challenge: Points? What's the diff?](https://packy.dardan.com/b/bN) +[Perl Weekly Challenge: Something just BROKE](https://packy.dardan.com/b/bw) diff --git a/challenge-341/packy-anderson/blog.txt b/challenge-341/packy-anderson/blog.txt index e69de29bb2..3c44456bdb 100644 --- a/challenge-341/packy-anderson/blog.txt +++ b/challenge-341/packy-anderson/blog.txt @@ -0,0 +1 @@ +https://packy.dardan.com/b/bw \ No newline at end of file diff --git a/challenge-341/packy-anderson/elixir/ch-1.exs b/challenge-341/packy-anderson/elixir/ch-1.exs index 45a0ed2251..398e7b8b91 100755 --- a/challenge-341/packy-anderson/elixir/ch-1.exs +++ b/challenge-341/packy-anderson/elixir/ch-1.exs @@ -1,26 +1,44 @@ #!/usr/bin/env elixir defmodule PWC do + def broken_keys(str, []) do + # if there are no broken keys, + # we can type all the words + String.split(str) + |> Enum.count + end + + def broken_keys(str, keys) do + # build a character class + {:ok, regex} = Regex.compile( + "[" <> Enum.join(keys) <> "]", [:caseless] + ) + # count how many words don't match the class + String.split(str) + |> Enum.filter(fn word -> not Regex.match?(regex, word) end) + |> Enum.count + end - def solution(ints) do - IO.puts("Input: @ints = (" <> Enum.join(ints, ", ") <> ")") - {sign, explain} = PWC.productSign(ints) - IO.puts("Output: " <> to_string(sign) ) - IO.puts("\n" <> explain) + def solution(str, keys) do + keylist = keys + |> Enum.map(fn c -> "'#{c}'" end) + |> Enum.join(",") + IO.puts("Input: $str = '#{str}, @keys = (#{keylist})'") + IO.puts("Output: #{broken_keys(str, keys)}") end end IO.puts("Example 1:") -PWC.solution() +PWC.solution("Hello World", ["d"]) IO.puts("\nExample 2:") -PWC.solution() +PWC.solution("apple banana cherry", ["a", "e"]) IO.puts("\nExample 3:") -PWC.solution() +PWC.solution("Coding is fun", []) IO.puts("\nExample 4:") -PWC.solution() +PWC.solution("The Weekly Challenge", ["a","b"]) IO.puts("\nExample 5:") -PWC.solution() +PWC.solution("Perl and Python", ["p"]) diff --git a/challenge-341/packy-anderson/elixir/ch-2.exs b/challenge-341/packy-anderson/elixir/ch-2.exs index 45a0ed2251..710d80716a 100755 --- a/challenge-341/packy-anderson/elixir/ch-2.exs +++ b/challenge-341/packy-anderson/elixir/ch-2.exs @@ -1,26 +1,28 @@ #!/usr/bin/env elixir defmodule PWC do + def reverse_prefix(str, char) do + [a, b] = String.split(str, char, parts: 2) + char <> String.reverse(a) <> b + end - def solution(ints) do - IO.puts("Input: @ints = (" <> Enum.join(ints, ", ") <> ")") - {sign, explain} = PWC.productSign(ints) - IO.puts("Output: " <> to_string(sign) ) - IO.puts("\n" <> explain) + def solution(str, char) do + IO.puts("Input: $str = \"#{str}\", $char = \"#{char}\"") + IO.puts("Output: \"#{reverse_prefix(str, char)}\"") end end IO.puts("Example 1:") -PWC.solution() +PWC.solution("programming", "g") IO.puts("\nExample 2:") -PWC.solution() +PWC.solution("hello", "h") IO.puts("\nExample 3:") -PWC.solution() +PWC.solution("abcdefghij", "h") IO.puts("\nExample 4:") -PWC.solution() +PWC.solution("reverse", "s") IO.puts("\nExample 5:") -PWC.solution() +PWC.solution("perl","r") diff --git a/challenge-341/packy-anderson/perl/ch-1.pl b/challenge-341/packy-anderson/perl/ch-1.pl index 98a155f02b..5156de78b6 100755 --- a/challenge-341/packy-anderson/perl/ch-1.pl +++ b/challenge-341/packy-anderson/perl/ch-1.pl @@ -1,22 +1,34 @@ #!/usr/bin/env perl use v5.40; -sub solution(@arr) { - say 'Input: @arr = (' . join(', ', @arr) . ')'; - say 'Output: (' . join(', ', @arr) . ')'; +sub brokenKeys($str, @keys) { + my @words = split /\s+/, $str; + # if there are no broken keys, + # we can type all the words + return scalar(@words) if @keys == 0; + # build a character class + my $regex = '[' . join('', @keys) . ']'; + # count how many words don't match the class + return ( scalar( grep {! /$regex/i } @words) ); +} + +sub solution($str, $keys) { + my $keylist = join ",", map {"'$_'"} @$keys; + say "Input: \$str = '$str', \@keys = ($keylist)"; + say "Output: " . brokenKeys($str, @$keys); } say "Example 1:"; -solution(); +solution("Hello World", ["d"]); say "\nExample 2:"; -solution(); +solution("apple banana cherry", ["a", "e"]); say "\nExample 3:"; -solution(); +solution("Coding is fun", []); say "\nExample 4:"; -solution(); +solution("The Weekly Challenge", ["a","b"]); say "\nExample 5:"; -solution(); +solution("Perl and Python", ["p"]); \ No newline at end of file diff --git a/challenge-341/packy-anderson/perl/ch-2.pl b/challenge-341/packy-anderson/perl/ch-2.pl index 98a155f02b..c925939b15 100755 --- a/challenge-341/packy-anderson/perl/ch-2.pl +++ b/challenge-341/packy-anderson/perl/ch-2.pl @@ -1,22 +1,28 @@ #!/usr/bin/env perl use v5.40; -sub solution(@arr) { - say 'Input: @arr = (' . join(', ', @arr) . ')'; - say 'Output: (' . join(', ', @arr) . ')'; +sub reversePrefix($str, $char) { + my $loc = index($str, $char) + 1; + reverse(substr($str, 0, $loc)) . substr($str, $loc); +} + +sub solution($str, $char) { + say qq{Input: \$str = "$str", \$char = "$char"}; + my $result = reversePrefix($str, $char); + say qq{Output: "$result"}; } say "Example 1:"; -solution(); +solution("programming", "g"); say "\nExample 2:"; -solution(); +solution("hello", "h"); say "\nExample 3:"; -solution(); +solution("abcdefghij", "h"); say "\nExample 4:"; -solution(); +solution("reverse", "s"); say "\nExample 5:"; -solution(); +solution("perl","r"); diff --git a/challenge-341/packy-anderson/python/ch-1.py b/challenge-341/packy-anderson/python/ch-1.py index 60b68c6163..ecd60e168f 100755 --- a/challenge-341/packy-anderson/python/ch-1.py +++ b/challenge-341/packy-anderson/python/ch-1.py @@ -1,28 +1,36 @@ #!/usr/bin/env python -def distinctAverages(nums): - pass - -def int_join(joiner, arr): - return joiner.join(map(lambda i: str(i), arr)) - -def solution(nums): - print(f'Input: @nums = ({int_join(", ", nums)})') - count, explain = distinctAverages(nums) - print(f'Output: {count}\n\n{explain}') +import re + +def broken_keys(mystr, keys): + words = mystr.split() + # if there are no broken keys, + # we can type all the words + if len(keys) == 0: return len(words) + # build a character class + regex = re.compile('[' + ''.join(keys) + ']', re.I) + # count how many words don't match the class + return( len([ + word for word in words if not re.search(regex, word) + ]) ) + +def solution(mystr, keys): + keylist = ",".join([ f"'{c}'" for c in keys ]) + print(f"Input: $str = '{mystr}', @keys = ({keylist})") + print(f"Output: {broken_keys(mystr, keys)}") print('Example 1:') -solution() +solution("Hello World", ["d"]) print('\nExample 2:') -solution() +solution("apple banana cherry", ["a", "e"]) print('\nExample 3:') -solution() +solution("Coding is fun", []) print('\nExample 4:') -solution() +solution("The Weekly Challenge", ["a","b"]) print('\nExample 5:') -solution() +solution("Perl and Python", ["p"]) diff --git a/challenge-341/packy-anderson/python/ch-2.py b/challenge-341/packy-anderson/python/ch-2.py index 60b68c6163..0265f90a2a 100755 --- a/challenge-341/packy-anderson/python/ch-2.py +++ b/challenge-341/packy-anderson/python/ch-2.py @@ -1,28 +1,24 @@ #!/usr/bin/env python -def distinctAverages(nums): - pass - -def int_join(joiner, arr): - return joiner.join(map(lambda i: str(i), arr)) - -def solution(nums): - print(f'Input: @nums = ({int_join(", ", nums)})') - count, explain = distinctAverages(nums) - print(f'Output: {count}\n\n{explain}') +def reverse_prefix(mystr, char): + loc = mystr.find(char) + 1 + return mystr[0:loc][::-1] + mystr[loc:] +def solution(mystr, char): + print(f'Input: $str = "{mystr}", $char = "{char}"') + print(f'Output: "{reverse_prefix(mystr, char)}"') print('Example 1:') -solution() +solution("programming", "g") print('\nExample 2:') -solution() +solution("hello", "h") print('\nExample 3:') -solution() +solution("abcdefghij", "h") print('\nExample 4:') -solution() +solution("reverse", "s") print('\nExample 5:') -solution() +solution("perl","r") diff --git a/challenge-341/packy-anderson/raku/ch-1.raku b/challenge-341/packy-anderson/raku/ch-1.raku index 53bd47e1a7..f400d13c4c 100755 --- a/challenge-341/packy-anderson/raku/ch-1.raku +++ b/challenge-341/packy-anderson/raku/ch-1.raku @@ -1,22 +1,34 @@ #!/usr/bin/env raku use v6; -sub solution(@arr) { - say 'Input: @arr = (' ~ @arr.join(', ') ~ ')'; - say 'Output: (' ~ @arr.join(', ') ~ ')'; +sub brokenKeys($str, @keys) { + my @words = $str.comb(/\S+/); + # if there are no broken keys, + # we can type all the words + return @words.elems if @keys == 0; + # build a character class + my $regex = '<[' ~ @keys.join ~ ']>'; + # count how many words don't match the class + return ( ( @words.grep({! /:i <$regex>/ }) ).elems ); +} + +sub solution($str, @keys) { + my $keys = @keys.map({"'$_'"}).join(","); + say "Input: \$str = '$str', \@keys = ($keys)"; + say "Output: " ~ brokenKeys($str, @keys); } say "Example 1:"; -solution(); +solution("Hello World", ["d"]); say "\nExample 2:"; -solution(); +solution("apple banana cherry", ["a", "e"]); say "\nExample 3:"; -solution(); +solution("Coding is fun", []); say "\nExample 4:"; -solution(); +solution("The Weekly Challenge", ["a","b"]); say "\nExample 5:"; -solution(); +solution("Perl and Python", ["p"]); \ No newline at end of file diff --git a/challenge-341/packy-anderson/raku/ch-2.raku b/challenge-341/packy-anderson/raku/ch-2.raku index 53bd47e1a7..739c2d8fed 100755 --- a/challenge-341/packy-anderson/raku/ch-2.raku +++ b/challenge-341/packy-anderson/raku/ch-2.raku @@ -1,22 +1,28 @@ #!/usr/bin/env raku use v6; -sub solution(@arr) { - say 'Input: @arr = (' ~ @arr.join(', ') ~ ')'; - say 'Output: (' ~ @arr.join(', ') ~ ')'; +sub reversePrefix($str, $char) { + my $loc = $str.index($char) + 1; + $str.substr(0, $loc).flip ~ $str.substr($loc); +} + +sub solution($str, $char) { + say qq{Input: \$str = "$str", \$char = "$char"}; + my $result = reversePrefix($str, $char); + say qq{Output: "$result"}; } say "Example 1:"; -solution(); +solution("programming", "g"); say "\nExample 2:"; -solution(); +solution("hello", "h"); say "\nExample 3:"; -solution(); +solution("abcdefghij", "h"); say "\nExample 4:"; -solution(); +solution("reverse", "s"); say "\nExample 5:"; -solution(); +solution("perl","r"); -- cgit