aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-114/abigail/README.md1
-rw-r--r--challenge-114/abigail/blog1.txt1
-rw-r--r--challenge-114/abigail/perl/ch-2.pl21
3 files changed, 4 insertions, 19 deletions
diff --git a/challenge-114/abigail/README.md b/challenge-114/abigail/README.md
index 174d509623..7548aee37d 100644
--- a/challenge-114/abigail/README.md
+++ b/challenge-114/abigail/README.md
@@ -55,3 +55,4 @@ higher integer is `17` having the same number of `1` bits i.e. `10001`.
* [Perl](perl/ch-2.pl)
### Blog
+[Higher Integet Set Bits](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-114-2.html)
diff --git a/challenge-114/abigail/blog1.txt b/challenge-114/abigail/blog1.txt
new file mode 100644
index 0000000000..aee5ae3122
--- /dev/null
+++ b/challenge-114/abigail/blog1.txt
@@ -0,0 +1 @@
+https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-114-2.html
diff --git a/challenge-114/abigail/perl/ch-2.pl b/challenge-114/abigail/perl/ch-2.pl
index 681ba2d601..61e2ddf1ea 100644
--- a/challenge-114/abigail/perl/ch-2.pl
+++ b/challenge-114/abigail/perl/ch-2.pl
@@ -18,26 +18,9 @@ use experimental 'lexical_subs';
#
#
-# We will look at the end of the binary expansion of the input number.
-# In particular, we're interested in the last group of 1s. Any positive
-# integer ends when written in binary as:
+# For a description of the algorithm, see
+# https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-114-2.html
#
-# 011...1100...00
-#
-# with 1 or more 1s, and 0 or more 0s at the end (note that we might
-# need to add a leading 0).
-#
-# The next number with the same amount of bits can be found by swapping
-# the '01' pair, and swapping the sequences of 1s and 0s.
-#
-# Code wise, if the input number (after turning it into a binary
-# representation and after adding a leading 0) matches /^(.*)(01)(1*)(0*)$/,
-# the binary representation of the wanted output number is "${1}10${2}${3}".
-#
-# We will be using 'sprintf "0b0%b"' to get the binary representation of
-# a number (including a leading 0 and a leading "0b"), and 'oct' to go
-# from a binary representation back to a number (for which we need the
-# leading "0b").
say oct sprintf ("0b0%b" => $_) =~ s {01(1*)(0*)$} {10$2$1}r while <>;