diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-25 20:07:40 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-26 00:06:54 +0000 |
| commit | 3fa58628535d4041c7cc648c005080ca88f18c18 (patch) | |
| tree | 336fe3cc14f518f05e871ab974cc86a09a2fd8f6 /challenge-026 | |
| parent | 3d3900a2f0f69c54a34683e4e1b5da007b4af9d9 (diff) | |
| download | perlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.tar.gz perlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.tar.bz2 perlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.zip | |
Replace tabs by spaces so that indentation looks correct
Diffstat (limited to 'challenge-026')
| -rw-r--r-- | challenge-026/paulo-custodio/perl/ch-1.pl | 14 | ||||
| -rw-r--r-- | challenge-026/paulo-custodio/perl/ch-2.pl | 34 | ||||
| -rw-r--r-- | challenge-026/paulo-custodio/test.pl | 8 |
3 files changed, 28 insertions, 28 deletions
diff --git a/challenge-026/paulo-custodio/perl/ch-1.pl b/challenge-026/paulo-custodio/perl/ch-1.pl index ae55779dda..7b608db30d 100644 --- a/challenge-026/paulo-custodio/perl/ch-1.pl +++ b/challenge-026/paulo-custodio/perl/ch-1.pl @@ -3,11 +3,11 @@ # Challenge 026 # # Task #1 -# Create a script that accepts two strings, let us call it, “stones” and -# “jewels”. It should print the count of “alphabet” from the string “stones” +# Create a script that accepts two strings, let us call it, “stones” and +# “jewels”. It should print the count of “alphabet” from the string “stones” # found in the string “jewels”. For example, if your stones is “chancellor” and -# “jewels” is “chocolate”, then the script should print “8”. To keep it simple, -# only A-Z,a-z characters are acceptable. Also make the comparison case +# “jewels” is “chocolate”, then the script should print “8”. To keep it simple, +# only A-Z,a-z characters are acceptable. Also make the comparison case # sensitive. use strict; @@ -17,7 +17,7 @@ use 5.030; say count(@ARGV); sub count { - my($letters, $word) = @_; - my %letters; $letters{$_}=1 for grep {/\w/} split //, $letters; - return scalar grep {$letters{$_}} split //, $word; + my($letters, $word) = @_; + my %letters; $letters{$_}=1 for grep {/\w/} split //, $letters; + return scalar grep {$letters{$_}} split //, $word; } diff --git a/challenge-026/paulo-custodio/perl/ch-2.pl b/challenge-026/paulo-custodio/perl/ch-2.pl index bbef0fec83..487024d364 100644 --- a/challenge-026/paulo-custodio/perl/ch-2.pl +++ b/challenge-026/paulo-custodio/perl/ch-2.pl @@ -3,9 +3,9 @@ # Challenge 026 # # Task #2 -# Create a script that prints mean angles of the given list of angles in degrees. +# Create a script that prints mean angles of the given list of angles in degrees. # Please read wiki page that explains the formula in details with an example. - + use strict; use warnings; use 5.030; @@ -15,19 +15,19 @@ use List::Util 'sum'; say mean(@ARGV); sub mean { - my(@a) = @_; - - # convert to radians - map {$_ = deg2rad($_)} @a; - - # compute sum of sin and cos - my $x = sum( map {cos($_)} @a ); - my $y = sum( map {sin($_)} @a ); - - # compute mean - my $a = atan2($y, $x); - - # convert back to degrees - $a = rad2deg($a); - return $a; + my(@a) = @_; + + # convert to radians + map {$_ = deg2rad($_)} @a; + + # compute sum of sin and cos + my $x = sum( map {cos($_)} @a ); + my $y = sum( map {sin($_)} @a ); + + # compute mean + my $a = atan2($y, $x); + + # convert back to degrees + $a = rad2deg($a); + return $a; } diff --git a/challenge-026/paulo-custodio/test.pl b/challenge-026/paulo-custodio/test.pl index aac0ec953d..6aaf2aa265 100644 --- a/challenge-026/paulo-custodio/test.pl +++ b/challenge-026/paulo-custodio/test.pl @@ -13,8 +13,8 @@ is capture("perl perl/ch-2.pl 0 45 90"), "45\n"; done_testing; sub capture { - my($cmd) = @_; - my $out = `$cmd`; - $out =~ s/[ \t\v\f\r]*\n/\n/g; - return $out; + my($cmd) = @_; + my $out = `$cmd`; + $out =~ s/[ \t\v\f\r]*\n/\n/g; + return $out; } |
