Spoiler Alert: This weekly challenge deadline is due in a few days from now (on Aug. 16, 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: Prime Sum
I’ve written a Raku program to solve this task, but it is unfortunately a bit buggy: it works in most cases, but there are a few rare cases where it doesn’t find the minimum number of prime numbers whose summation gives you the target number. I certainly don’t want to publish here a program which I know to be faulty in some cases, and I no longer have time before the deadline to fix it. So, I’ll skip this task for now.
Perl has some really great community websites. But a drawback to this is that the Perl community is centred around a few domain names, which means that it isn't as visible as some other languages. Most projects use github for development and CPAN for distribution, and outside those sites, they don't have much online presence.
One thing I think might help spread Perl around the web would be if different Perl projects had their own websites.
The title is clickbait. I ran short of time this week and am ~~recycling~~^Wconsolidating comments, replies and thoughts. Let's talk about Books!
I would love a new PDL Book. One that's completely different from the original to maximize the surface of engagement to a new audience. As a "sequel", It would have the advantage of being able to refer the reader to the first book for longer explanations and be able to jump right into how to solve significant problems. brian d foy has just finished his Mojolicious book, so I bet he's got loads of free time on his hands. (although I remember him in the middle of writing it in 2018, so you may have to wait a bit)
I'm using the fabulous FFI::Platypus to interface to a C routine which uses caller-allocated buffers to return data. While FFI::Platypus transparently translates Perl arrays to C arrays and back, the buffers are used only to return data, so I only need the C-to-Perl conversion and not the Perl-to-C conversion.
The first step is to efficiently allocate a buffer of a given size in Perl (the last step, converting the retuned data in the buffer to Perl, is done straightforwardly with unpack).
If you do your due diligence, you'll find a link to an old PerlMonks post, which provides the following recipe:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (August 30, 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: Coins Sums
You are given a set of coins @C, assuming you have infinite amount of each coin in the set.
Write a script to find how many ways you make sum $S using the coins from the set @C.
I gave a talk at TPC 2019 based on my experiences speeding up the Perl test suite at room/roommate finding service SpareRoom, also serving as an introduction to the - just released at the time - Test2::Aggregate. The talk was a bit too dense, as I had prepared a pretty packed 20 minute presentation, only to realize a couple of days before (newbie speaker) that I had just 15 minutes real time excluding the Q&A. So, some attendees asked me to put up a blog post with the notes etc, and especially more about Test2::Aggregate, which is why I am writing this. I will try to give a longer and more detailed talk about the subject in one of the Perl conferences this summer.
In any case, the talk is up on youtube and gives an overview of the various lessons learned and techniques used while making our frustratingly slow 20 min test suite almost 10x faster, making a huge difference in our dev process:
The start of year 2020 didn't go well as planned. First my Dad was hospitalised and I had to make emergency travel plan to visit India. Luckily he is out of danger and back home. During this whole drama, the Perl Weekly Challenge got less of my attention. Thankfully I had loads of support messages throughout. Some offered to chip in so that I can focus on my Dad's health. I even missed my turn of editing Perl Weekly newsletter. It never happened ever since I joined the team of editors. Thanks to the chief edit, Gabor Szabo, I survived.
Another casualty of the January 2020, I missed submitting one Pull Request on everage in the month. I only submitted 22 Pull Requests. I have done this non-stop since October 2017. Sufferings didn't stop there, I couldn't get the monthly report published on the 1st Feb as per the tradition. It got delayed by 2 days.
The square secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right.
For example, the message is “The quick brown fox jumps over the lazy dog”. The code message would be as below:
tbjrd hruto eomhg qwpe unsl ifoa covz kxey
Let’s start with the test:
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;
is square_secret_code('The quick brown fox jumps over the lazy dog'),
'tbjrd hruto eomhg qwpe unsl ifoa covz kxey',
'encode';
Spoiler Alert: This weekly challenge deadline is due in a few hours from now. 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: Majority Element
You are given an array of integers of size $N.
Write a script to find the majority element. If none found then print -1.
Majority element in the list is the one that appears more than floor(size_of_list/2).
Example 1:
Input: @A = (1, 2, 2, 3, 2, 4, 2)
Output: 2, as 2 appears 4 times in the list which is more than floor(7/2).
Example 2:
Input: @A = (1, 3, 1, 2, 4, 5)
Output: -1 as none of the elements appears more than floor(6/2).
LANraragi is a web application for archival and reading of manga/doujinshi. It's lightweight and Docker-ready for NAS/servers. There is even a standing offer from the author to send out a free sticker pack for the first person to run the linux/s390x docker image on a real IBM System 390.
Several YAML modules allow loading and dumping objects.
When loading untrusted data, this can be a security vulnerability, if this
feature is enabled.
You can create any kind of object with YAML. The creation itself is
not the critical part, but if the class has a DESTROY method, it will be
called once the object is deleted. An example with File::Temp removing
files can be found here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862373
YAML::Syck had the option to disable this
feature via $YAML::Syck::LoadBlessed for a long time. Since 2018, also
YAML.pm and
YAML::XS have this variable.
You are given a string “123456789”. Write a script that would insert ”+” or ”-” in between digits so that when you evaluate, the result should be 100.
We can populate each place “between digits” with one of three possible values: a plus sign, minus sign, or nothing. To check all the possible permutations, we’ll use an indicator function similarly to The Knapsack Problem. In this case, though, there are three possible values, so we need to loop over numbers in the ternary numeral system.
The only operation we’ll need will be the increment, so we don’t need the full support for arithmetic in base 3. We can implement the increment ourselves: we start from the right of the number, change any 2 into 0 and move left. Once we find 0 or 1, we increment it and we’re done.
To create the expression, we just need to intersperse the digits with the operators. See the apply subroutine below.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on Aug. 16, 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: Min Sliding Window
You are given an array of integers @A and sliding window size $S.
Write a script to create an array of min from each sliding window.
We are really happy to announce that Curtis “Ovid” Poe will present a keynote at the
22nd Perl/Raku workshop in March in Erlangen!
Curtis runs Tau Station and is a long time contributor
to the workshop.
The list of accepted talks has grown, with varied topics from
“Progressing from Humans to Developers”, “A new Lisp, in Perl” and
“Querying the Etherum Blockchain Nodes with Raku”. All accepted talks
are listed here .
Since we still have some slots free for talks, we have extended the deadline
for talk submission to the 3rd February 2020. If you have a topic you want
to present, please submit your talk .
We’d also like to thank our sponsors for supporting the Perl and Raku community
Well it looks like a wrap for PAWS XML as the last thing I am working on is getting the test suite to pass
Looking at S3 I have only 1 error with the 09_requestst.t test suite;
ok 829 - Call S3->SelectObjectContent from t/09_requests/s3-select-object-content.request
not ok 830 - Got content eq from request
# Failed test 'Got content eq from request'
# at t/09_requests.t line 123.
# got: '<SelectObjectContentRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><InputSerialization><CompressionType>NONE</CompressionType></InputSerialization><OutputSerialization><CSV><FieldDelimiter>\,</FieldDelimiter><QuoteCharacter>\'</QuoteCharacter><QuoteEscapeCharacter>\"</QuoteEscapeCharacter><QuoteFields>ASNEEDED</QuoteFields><RecordDelimiter>\\n</RecordDelimiter></CSV></OutputSerialization><Expression>MyExpression</Expression><ExpressionType>SQL</ExpressionType></SelectObjectContentRequest>'
# expected: '<InputSerialization><CompressionType>NONE</CompressionType></InputSerialization><OutputSerialization><CSV><FieldDelimiter>\,</FieldDelimiter><QuoteCharacter>\'</QuoteCharacter><QuoteEscapeCharacter>\"</QuoteEscapeCharacter><QuoteFields>ASNEEDED</QuoteFields><RecordDelimiter>\\n</RecordDelimiter></CSV></OutputSerialization>'
I rechecked the API and my real world test and found the action 'SelectObjectContent
' it is a one off case in S3 that requires the root tag and the 'xmlns' to be present;
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.
Since both tasks in this week challenge are quite simple, I decided to use only one-liners to solve each task, both in Raku and in Perl.
Task 1: Trailing Zeros
You are given a positive integer $N (<= 10).
Write a script to print number of trailing zeroes in $N!.
Example 1:
Input: $N = 10
Output: 2 as $N! = 3628800 has 2 trailing zeroes
Example 2
Input: $N = 7
Output: 1 as $N! = 5040 has 1 trailing zero
When
last we saw our heroes,
what they thought was
the brink of success turned out to be the precipice
of hasty interpretation and now they are dangling
for dear life on the branch of normalization!
how's that for tortured metaphor!
If you use raw values for your
k-means clustering,
dimensions with large values or large ranges can
swamp smaller dimensions and skew your clusters.
The process of normalization tries to bring everything
into the same range, usually [0,1], although your choices
on how to transform the ranges are also significant.
There is not always one best way to do it and,
as usual, get familiar with your dataset and use
your judgement.
For over a decade now, I've been running public training classes in both presentation skills
and software development in conjunction with the Swiss Institute of Bioinformatics,
the University of Lausanne, and the École Polytechnique Fédérale de Lausanne.
This year, in the week of March 9-13, we're offering my full set of
Presentation Skills classes as a three-day sequence (though, of course, you can also sign up
for just one or two of the classes, if you prefer):
These two classes are based on my popular Perl courses on these topics, but I've now
redesigned and adapted them to be entirely language-neutral, so they're equally useful
to developers working in any other mainstream language(s).
Finally things were looking my way. I plowed thought the remaining CloudFront actions and got them all to work without any more changes to Paws.
In the end I checked in 30+ new tests cases and over 2k of tests the other day. So I can safely say that 'CloudFront' is fully operational.
That leaves only 'Route53' to look and for me this is somewhat problematic. The Route53 api deals with 'Domains', 'Checks', 'Hosts', 'Traffic' and such. To test 90% of the actions in this API you will need
Have at least one registered DNS domains to start
Know how to create a Hosts for a Domain
Know how to config a Host for a Domain and most importantly
Have some spare cash to pay for all the actions you are mucking with
As I fail on all 4 of the above I am not comfortable with creating working scrips for this API.