he first order of the day was to clean up all the debugging code I peppered across my perl trying to find an answer to my 'Failed Signature' bug.
This did take a while and in the end the changes that I am sticking with are;
if ( my $xml_body = $self->_to_xml_body($call) ) {
$request->content($xml_body);
++ $request->header( 'content-type' => 'application/xml'); #this is an XML interface so it should have this header
}
A guest house had a policy that the light remain ON as long as the at least one guest is in the house. There is guest book which tracks all guest in/out time. Write a script to find out how long in minutes the light were ON.
1) Alex IN: 09:10 OUT: 09:45
2) Arnold IN: 09:15 OUT: 09:33
3) Bob IN: 09:22 OUT: 09:55
4) Charlie IN: 09:25 OUT: 10:05
5) Steve IN: 09:33 OUT: 10:01
6) Roger IN: 09:44 OUT: 10:12
7) David IN: 09:57 OUT: 10:23
8) Neil IN: 10:01 OUT: 10:19
9) Chris IN: 10:10 OUT: 11:00
Spoiler Alert: This weekly challenge deadline is due in a few hours. 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: Linked List Partition
You are given a linked list and a value k. Write a script to partition the linked list such that all nodes less than k come before nodes greater than or equal to k. Make sure you preserve the original relative order of the nodes in each of the two partitions.
Now that I have at least one call working 'ListJobs' I reran the full test suit and to my surprise I got no fails. So maybe it is going to be an easy ride?
Well I was dead wrong.
Just spent the last few days banging my head against the AWS servers thinking that if the first 825 attempts to get 'CreateJob' to work, the 826th would of work.
Well lets just say 826 attempt is most likely an order of magnitude under the number of differing combinations and iterations I went though on getting the call working all with the same failed of '403' status and the error 'SignatureDoesNotMatch'!
No spoilers here, just a rambling. There are probably countless times when one relies on the genius of others to complete tasks. If PerlWeeklyChallenges has shown me one thing, it is that there is probably nothing I can do that someone else can not do better, more efficiently, and more robustly. The key to good coding, one imagines, is to have code that survives not just the scenario presented in the challenge, but also accommodates other scenarios
The Hotel lights
Take the lights on puzzle. A first glance at the puzzle show that the times are all overlapping, so technically the lights should be on continuously from the first guest entry to last exit. So the simplest way to extract the time the lights were on is to get the earliest time and the latest time mentioned in the log. These can be extracted using four steps: load the log, extract the earliest and the last time; convert to minutes and subtract.
Continuing on from the
intention
of clustering data in Perl (a form of unsupervised learning), I'm going to start with
PDL::Stats::Kmeans
and see how far I can get.
Let's just plunge in and use the module
and read the documentation after to figure out what it all k-means. (sorry)
Spoiler Alert: This weekly challenge deadline is due in a couple of days (May 3, 2020). 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: Compare Versions
Compare two given version number strings v1 and v2 such that:
- If v1 > v2 return 1- If v1 < v2 return -1- Otherwise, return 0
The version numbers are non-empty strings containing only digits, and the dot (“.”) and underscore (“”) characters. (“” denotes an alpha/development version, and has a lower precedence than a dot, “.”). Here are some examples:
Well I was just about ready to check everything in on S3 Paws and move onto the next part of Paws that need some love and kindness when I did one last review of all the test cases I have created over the past little while when I discovered I had left one out.
I forgot to add in a request test case for the 'DeleteBucketMetricsConfiguration' action. It took the opportunity to use my new test generator a spin as well so I fired up my real world call with the new caller and much to my chagrin I got an error;
'The specified configuration does not exist.',
Which could be the case as the Bucket I was playing with may not have a 'Metrics Configuration' on it. So I dusted off another test that does both 'PUT and 'GET' and then I slapped my 'DELETE' on the end and this was the result;
Spoiler Alert: This weekly challenge deadline is due in a couple of hours. 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: Tree Inversion
You are given a full binary tree of any height, similar to the one below:
1
/ \
2 3
/ \ / \
4 5 6 7
Write a script to invert the tree, by mirroring the children of every node, from left to right. The expected output from the tree above would be:
Why, oh why, can't I post a comment on blogs.perl.org? I'm properly signed in. I read a post, 30 seconds later. 30 seconds later, I click the button at the bottom of the post in order to post a reply. I fill in the form with my post. Then I get this error:
---
Comment Submission Error
Your comment submission failed for the following reasons: Your session has expired. Please sign in again to comment.
Return to the original entry.
---
And there is no avoiding it, even after signing in again.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (April 19, 2020). 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: Diff-k
You are given an array @N of positive integers (sorted) and another non negative integer k.
Write a script to find if there exists 2 indices i and j such that A[i] - A[j] = k and i != j.
It should print the pairs of indices, if any such pairs exist.
My morning started today with a cup of cold tea and an IRC request. The latter was coming from Elizabeth Mattijsen asking to write a paragraph on my recently merged work on Raku roles. There was a little problem though: I have no idea how to fit it into a single paragraph! And so I was left with no choice but to start blogging for the first time in many years.
Note. For those of you who consider themselves Raku experts I'd rather recommend skipping the next two sections and proceed directly to the technical details in Changes.
Once upon a time...
... there was a project which I was implementing to support a my boss' project. The structure of the code was heavily based on roles. This is the pattern I tend to use: split functionality into manageable as small as possible pieces and compose them into final code.
In my previous post I added a footnote that "use.perl.org is difficult to get info out of now, it's basically dead. A lot of content is lost". That turned out to be not entirely true, it just needed some work to get to it
In the reddit comments, brian d foy mentioned Léon's WWW::UsePerl::Server, a module to host the use.perl.org archive.
I grabbed the archive, Léon's module, installed all the deps, got it up and running after hacking the module to work with the latest Catalyst, then combined some sed, awk, perl, SQL to create a static version of the site with URLs that allow it to function correctly: https://use-perl.github.io/. Note that the change in the URL structure to get it to work a) as a static site, and b) on github pages, means that any "permalinks" that might exist elsewhere in reference to it will need manual fiddling to get to the page in question - the URL structure should be relatively obvious however.
In my blog post related to Perl Weekly Challenge 54 posted on April 4, 2020, the section about the "extra credit" task concerning the Collatz conjecture described in some details the difficulties encountered when trying to cache the data: the volume of data is very large. I'm blogging again on the subject because of new findings.
The Collatz conjecture concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. For example, the Collatz sequence for 23 is this: