Robbie Hatley's Solutions To The Weekly Challenge #218

For those not familiar with "The Weekly Challenge", it is a weekly programming puzzle, usually with two parts, cycling every Sunday. You can find it here:

The Weekly Challenge

This week (2023-05-21 through 2023-05-27) is weekly challenge #218.

Task 1 is as follows:

"Given a list of 3 or more integers, write a script to find the 3 integers whose product is maximum and return their product."

This is just a matter of trying all combinations and seeing which is max. I use the "Math::Combinatorics" CPAN module again (it's becoming one of my favorite go-to modules):

Robbie Hatley's Solution to The Weekly Challenge 218-1

Task 2 is as follows:

"You are given a m x n binary matrix i.e. having only 1 and 0. You are allowed to make as many moves as you want to get the highest score. A move can be either toggling each value in a row or column. To get the score, convert the each row binary to dec and return the sum."

Yikes. There is likely a "naive" approach to that using combinations of combinations, but it's likely very slow. And I just don't have time this week to come up with an efficient solution, due to work, governmental issues, illness, and other issues. So I'm afraid this is just a non-functional stub:

Robbie Hatley's Perl Solution to The Weekly Challenge 218-2

That's it for 218; see you on 219!

Comments

Popular posts from this blog

Robbie Hatley's Solutions To The Weekly Challenge #262

Robbie Hatley's Solutions To The Weekly Challenge #266

Robbie Hatley's Solutions To The Weekly Challenge #273