Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on May 15, 2022 at 24:00). 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 Palindromes
Write a script to find all prime numbers less than 1000, which are also palindromes in base 10. Palindromic numbers are numbers whose digits are the same in reverse. For example, 313 is a palindromic prime, but 337 is not, even though 733 (337 reversed) is also prime.
Prime Palindromes in Raku
We use a data pipeline (chained method invocations) with two grep statements, one to keep palindromes and one to keep prime numbers. This leads to a fairly concise one-line solution:
say (1..^1000).grep({ $_ == .flip }).grep({.is-prime});
You are given a positive integer $N. Write a script to generate all Rare numbers of size $N if exists. Please checkout the page for more information about it.
Following on from the Gzip::Libdeflate I mentioned before, I also made this: Gzip::Zopfli
It is based on the Zopfli gzip compression library from Google Research.
Both Zopfli and libdeflate seem to excel at compressing JSON files compared to the ordinary zlib compression, sometimes with an improvement of up to 30%. Zopfli usually wins by a small margin over libdeflate. Here are some results of this script on random JSON files:
Despite rt.cpan.org still displaying the sunset message, it is in fact not going away forever on the 1st of March, but will have an 'extended downtime' while it is moved elsewhere. In future it'd be nice if communications of such things, and even allowing others to have a say on the matter, could be handled better.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on May 8, 2022 at 24:00). 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: Sum Bitwise Operator
You are given list positive numbers, @n.
Write script to calculate the sum of bitwise & operator for all unique pairs.
I started the Inline::F2003 project in 2017 because I have a strong interest in modern Fortran and Perl programming.
The project features the Perl module Inline::F2003. This module allows modern Fortran source to be inlined and called from a Perl program. The module compiles the Fortran source and builds an executable shared library that is loaded into the Perl system.
Inline::F2003 is usually invoked at compile-time. The source fragment below shows typical use of the module.
It's often (for work or for personal projects) that I need to create a real-time feature for a website. This can range from a simple notification whenever an event happens on the server of an existing website, to implementing a real-time multiplayer game or adding a feature inspired from social media websites.
Unfortunately the increase in complexity in code (Perl & JS) and architecture involved in setting up a reliable solution, very often made me forego the opportunity to use WebSockets for many of these projects, and instead resorted to http polling to keep the solution simple for the others to maintain.
So I started looking for a library with a client & server component, that would make life easier. The library would hopefully have to have the following features:
We are finally here - we have hit week 100 of Manwar's Perl Weekly Challenges, and here are solutions to this weeks challenges from the Perl Weekly Challenge.
You are given a time (12 hour / 24 hour). Write a script to convert the given time from 12 hour format to 24 hour format and vice versa. Ideally we expect a one-liner.
Example 1: Input: 05:15 pm or 05:15pm -> Output: 17:15
Example 2: Input: 19:15 -> Output: 07:15 pm or 07:15pm
The solution
Firstly I have to thank Manwar for asking for a one line solution as this is my
modus operandi
.... So we will look at this and see how we can get a simple yet compact solution... well here goes.... {code is 110 bytes, within the functions curly braces there are just 102 bytes of code}
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on May 1st, 2022 at 24:00). 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: ISBN-13
Write a script to generate the check digit of given ISBN-13 code. Please refer wikipedia for more information.
Example
ISBN-13 check digit for '978-0-306-40615-7' is 7.
This how Wikipedia describes the calculation of the ISBN-13 check digit:
I've released berrybrew version 1.33. This version has significant enhancements, along with some bug fixes and handling of some uncaught exceptions. The changes reflect versions 1.30 to 1.33.
Major changes include:
UI:
Allows you to install, switch to, remove and use Strawberry Perls directly
Can now spawn a CLI window for any Perl you have installed
Allows you to spawn a CLI window for the currently active Perl
Provides access to modify several of the core configuration options (debug, file association etc)
Allows you to disable all berrybrew Perls and restore to system default
Installer:
Performs an upgrade on any previous berrybrew install
Adds any new configuration options, while preserving the values of any previously set existing ones
Provides facility to install the most recent version of Strawberry Perl
Allows you to have berrybrew manage the .pl file association
Allows you to have the UI run at system startup
Aborts if trying to install the same version that's already installed
Functionality:
You can now leave off the 32/64 bit prefix on a Perl name, and we'll default to _64
All execution paths return a proper exit code
Added new berrybrew hidden command, lists all, well, hidden commands
For all other changes, please refer to the Changes file.
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on April 24, 2022 at 24:00). 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: Abecedarian Words
An abecedarian word is a word whose letters are arranged in alphabetical order. For example, “knotty” is an abecedarian word, but “knots” is not. Output or return a list of all abecedarian words in the dictionary, sorted in decreasing order of length.
Optionally, using only abecedarian words, leave a short comment in your code to make your reviewer smile.
I recently became aware of a very cool service provided by the Google. The Civic Information API provides contact information for all elected representatives (from head of state down to municipal official) for any US address.
I wrote the Perl client for the API, published as Net::Google::CivicInformation. Get a free API token and you're up and running.
This was a satisfying project because I can imagine people finding actual value in the product. I'm all for being vocal with our government! I decided to take it a step further and created a webservice interfacing to the API. It's written in Dancer2 and the source code is on Github (at the urging of ++GabSzab who pointed out that there are few examples of Dancer2 apps for developers to study.)
Create subroutine readN($FILE, $number) returns the first n-characters and moves the pointer to the (n+1)th character.
Solution
Rather than turning this into an object which was the first idea - I decided to keep the code clean by making it a function call, and to also make it work with multiple file handles open simultaneously.
To achieve this without an object - we will need to use a global hash to contain the opened file handles - so that when we re-call the function we don't re-open the file.
I have been doing monthly report for many years now.
Why? What is the point?
Well, let me answer the first question, Why? To be honest with you, I do it to keep myself motivated. I need some kind of (self) motivation to carry on what I do on a daily basis. Now to answer the second question, What is the point? It helps me to keep track and follow the progress.
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on April 17, 2022 at 24:00). 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: Four is Magic
You are given a positive number, $n < 10.
Write a script to generate English text sequence starting with the English cardinal representation of the given number, the word ‘is’ and then the English cardinal representation of the count of characters that made up the first word, followed by a comma. Continue until you reach four.
Example 1:
Input: $n = 5
Output: Five is four, four is magic.
Example 2:
Input: $n = 7
Output: Seven is five, five is four, four is magic.
The British Royal Family and GameStop have been in a secret war with each other for hundreds of years. Nobody knows why. GameStop has included it in their manifesto and the Royals is always untrustworthy. They leave clues to mock us! GAMESTOP HAS INCLUDED IT IN THEIR MANIFESTO! MOCK! MOCK!
There is more:
Q found out that reincarnation is true and he has been imprisoned in The Pentagon. Qanon are protecting this secret. The Biden administration knows the truth but Qanon have paid them off with a warehouse full of holy water. The Wikipedia entry for The Pentagon keeps getting edited by the Biden administration and Qanon even admit it. They leave clues to mock us.
You too can find out the truth about what's REALLY going on here or here
Well, it’s been a hot minute since the last release, hasn’t it? Dancer2 0.300005 has landed on CPAN and features a number of bug fixes, enhancements, and doc patches: