Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 28, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Weakest Row
You are given an m x n binary matrix i.e. only 0 and 1 where 1 always appear before 0.
A row i is weaker than a row j if one of the following is true:
a) The number of 1s in row i is less than the number of 1s in row j.
b) Both rows have the same number of 1 and i < j.
Write a script to return the order of rows from weakest to strongest.
Back already with this week's solutions to the PWC #212. Spoiler alert, because the challenge doesn't close for another few days if you want to have a try.
Challenge #1 - Spinning Letters
This week we've got a simple letter rotation. Take each letter of the word provided and rotate it by each number in the list. At first I thought this would be a lot longer code. i even put it in a sub. That actually doubles the size though for absolutely no benefit, so I just simplified. We split the word, then loop through the letters and apply the rotation. If it wraps we start from the start of the alphabet. Upper-case is handled with a simple test to insert the right case of each character. Then we don't even bother putting the word back together again because we can just say it as-is.
Date of Latest Release: Feb 12, 2020
Distribution: Data-Table
Module version: 0.38
Main Contributors: Yingyao Zhou (EZDB), Guangzhou Zou
License: [perl]
Near the Christmas in 2022, I played a data engineering challenge called "Hanukkah of Data 5783". You can find it on https://hanukkah.bluebird.sh/5783 . Players can download data of either .CSV, .JSON or .SQLITE format.
The first* task is like this:
... And their phone number was their last name spelled out. I didn’t know what that meant, but apparently before there were smartphones, people had to remember phone numbers or write them down. If you wanted a phone number that was easy-to-remember, you could get a number that spelled something using the letters printed on the phone buttons: like 2 has “ABC”, and 3 “DEF”, etc."
* There is a "zeroth" task on the calendar year.
I didn't mind perish my skill on SQL, but these kinds of things immediately I thought of Perl, maybe there would be a subroutine like this:
The other day I was working on yet another side project. Almost immediately I got side tracked. Does that make the new project a side side project?
What shiny bobble or cool new tech got my attention you ask? It wasn't $buzzword, or $fancy_tech. Nawe, nothing that resumé worthy. Instead, I decided to see what a MVP for a REST API would look like in using Catalyst. Look ma, no extra modules! Except a JSON one, but I don't count it since Catalyst also uses a JSON module.
NOTE: If you are trying to be productive, you probably want to just use Catalyst::Action::REST instead of rolling your own. That's what I've used at work with great success.
Other than generating the scripts I went ahead and hand wrote out everything else and was pleasantly surprised. There was so little code that I went ahead and retyped the only three modules needed here. Apologies if there's a typo.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 28, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 1: Split Strings
You are given an array of strings and a character separator.
Write a script to return all words separated by the given character excluding empty string.
Paul, Philippe, and Ricardo had our mostly-weekly Zoom call today.
We began by discussing last week, when Pete K from TPRF joined us and we talked about what TPRF could do to help p5p. (Main topics then, which didn’t get any firm action items, were support for critical infrastructure and services and bounties for implementation of PPCs.)
Most of our time this week was spent on the upcoming v5.38.0 release, especially what might be blocking it. (Notable: two new deprecation warnings added in the last two releases — smartmatch, and tick as package separator.)
We discussed strategies used by other languages to make things more attractive for developers, like batteries included. We didn’t end up with any plan of action from this.
In a few weeks, we’ll all be in one place, and look forward to looking carefully at the color of Chartreuse.
Perl has had the CPAN and awesome websites like MetaCPAN and its predecessor search.cpan.org for a long time, so unlike how things happen in other programming language ecosystems, many Perl projects have felt no need to start their own websites for documentation, package downloads, and community — all these things were already provided.
However, I do feel that this centralization keeps Perl content on the Internet very isolated and makes Perl less visible than other programming languages.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 21, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Unique Sum Zero
You are given an integer, $n.
Write a script to find an array containing $n unique integers such that they add up to zero.
Example 1
Input: $n = 5
Output: (-7, -1, 1, 3, 4)
Two other possible solutions could be as below:
(-5, -1, 1, 2, 3) and (-3, -1, 2, -2, 4).
Hi ! Everyone, I am back here to ask environmental issue.
When I ran the following CGI.pm testing script before placing at /var/www/cgi-bin, but it is still at /home/mkido/bin. Perl script ran successfully at the Terminal, and replied back the OUTPUT below there.
Perl Script, check.pl
#!/usr/bin/env perl
use strict;
use warnings;
use CGI;
my $q = CGI->new;
print $q->header();
print "OK";
===================
OUTPUT
mkido@localhost$check.pl [Enter to run it.]
Content-Type: text/html; charset=ISO-8859-1
OK
mkido@localhost$
This output result evoked my recognition. Is this Rocky 9.1 Web Server running to provide charset=ISO-8859-1 ?? I want to set all replies from the Server to charset=UTF-8. The httpd.conf is already set to charset=UTF-8. Is there any other setting adjustment somewhere in environmental configuration on my server to change from charset=ISO-8859-1 to charset=UTF-8 ?? Thanks, thanks.
Today, the popular Dark Sky weather API is shutting down. I did a little write-up for non-Perl devs on DEV.to, but I thought I'd post here a couple of potentially useful modules I released to CPAN recently.
Weather::WeatherKit accesses the WeatherKit REST API, which is Apple's official Dark Sky replacement. The module uses Crypt::JWT to create tokens, so accessing WeatherKit then is as simple as:
use Weather::WeatherKit;
my $wk = Weather::WeatherKit->new(
team_id => $apple_team_id,
service_id => $weatherkit_service_id,
key_id => $key_id,
key => $private_key
);
my %report = $wk->get(
lat => 51.2,
lon => -1.8,
dataSets => 'currentWeather'
);
Of course, this API is sort of free, as it requires an Apple developer account. If you don't have one and don't want to get one, there are some alternative APIs, but for the purposes of this post I'll stick to 7Timer, via Weather::Astro7Timer. Even simpler, as it does not need authentication:
Destination: Graph
Date of Latest Release: Feb 12, 2023
Distribution: Graph
Module version: 0.9726
Main Contributors: Jarkko Hietaniemi (JHI)
Current Maintainer: Neil Bowers (NEILB)
License: [perl_5]
Long time ago I claimed in front of a friend I would write a short introduction to graph theory, but I had been not able to figure out where I should start. Neither I would try today. The mathematical objects graphs, or the abstract data structures graphs, are full of interesting behaviors being studied in the discrete math subdiscipline graph theory. The CPAN module Graph is designed to empower Perl programmers doodle with undirected graphs and directed graphs (and also multigraphs and hypergraphs - not going to visit these functionalities here).
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 21, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 1: Special Numbers
You are given an array of integers, @ints.
Write a script to find the sum of the squares of all special elements of the given array.
An element $int[i] of @ints is called special if i divides n, i.e. n % i == 0, where n is the length of the given array. Also the array is 1-indexed for the task.
I'm back this week with PWC #210. Last week I was very busy and spent a long time reviewing other peoples' far more efficient solutions to #208, so I didn't get to doing any solutions for #209. The usual disclaimer about this could contain spoilers, so if you're trying to solve the challenge yourself you may want to skip this post for now. So let's get right into this.
Kill And Win
For this challenge I decided to use some of the tools I learned about in the solutions other people submitted for #208, especially the ways hashes can make the process more efficient. The goal is to find the number in the list where you can delete the most points by deleting the number and its adjacent numbers plus and minus one. You get to count each number however many times it appears in the list.
Bug reporting by email: we commit to nothing as an organisation. Some would-be submitters of issues don’t want to use GitHub. They can just send an email to perl5-porters and hope that some helpful soul will copy-paste to GitHub. We encourage the conventional use of GitHub.
On the topic email bug reports, it’s likely time to deprecate perlbug as a way to send bug reports. It could be updated to point the user to GitHub, and to print perl -V output (etc.) to copy and paste. We should also have a better set of templates for issues on GitHub.
The segfaults on feature-class and refaliasing won’t be fixed before 5.38, and should just be documented as “known bugs”
After we discussed renaming RFC to PPC, the general sentiment seemed to be “in favor”, so we’re going to make the rename
Rik volunteered to release 5.38, we still need a release manager for 5.37.11
Some discussions about preparing the Perl Toolchain Summit plans (which will host the first ever in-person PSC meeting)
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 14, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Lucky Number
You are given a m x n matrix of distinct numbers.
Write a script to return the lucky number, if there is one, or -1 if not.
A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.
A couple very very last-minute solutions to the Weekly Challenge #211. I was crammed for time, so I didn't get to these until the last minute.
Challenge #1
For challenge number 1 I had an idea of the method I would use, but since I've been experimenting with it anyway, I asked ChatGPT for its ideas as well. Because of my lack of time, I wanted to get some help with the design process. ChatGPT is amazing at both developing and describing an algorithm in simple terms to make it understandable. I based my solution somewhat off the AI's algorithm, but I did write it entirely by hand. It's pretty simple, it just iterates across the matrix and makes sure everything matches its diagonal neighbor prior to it.
Another thing you might notice this week is that I actually put my solutions into functions, not just a basic script. Anyways, here it is:
Date of Latest Release: Mar 09, 2012
Distribution: Text::Extract::Word
Module version: 0.02
Main Contributors: Stuart Watt (SNKWATT)
License: The Artistic License 2.0
Date of Latest Release: Jan 26, 2023
Distribution: MsOffice::Word::Surgeon
Module version: 2.01
Main Contributors: Laurent Dami (DAMI)
License: The Artistic License 2.0