Posts

Showing posts from April, 2023

Robbie Hatley's Perl Solutions To The Weekly Challenge #213

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-04-16 through 2023-04-22) is weekly challenge #213. Task 1 is as follows: "Write a script to sort a list of positive integers so that the sorted list consists of the even integers in ascending order followed by the odd integers in ascending order." I found this super-simple: Robbie Hatley's Perl Solution to The Weekly Challenge 213-1 Task 2 is as follows: You are given a list of bidirectional routes defining a network of nodes, as well as source and destination node numbers. Write a script to find the route from source to destination that passes through fewest nodes. That one, I didn't have time to complete, but here's a stub, as far as I got with it: Robbie Hatley's Perl Solution to The Weekly Challenge 212-2 That's it for 213; see you

Robbie Hatley's Perl Solutions To The Weekly Challenge #212

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-04-09 through 2023-04-15) is weekly challenge #212. Task 1 is as follows: You are given a word having alphabetic characters only, and a list of positive integers of the same length. Write a script to print the new word generated after jumping forward each letter in the given word by the integer in the list. The given list would have exactly the number as the total alphabets in the given word. This is like a Caesar cipher but with the added kink that every index within the plaintext gets rotated an independent amount. I found it very straightforward to program, just a matter of doing chr(65 + (ord($a)-65+$j)%26) for uppercase and chr(97 + (ord($a)-97+$j)%26) for lowercase: Robbie Hatley's Perl Solution to The Weekly Challenge 212-1 Task 2 is as follows: You are given a

Robbie Hatley's Perl Solutions To The Weekly Challenge #211

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-04-02 through 2023-04-08) is weekly challenge #211. Task 1 is as follows: You are given a matrix m x n. Write a script to find out if the given matrix is Toeplitz Matrix. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. For some reason this gave me more trouble than Task 2 below even though that one was conceptually harder. I guess I just found it annoying that I had to riffle through columns of all different lengths. My approach turned out to use... can you guess?... yep, nested 3-part loops again. :-) I do tend to use those a lot. Check it out: Robbie Hatley's Perl Solution to The Weekly Challenge 211-1 Task 2 is as follows: You are given an array of integers. Write a script to find out if the given can be split into two se