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.
Short post this time because I got
nerd-sniped
looking at the data. The fun part is that you quickly
move from thinking about how to get your results to trying
to work out what they mean.
Forget why I started down this road. Right now, we
are seeking the answer to Lewis Carol's famous question,
How is a Porsche 914-2 like a Volvo 142E?
(well, that's what it was in the first draft)
A quick summary for those who have just joined us.
After introducing KBOS I should write about the most fundamental concept in this Perl syntax extension. In fact it's so basic, you could use it even without objects.
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.
While Mojo::ACME was a fun experiment, it has several shortcomings at this point and I’ve officially stopped using it. If someone is interested in maintaining it, and if I’m sufficiently convinced of your credibility since this is a security module after all, I can hand it over. Otherwise I will be marking it as deprecated soon.
Technically, I already announced it, but now I've renamed it. MooX::Pression is now called Zydeco.
Moops had a memorable name, and I think the naming really helped it gain a following. MooX::Pression was just meh. So now it's Zydeco. Zydeco is a fun word and pretty short to type. It's a musical genre that blends jazz, blues, and Louisiana French Creole, and it just seemed like a good fit for a module that takes what I feel are some of the coolest features of Perl programming, and blends them together under one syntax.
Also, practising what I preach, Zydeco now has its own website.
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).
Encouraged by Enkidu I decided to write a little about my unsuccessful trial to run PDL Book example on Windows. It all started in December 2019 as I decided to learn Perl and looked for a way to create SVM (Support Vector Machine) model with it as I am able to do similar tasks in R or Python. As a side effect and to my surprise I have found that there exists such a thing as Perl Data Language (PDL) that has many modules suited for data science.
Intrigued by PDL I have installed Strawberry Perl 5.30.1.1 PDL edition. I followed first steps from
PDL book
and tried to install PDL::Graphics::Simple. Just ran typical installation with cpan and got an error:
Well back on my PAWS run again. This one might be a rather short series as I am really just looking at one Action in the Kinesis API 'SubscribeToShard'. There is an open bug for this one up on github https://github.com/pplu/aws-sdk-perl/issues/371 and one I think I can fix up fairly eaisy.
First things first, a little word on Kinesis. Well in short it touted as a very scalable real time data-stream thingy that sings dances and basically makes you line much better. Myself I do not havea use for it but it is part of the system and there is a bug so in I go.
I first had to set things up on the AWS server side with some permission etc the usualal srtuff I also had to run a number of command top build up my Kineses system to a point where I can actually use the 'SubscribeToShard'
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.
Starting even before Moose, we (in the Perl 5 world) have a plethora of Modules extending the syntax of the language with Perl 6 and more in mind. The following article sums up not only my 2 and a half cents on the subject but also an attempt to implement it. It should be of interest to anybody thinking about programming in general.
The test suite for MooX::Pression used to run in 79 seconds on my laptop. Now it's at 10 seconds.
And no, I didn't cut out any tests — I switched from using Keyword::Declare to a combination of Keyword::Simple and PPR. (Keyword::Declare is a wrapper around Keyword::Simple and PPR, but I found out by using them directly, I could massively improve compile-time speed.)
MooX::Pression allows you to build classes and roles with multimethods, types, method signatures, and sweet, sweet, sugary syntax…
AgoraCart, a website shopping cart application built with Perl, was recently released to the public in November 2019. This release marks the first major version release for the f/OSS (free open source software) version of AgoraCart in about a decade.
I have avoided any spotlight in the Perl community after negative experiences early on but at the urging of Gabor Szabo over at PerlMaven.com, I realized that I should not care if I am not the normal Perl community member/developer. As a result, announcements on Perl type groups was skipped until now. So here's to new beginnings.
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
In my last blog post, there was a bit of a discussion in the comments about whether data in unit tests should be hardcoded or not. Tom Metro scored the last point with this comment:
We always coach developers to use hard coded test data to the extent practical. When writing tests you have to unlearn a lot of DRY principles. We tolerate a lot more repetition, and factor it out sparingly.
and then I said that this really required a longer discussion than blog post comments would allow. This, then, is that longer discussion.
So, first of all, let me agree whole-heartedly with Tom’s final statement there: “We tolerate a lot more repetition, and factor it out sparingly.” Absolutely good advice. The only problem is that, as I noted previously on my Other Blog, we humans have a tendency to want to simplify things in general, and rules and “best practices” in particular. I don’t think that Tom was saying “always hardcode everything in your unit tests!” ... but I think some people will read it that way nonetheless. I would like to make the argument that this is a more nuanced topic, and hopefully present some reasons why you want to consider this question very carefully.1
The communication system of an office is broken and message received are not completely reliable. To send message Hello, it ended up sending these following:
H x l 4 !
c e - lo
z e 6 l g
H W l v R
q 9 m # o
Similarly another day we received a message repeatedly like below:
P + 2 l ! a t o
1 e 8 0 R $ 4 u
5 - r ] + a > /
P x w l b 3 k \
2 e 3 5 R 8 y u
< ! r ^ ( ) k 0
Write a script to decrypt the above repeated message (one message repeated 6 times).
Even without reading the hint, the idea seems clear: for each column, the output should consist of its most frequent character. As usually, to count frequency, we’ll use a hash. To find the most frequent one, we’ll use max from List::Util.
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.