diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-10-26 09:52:33 +0100 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-10-26 09:52:33 +0100 |
| commit | 4fbb301ccb5620c8bcee20462bd1bb8145b0d13c (patch) | |
| tree | ca2cd6d56d2437c433c0913480dd769a0566911b /challenge-131 | |
| parent | de4d4e92a64a4cd61ae6db8da41662c88553772a (diff) | |
| download | perlweeklychallenge-club-4fbb301ccb5620c8bcee20462bd1bb8145b0d13c.tar.gz perlweeklychallenge-club-4fbb301ccb5620c8bcee20462bd1bb8145b0d13c.tar.bz2 perlweeklychallenge-club-4fbb301ccb5620c8bcee20462bd1bb8145b0d13c.zip | |
Whitespace
Diffstat (limited to 'challenge-131')
| -rw-r--r-- | challenge-131/paulo-custodio/perl/ch-1.pl | 28 | ||||
| -rw-r--r-- | challenge-131/paulo-custodio/perl/ch-2.pl | 18 | ||||
| -rw-r--r-- | challenge-131/paulo-custodio/python/ch-1.py | 6 | ||||
| -rw-r--r-- | challenge-131/paulo-custodio/python/ch-2.py | 8 | ||||
| -rw-r--r-- | challenge-131/paulo-custodio/t/test-2.yaml | 4 |
5 files changed, 32 insertions, 32 deletions
diff --git a/challenge-131/paulo-custodio/perl/ch-1.pl b/challenge-131/paulo-custodio/perl/ch-1.pl index 544735f33e..cb460b0440 100644 --- a/challenge-131/paulo-custodio/perl/ch-1.pl +++ b/challenge-131/paulo-custodio/perl/ch-1.pl @@ -3,10 +3,10 @@ # TASK #1 > Consecutive Arrays # Submitted by: Mark Anderson # You are given a sorted list of unique positive integers. -# +# # Write a script to return list of arrays where the arrays are consecutive # integers. -# +# # Example 1: # Input: (1, 2, 3, 6, 7, 8, 9) # Output: ([1, 2, 3], [6, 7, 8, 9]) @@ -28,16 +28,16 @@ my @output = cons_arrays(@input); say "[".join(", ", map {"[".join(", ", @$_)."]"} @output)."]"; sub cons_arrays { - my(@input) = @_; - my @output = [shift @input]; - while (@input) { - my $n = shift @input; - if ($n == $output[-1][-1] + 1) { - push @{$output[-1]}, $n; - } - else { - push @output, [$n]; - } - } - return @output; + my(@input) = @_; + my @output = [shift @input]; + while (@input) { + my $n = shift @input; + if ($n == $output[-1][-1] + 1) { + push @{$output[-1]}, $n; + } + else { + push @output, [$n]; + } + } + return @output; } diff --git a/challenge-131/paulo-custodio/perl/ch-2.pl b/challenge-131/paulo-custodio/perl/ch-2.pl index d37470a793..1252dd60eb 100644 --- a/challenge-131/paulo-custodio/perl/ch-2.pl +++ b/challenge-131/paulo-custodio/perl/ch-2.pl @@ -3,16 +3,16 @@ # TASK #2 > Find Pairs # Submitted by: Yary # You are given a string of delimiter pairs and a string to search. -# +# # Write a script to return two strings, the first with any characters # matching the "opening character" set, the second with any matching # the "closing character" set. -# +# # Example 1: # Input: # Delimiter pairs: ""[]() # Search String: "I like (parens) and the Apple ][+" they said. -# +# # Output: # "([" # ")]" @@ -20,7 +20,7 @@ # Input: # Delimiter pairs: **//<> # Search String: /* This is a comment (in some languages) */ <could be a tag> -# +# # Output: # /**/< # /**/> @@ -33,9 +33,9 @@ my $string = <>; my $open_delims = "["; my $close_delims = "["; while (length($delims) >= 2) { - $open_delims .= "\\".substr($delims,0,1); - $close_delims .= "\\".substr($delims,1,1); - $delims = substr($delims,2); + $open_delims .= "\\".substr($delims,0,1); + $close_delims .= "\\".substr($delims,1,1); + $delims = substr($delims,2); } $open_delims .= "]"; $close_delims .= "]"; @@ -43,8 +43,8 @@ $close_delims .= "]"; my $open_string; my $close_string; for my $c (split //, $string) { - $open_string .= $c if $c =~ /$open_delims/; - $close_string .= $c if $c =~ /$close_delims/; + $open_string .= $c if $c =~ /$open_delims/; + $close_string .= $c if $c =~ /$close_delims/; } say $open_string; diff --git a/challenge-131/paulo-custodio/python/ch-1.py b/challenge-131/paulo-custodio/python/ch-1.py index 3f047245c9..5ec166762f 100644 --- a/challenge-131/paulo-custodio/python/ch-1.py +++ b/challenge-131/paulo-custodio/python/ch-1.py @@ -3,10 +3,10 @@ # TASK #1 > Consecutive Arrays # Submitted by: Mark Anderson # You are given a sorted list of unique positive integers. -# +# # Write a script to return list of arrays where the arrays are consecutive # integers. -# +# # Example 1: # Input: (1, 2, 3, 6, 7, 8, 9) # Output: ([1, 2, 3], [6, 7, 8, 9]) @@ -34,4 +34,4 @@ def cons_arrays(input): input = [int(x) for x in sys.argv[1:]] output = cons_arrays(input) -print(output)
\ No newline at end of file +print(output) diff --git a/challenge-131/paulo-custodio/python/ch-2.py b/challenge-131/paulo-custodio/python/ch-2.py index 52fe765741..921bddd6bc 100644 --- a/challenge-131/paulo-custodio/python/ch-2.py +++ b/challenge-131/paulo-custodio/python/ch-2.py @@ -3,16 +3,16 @@ # TASK #2 > Find Pairs # Submitted by: Yary # You are given a string of delimiter pairs and a string to search. -# +# # Write a script to return two strings, the first with any characters # matching the "opening character" set, the second with any matching # the "closing character" set. -# +# # Example 1: # Input: # Delimiter pairs: ""[]() # Search String: "I like (parens) and the Apple ][+" they said. -# +# # Output: # "([" # ")]" @@ -20,7 +20,7 @@ # Input: # Delimiter pairs: **//<> # Search String: /* This is a comment (in some languages) */ <could be a tag> -# +# # Output: # /**/< # /**/> diff --git a/challenge-131/paulo-custodio/t/test-2.yaml b/challenge-131/paulo-custodio/t/test-2.yaml index 9fc70d6e9a..2229e7787c 100644 --- a/challenge-131/paulo-custodio/t/test-2.yaml +++ b/challenge-131/paulo-custodio/t/test-2.yaml @@ -1,6 +1,6 @@ - setup: cleanup: - args: + args: input: | ""[]() "I like (parens) and the Apple ][+" they said. @@ -9,7 +9,7 @@ ")]" - setup: cleanup: - args: + args: input: | **//<> /* This is a comment (in some languages) */ <could be a tag> |
