aboutsummaryrefslogtreecommitdiff
path: root/challenge-121/mohammad-anwar
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-07-14 20:17:04 +0100
committerGitHub <noreply@github.com>2021-07-14 20:17:04 +0100
commitbbf09073ce0c20a456e3134885d24e2c4a4b28d3 (patch)
tree2a0a423d5130a0a650698cdbfa74448c8d25f17e /challenge-121/mohammad-anwar
parenta4238e8cc76d7a19d69fac649fd2debff35163c3 (diff)
downloadperlweeklychallenge-club-bbf09073ce0c20a456e3134885d24e2c4a4b28d3.tar.gz
perlweeklychallenge-club-bbf09073ce0c20a456e3134885d24e2c4a4b28d3.tar.bz2
perlweeklychallenge-club-bbf09073ce0c20a456e3134885d24e2c4a4b28d3.zip
Update ch-1.pl
Diffstat (limited to 'challenge-121/mohammad-anwar')
-rw-r--r--challenge-121/mohammad-anwar/perl/ch-1.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-121/mohammad-anwar/perl/ch-1.pl b/challenge-121/mohammad-anwar/perl/ch-1.pl
index 5dd0e3769c..27f20f2df4 100644
--- a/challenge-121/mohammad-anwar/perl/ch-1.pl
+++ b/challenge-121/mohammad-anwar/perl/ch-1.pl
@@ -1,5 +1,29 @@
#!/usr/bin/perl
+=head1 Task #1: Invert Bit
+
+You are given integers 0 <= $m <= 255 and 1 <= $n <= 8.
+
+Write a script to invert $n bit from the end of the binary representation of $m and print the decimal representation of the new binary number.
+
+=head1 Example
+
+ Input: $m = 12, $n = 3
+ Output: 8
+
+ Binary representation of $m = 00001100
+ Invert 3rd bit from the end = 00001000
+ Decimal equivalent of 00001000 = 8
+
+ Input $m = 18, $n = 4
+ Output: 26
+
+ Binary representation of $m = 00010010
+ Invert 4th bit from the end = 00011010
+ Decimal equivalent of 00011010 = 26
+
+=cut
+
use strict;
use warnings;
use Test::More;