diff options
| author | Simon Green <mail@simon.green> | 2021-06-29 17:44:48 +1000 |
|---|---|---|
| committer | Simon Green <mail@simon.green> | 2021-06-29 17:44:48 +1000 |
| commit | 77f2c0da8089704b72b5d8d44ace1511ee25e443 (patch) | |
| tree | 33f549fb5d8221a1ad84e2baab341e28733aec57 | |
| parent | 37235293508cc0923d6e88bcfea6cf833be713a2 (diff) | |
| download | perlweeklychallenge-club-77f2c0da8089704b72b5d8d44ace1511ee25e443.tar.gz perlweeklychallenge-club-77f2c0da8089704b72b5d8d44ace1511ee25e443.tar.bz2 perlweeklychallenge-club-77f2c0da8089704b72b5d8d44ace1511ee25e443.zip | |
sgreen solution to challenge 119
| -rw-r--r-- | challenge-119/sgreen/README.md | 4 | ||||
| -rw-r--r-- | challenge-119/sgreen/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-119/sgreen/perl/ch-1.pl | 18 | ||||
| -rwxr-xr-x | challenge-119/sgreen/perl/ch-2.pl | 22 |
4 files changed, 43 insertions, 2 deletions
diff --git a/challenge-119/sgreen/README.md b/challenge-119/sgreen/README.md index 64b6aa2762..ed9cc17ef6 100644 --- a/challenge-119/sgreen/README.md +++ b/challenge-119/sgreen/README.md @@ -1,3 +1,3 @@ -# The Weekly Challenge 118 +# The Weekly Challenge 119 -Solution by Simon Green. [Blog](https://dev.to/simongreennet/weekly-challenge-118-4hg9) +Solution by Simon Green. [Blog](https://dev.to/simongreennet/weekly-challenge-119-79j) diff --git a/challenge-119/sgreen/blog.txt b/challenge-119/sgreen/blog.txt new file mode 100644 index 0000000000..647ec1cd10 --- /dev/null +++ b/challenge-119/sgreen/blog.txt @@ -0,0 +1 @@ +https://dev.to/simongreennet/weekly-challenge-119-79j diff --git a/challenge-119/sgreen/perl/ch-1.pl b/challenge-119/sgreen/perl/ch-1.pl new file mode 100755 index 0000000000..0e51d241fd --- /dev/null +++ b/challenge-119/sgreen/perl/ch-1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature 'say'; + +sub main { + my $number = shift; + + # Sanity check + die "You must specify a positive integer\n" unless defined $number; + die "The value doesn't appear to be a positive integer\n" unless $number =~ /^[1-9][0-9]*$/; + die "The value has to be less than 256\n" unless $number < 256; + + say +( $number >> 4 ) + ( $number & 15 ) * 16; +} + +main(@ARGV); diff --git a/challenge-119/sgreen/perl/ch-2.pl b/challenge-119/sgreen/perl/ch-2.pl new file mode 100755 index 0000000000..5b11b15910 --- /dev/null +++ b/challenge-119/sgreen/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature 'say'; + +sub main { + my $counter = shift; + + # Sanity check + die "You must specify a positive integer\n" unless defined $counter; + die "The value doesn't appear to be a positive integer\n" unless $counter =~ /^[1-9][0-9]*$/; + + my $number = 0; + while ( $counter and ++$number ) { + --$counter if $number =~ /^[123]*$/ and index( $number, '11' ) == -1; + } + say $number; +} + +main(@ARGV); + |
