Robbie Hatley's Solutions To The Weekly Challenge #219

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-28 through 2023-06-03) is weekly challenge #219.

Task 1 is as follows:

"Given a list of numbers, write a script to square each number in the list and return the sorted list of squares in increasing order."

This is literally just a 1-liner: "my @squares = sort {$a<=>$b} map {$_*$_} @$aref;". My finished program looks like this:

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

Task 2 is as follows:

You are given two list, @costs and @days.
The list @costs contains the cost of three different types 
of travel cards you can buy.
For example @costs = (5, 30, 90)
Index 0 element represent the cost of  1 day  travel card.
Index 1 element represent the cost of  7 days travel card.
Index 2 element represent the cost of 30 days travel card.
The list @days contains the day number you want to travel 
in the year.
For example: @days = (1, 3, 4, 5, 6)
The above example means you want to travel on day 1, day 3, 
day 4, day 5 and day 6 of the year.
Write a script to find the minimum travel cost.

Yikes. That's way beyond what I had time for this week. (It's been a very hectic, tiring week for me.) So unfortunately, I'm going to have to skip 219-2.

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

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