diff options
| -rw-r--r-- | challenge-278/paulo-custodio/Makefile | 2 | ||||
| -rw-r--r-- | challenge-278/paulo-custodio/perl/ch-1.pl | 35 | ||||
| -rw-r--r-- | challenge-278/paulo-custodio/perl/ch-2.pl | 34 | ||||
| -rw-r--r-- | challenge-278/paulo-custodio/t/test-1.yaml | 15 | ||||
| -rw-r--r-- | challenge-278/paulo-custodio/t/test-2.yaml | 15 |
5 files changed, 101 insertions, 0 deletions
diff --git a/challenge-278/paulo-custodio/Makefile b/challenge-278/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-278/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-278/paulo-custodio/perl/ch-1.pl b/challenge-278/paulo-custodio/perl/ch-1.pl new file mode 100644 index 0000000000..726d509125 --- /dev/null +++ b/challenge-278/paulo-custodio/perl/ch-1.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl + +# Challenge 278 +# +# Task 1: Sort String +# Submitted by: Mohammad Sajid Anwar +# +# You are given a shuffle string, $str. +# +# Write a script to return the sorted string. +# +# A string is shuffled by appending word position to each word. +# +# Example 1 +# +# Input: $str = "and2 Raku3 cousins5 Perl1 are4" +# Output: "Perl and Raku are cousins" +# +# Example 2 +# +# Input: $str = "guest6 Python1 most4 the3 popular5 is2 language7" +# Output: "Python is the most popular guest language" +# +# Example 3 +# +# Input: $str = "Challenge3 The1 Weekly2" +# Output: "The Weekly Challenge" + +use Modern::Perl; + +say join(' ', + map { $_->[0] } + sort { $a->[1] <=> $b->[1] } + map { /(.*)(\d+)$/; [$1, $2] } + @ARGV); diff --git a/challenge-278/paulo-custodio/perl/ch-2.pl b/challenge-278/paulo-custodio/perl/ch-2.pl new file mode 100644 index 0000000000..43636b2692 --- /dev/null +++ b/challenge-278/paulo-custodio/perl/ch-2.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl + +# Challenge 278 +# +# Task 2: Reverse Word +# Submitted by: Mohammad Sajid Anwar +# +# You are given a word, $word and a character, $char. +# +# Write a script to replace the substring up to and including $char with its +# characters sorted alphabetically. If the $char doesn’t exist then DON'T do +# anything. +# +# Example 1 +# +# Input: $str = "challenge", $char = "e" +# Ouput: "acehllnge" +# +# Example 2 +# +# Input: $str = "programming", $char = "a" +# Ouput: "agoprrmming" +# +# Example 3 +# +# Input: $str = "champion", $char = "b" +# Ouput: "champion" + +use Modern::Perl; + +@ARGV==2 or die "Usage: $0 word letter\n"; +my($word, $letter) = @ARGV; + +say $word =~ s{.*?$letter}{ join '', sort split //, $& }er; diff --git a/challenge-278/paulo-custodio/t/test-1.yaml b/challenge-278/paulo-custodio/t/test-1.yaml new file mode 100644 index 0000000000..4ac0fc3d76 --- /dev/null +++ b/challenge-278/paulo-custodio/t/test-1.yaml @@ -0,0 +1,15 @@ +- setup: + cleanup: + args: and2 Raku3 cousins5 Perl1 are4 + input: + output: Perl and Raku are cousins +- setup: + cleanup: + args: guest6 Python1 most4 the3 popular5 is2 language7 + input: + output: Python is the most popular guest language +- setup: + cleanup: + args: Challenge3 The1 Weekly2 + input: + output: The Weekly Challenge diff --git a/challenge-278/paulo-custodio/t/test-2.yaml b/challenge-278/paulo-custodio/t/test-2.yaml new file mode 100644 index 0000000000..0d132f73ec --- /dev/null +++ b/challenge-278/paulo-custodio/t/test-2.yaml @@ -0,0 +1,15 @@ +- setup: + cleanup: + args: challenge e + input: + output: acehllnge +- setup: + cleanup: + args: programming a + input: + output: agoprrmming +- setup: + cleanup: + args: champion b + input: + output: champion |
