aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-12-23 14:33:04 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2021-12-23 14:33:04 +0000
commitce5bd2dd1a3159107febe4b9eb488a071bc601f5 (patch)
treefe414d6bf26de2b2c6682c2b399ace41a24492cf
parent9f83fe38e24a005d07ee31c0c53582f3eefbc9e5 (diff)
downloadperlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.tar.gz
perlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.tar.bz2
perlweeklychallenge-club-ce5bd2dd1a3159107febe4b9eb488a071bc601f5.zip
Whitespace
-rw-r--r--challenge-032/paulo-custodio/perl/ch-1.pl18
-rw-r--r--challenge-032/paulo-custodio/perl/ch-2.pl24
-rw-r--r--challenge-032/paulo-custodio/python/ch-1.py8
-rw-r--r--challenge-032/paulo-custodio/python/ch-2.py10
-rw-r--r--challenge-032/paulo-custodio/t/test-2.yaml2
5 files changed, 31 insertions, 31 deletions
diff --git a/challenge-032/paulo-custodio/perl/ch-1.pl b/challenge-032/paulo-custodio/perl/ch-1.pl
index 527d5ae4c2..5770faa607 100644
--- a/challenge-032/paulo-custodio/perl/ch-1.pl
+++ b/challenge-032/paulo-custodio/perl/ch-1.pl
@@ -8,9 +8,9 @@
# Create a script that either reads standard input or one or more files
# specified on the command-line. Count the number of times and then print a
# summary, sorted by the count of each entry.
-#
+#
# So with the following input in file example.txt
-#
+#
# apple
# banana
# apple
@@ -18,12 +18,12 @@
# cherry
# apple
# the script would display something like:
-#
+#
# apple 3
# cherry 2
# banana 1
# For extra credit, add a -csv option to your script, which would generate:
-#
+#
# apple,3
# banana,1
# cherry,2
@@ -33,18 +33,18 @@ use Modern::Perl;
# command line options
my $sep = "\t";
if (@ARGV && $ARGV[0] eq '-csv') {
- $sep = ",";
- shift;
+ $sep = ",";
+ shift;
}
# count instances
my %count;
while (<>) {
- chomp;
- $count{$_}++;
+ chomp;
+ $count{$_}++;
}
# output
for my $key (sort keys %count) {
- say $key, $sep, $count{$key};
+ say $key, $sep, $count{$key};
}
diff --git a/challenge-032/paulo-custodio/perl/ch-2.pl b/challenge-032/paulo-custodio/perl/ch-2.pl
index 1fafbc0eb9..883a9ae6c8 100644
--- a/challenge-032/paulo-custodio/perl/ch-2.pl
+++ b/challenge-032/paulo-custodio/perl/ch-2.pl
@@ -8,13 +8,13 @@
# Write a function that takes a hashref where the keys are labels and the
# values are integer or floating point values. Generate a bar graph of the
# data and display it to stdout.
-#
+#
# The input could be something like:
-#
+#
# $data = { apple => 3, cherry => 2, banana => 1 };
# generate_bar_graph($data);
# And would then generate something like this:
-#
+#
# apple | ############
# cherry | ########
# banana | ####
@@ -28,15 +28,15 @@ use List::Util 'max';
my $data = { apple => 3, cherry => 2, banana => 1 };
sub chart {
- my($data) = @_;
-
- # get size of keys
- my $width = max(map {length($_)} keys %$data);
-
- # output data
- for my $key (sort keys %$data) {
- say sprintf("%*s | %s", $width, $key, "##" x $data->{$key});
- }
+ my($data) = @_;
+
+ # get size of keys
+ my $width = max(map {length($_)} keys %$data);
+
+ # output data
+ for my $key (sort keys %$data) {
+ say sprintf("%*s | %s", $width, $key, "##" x $data->{$key});
+ }
}
chart($data);
diff --git a/challenge-032/paulo-custodio/python/ch-1.py b/challenge-032/paulo-custodio/python/ch-1.py
index 2a600a8112..717d0f8ded 100644
--- a/challenge-032/paulo-custodio/python/ch-1.py
+++ b/challenge-032/paulo-custodio/python/ch-1.py
@@ -8,9 +8,9 @@
# Create a script that either reads standard input or one or more files
# specified on the command-line. Count the number of times and then print a
# summary, sorted by the count of each entry.
-#
+#
# So with the following input in file example.txt
-#
+#
# apple
# banana
# apple
@@ -18,12 +18,12 @@
# cherry
# apple
# the script would display something like:
-#
+#
# apple 3
# cherry 2
# banana 1
# For extra credit, add a -csv option to your script, which would generate:
-#
+#
# apple,3
# banana,1
# cherry,2
diff --git a/challenge-032/paulo-custodio/python/ch-2.py b/challenge-032/paulo-custodio/python/ch-2.py
index e8956935b6..6a0b7385c7 100644
--- a/challenge-032/paulo-custodio/python/ch-2.py
+++ b/challenge-032/paulo-custodio/python/ch-2.py
@@ -8,13 +8,13 @@
# Write a function that takes a hashref where the keys are labels and the
# values are integer or floating point values. Generate a bar graph of the
# data and display it to stdout.
-#
+#
# The input could be something like:
-#
+#
# $data = { apple => 3, cherry => 2, banana => 1 };
# generate_bar_graph($data);
# And would then generate something like this:
-#
+#
# apple | ############
# cherry | ########
# banana | ####
@@ -25,10 +25,10 @@
data = { 'apple':3, 'cherry':2, 'banana':1 }
def chart(data):
- # get size of keys
+ # get size of keys
width = max([len(x) for x in data])
- # output data
+ # output data
for key in sorted(data):
print(("{:"+str(width)+"s} | {}").format(key, "##"*data[key]))
diff --git a/challenge-032/paulo-custodio/t/test-2.yaml b/challenge-032/paulo-custodio/t/test-2.yaml
index c55ff3e3a1..a52de03332 100644
--- a/challenge-032/paulo-custodio/t/test-2.yaml
+++ b/challenge-032/paulo-custodio/t/test-2.yaml
@@ -1,6 +1,6 @@
- setup:
cleanup:
- args:
+ args:
input:
output: |
| apple | ######