diff options
| author | corvettes13 <86648326+corvettes13@users.noreply.github.com> | 2021-07-02 10:09:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-02 10:09:40 -0500 |
| commit | c29db6e7df729967c26e749e9cf831bdb5b1d853 (patch) | |
| tree | 751d317f49ffc03fc2eb1d01853bd01353b1f2d9 | |
| parent | 5ca123778f0bf377a2de08729ca85509f1358d02 (diff) | |
| download | perlweeklychallenge-club-c29db6e7df729967c26e749e9cf831bdb5b1d853.tar.gz perlweeklychallenge-club-c29db6e7df729967c26e749e9cf831bdb5b1d853.tar.bz2 perlweeklychallenge-club-c29db6e7df729967c26e749e9cf831bdb5b1d853.zip | |
Update ch-1.pl
| -rw-r--r-- | challenge-119/paul-fajman/perl/ch-1.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-119/paul-fajman/perl/ch-1.pl b/challenge-119/paul-fajman/perl/ch-1.pl index 8175881325..5a96f61777 100644 --- a/challenge-119/paul-fajman/perl/ch-1.pl +++ b/challenge-119/paul-fajman/perl/ch-1.pl @@ -1,5 +1,23 @@ #/usr/bin/perl +# Weekly Challenge 119 +# You are given a positive integer $N. +# Write a script to swap the two nibbles of the binary representation of the +# given number and print the decimal number of the new binary representation. +# +# Input: $N = 101 +# Output: 86 + +# Binary representation of decimal 101 is 1100101 or as 2 nibbles (0110)(0101). +# The swapped nibbles would be (0101)(0110) same as decimal 86. + +# Input: $N = 18 +# Output: 33 + +# Binary representation of decimal 18 is 10010 or as 2 nibbles (0001)(0010). +# The swapped nibbles would be (0010)(0001) same as decimal 33. +############################## + use strict; use warnings; |
