Perl Weekly Challenge 163: Sum Bitwise Operator and Summations
These are some answers to the Week 163 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on May 8, 2022 at 24:00). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Sum Bitwise Operator
You are given list positive numbers, @n.
Write script to calculate the sum of bitwise & operator for all unique pairs.
Example 1:
Input: @n = (1, 2, 3)
Output: 3
Since (1 & 2) + (2 & 3) + (1 & 3) => 0 + 2 + 1 => 3.
Example 2:
