Perl Weekly Challenge 235: Duplicate Zeros

These are some answers to the Week 235, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a few days from now (on September 24, 2023 at 23:59). 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 2: Duplicate Zeros

You are given an array of integers.

Write a script to duplicate each occurrence of ZERO in the given array and shift the remaining to the right but make sure the size of array remain the same.

Example 1

Input: @ints = (1, 0, 2, 3, 0, 4, 5, 0)
Ouput: (1, 0, 0, 2, 3, 0, 0, 4)

Example 2

Input: @ints = (1, 2, 3)
Ouput: (1, 2, 3)

Example 3

Of Go, C, Perl and fastq file conversion Vol III : pledging allegiance to the flag

In the previous entry, we presented a regex based fastq parser. As the regex engine maps to a finite state automaton, we should be able to rewrite the parser without regular expressions, using flags to keep track of the part of the record we are at. The code is straightforward, but lacks the elegance of the regex parser. It is provided as a possibly faster alternative to the regular expression implementation.

This week in PSC (116)

There were only two of us this week, and the list is still a bit quiet.

The main topic was stalled PPC work: we have a few PPCs that have been approved and are in the “Implementing” state, but still waiting for an implementor. We’ll send a separate email asking for volunteers on those.

Perl Weekly Challenge #234 - Sharing is Caring

Hi everybody! Back this week with a (surprisingly long) solution to just Task 1 of the weekly challenge. Task 2 makes no sense to me at all because it seems like examples 1 and 3 disagree with each other. Just sticking to one challenge for that reason. Anyways, let's dive into it!

The goal here is to find the letters that all the provided words share. Here's the code:

Perl Weekly Challenge 235: Remove One

These are some answers to the Week 235, Task 1, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a few days from now (on September 24, 2023 at 23:59). 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: Remove One

You are given an array of integers.

Write a script to find out if removing ONLY one integer makes it strictly increasing order.

Example 1

Input: @ints = (0, 2, 9, 4, 6)
Output: true

Removing ONLY 9 in the given array makes it strictly increasing order.

Example 2

Input: @ints = (5, 1, 3, 2)
Output: false

Example 3

Of Go, C, Perl and fastq file conversion Vol II : the Jedi regex

In the second part of this series about fast parsers for sequencing applications,  I will review the code for the regex based parser. This is shown below (I use v5.38, as you should! because the year is 2023 and you should not have to type use strict; use warnings)

This week in PSC (114)

This week, we talked about:

  • the recent quietness of the perl5-porters list
  • PPC 0013 and the use of a lexical feature (join_with_concat) to enable concat magic
  • inclusion of stringify (OP_STRINGIFY) and numify functions in the builtin namespace
  • turning the UNIVERSAL::import deprecation warning into a regular warning so as not to imply a removal timescale

The Hidden Power of Prototypes

Introduction

I have been leaning very heavily on Perl's prototype feature for creating new modules. The imptetus for this can traced back to the day I looked at the source code for Try::Tiny, and realized that it was implemented using prototypes. The main reason for using prototypes for many new modules I've created recently is my focus on making a thing I do repeatedly available in a more Perlish or idiomatic way.

Required reading if you have not and are about to dive into an article about prototypes: Far More Than Everything You've Ever Wanted to Know about Prototypes in Perl by Tom Christiansen.

The following article demonstrates 2 CPAN modules I have written that focus more on Perl programmer UX and why Perl prototypes can provide a way forward for a great many ideas that people have. Prototypes misunderstood, yes; but more so, they are misunderestimated. They are infact, very powerful and when used for their intended purpose; a lot of hand wringing can be avoided during feature discussions.

Perl Weekly Challenge 234: Unequal Triplets

These are some answers to the Week 234, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Task 2: Unequal Triplets

You are given an array of positive integers.

Write a script to find the number of triplets (i, j, k) that satisfies num[i] != num[j], num[j] != num[k] and num[k] != num[i].

Example 1

Input: @ints = (4, 4, 2, 4, 3)
Ouput: 3

(0, 2, 4) because 4 != 2 != 3
(1, 2, 4) because 4 != 2 != 3
(2, 3, 4) because 2 != 4 != 3

Example 2

Input: @ints = (1, 1, 1, 1, 1)
Ouput: 0

Example 3

Perl Weekly Challenge #231 - Not Going to Extremes but Accepting Senior Citizens

Hi everybody! In this week's weekly challenge, we're searching for anything but the minimum or maximum in a dataset, and searching for senior citizens on a plane.

Min And Max

This challenge is a very interesting one, because obviously the easiest solution in terms of development is to sort and filter the first and last element. However, that is O(n log n) and it's very little added complexity to do the O(n) solution with a single-pass filter.

Next stable DBD::SQLite will be released in the middle of September

DBD::SQLite 1.73_01 (with SQLite 3.42.0) is a release candidate for the next stable DBD::SQLite. This release is mainly to upgrade the bundled SQLite library.

I'll wait for about a month and release 1.74 in the middel of September if there's no blocker nor request to wait for more. Thank you for your patience.

This week in PSC (112)

This week, for its first meeting, the new PSC:

  • discussed the nature of typing systems for Perl and what properties we find desirable vs not
  • worked out a release schedule for the next few months of devel releases
  • reviewed the PPC Tracker document. A few are now done, the rest need remainder nudge emails to their respective proposers

Perl Weekly Challenge 234: Common Characters

These are some answers to the Week 233, Task 1, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on September 17, 2023 at 23:59). 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: Common Characters

You are given an array of words made up of alphabetic characters only.

Write a script to return all alphabetic characters that show up in all words including duplicates.

Example 1

Input: @words = ("java", "javascript", "julia")
Output: ("j", "a")

Example 2

Input: @words = ("bella", "label", "roller")
Output: ("e", "l", "l")

Example 3

Why YACM (yet another color module) ?

At the recent YAPC::EU (still running) I gave a talk about my latest CPAN module: Graphics::Toolkit::Color (in short GTC - v1.53). It went a little out of hand and even worse: some of the key thoughts I did not formulate as clear as wanted. That is why I use this channel to correct that. In this first part I outline the goal of the module and the next part will be about the design principles of the public API, moving than into implementation details and the general issues when dealing with colors.

Resource::Silo - declarative lazy resource container library

Resource::Silo is a declarative lazy resource container library for Perl. It allows to declare resources such as configuration files, database connections, external service endpoints, and so on, in one place; acquire them on demand; cache them; and release in due order.

It may also be described as the single source of truth for the application's side effects.

For those unfamiliar with Bread::Board:

Hey, hey, hey, hey! A shiny new solution just arrived!

  • declare all of your application's resources / dependencies in one place using a simple DSL;
  • instantiate them on demand and only once, with little overhead;
  • override them with mocks in your tests & guard against unexpected side effects;
  • gain more fine-grained control via the ctl frontend.

For Bread::Board users:

This week in PSC (111)

Today was PSC 111 — what happened to 110 you ask? Well, it was a bit of a non-meeting a few weeks ago. Nothing to say about it, sorry!

This week, we:

  • Said hello to Graham and goodbye to Rik
  • We did a bunch of handover, making sure we set up a new Zoom meeting and calendar, and talking about our usual order of business

In more normal business, we:

  • talked about the future of use vX, especially related to builtin:: stuff — do we want “use v5.40” to import “builtin::refaddr” for example
  • talked about what we’re going to do with the UNIVERSAL::import changes so we can move it forward toward someday making it fatal but without breaking half of CPAN at once

Perl Weekly Challenge 233: Frequency Sort

These are some answers to the Week 233, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

You are given an array of integers.

Write a script to sort the given array in increasing order based on the frequency of the values. If multiple values have the same frequency then sort them in decreasing order.

Example 1

Input: @ints = (1,1,2,2,2,3)
Ouput: (3,1,1,2,2,2)

'3' has a frequency of 1
'1' has a frequency of 2
'2' has a frequency of 3

Example 2

Foswiki-2.1.8 has been released

Dear all,

we've got a new release out. Update is highly recommended as it fixes 9 critical security related bugs, i.e.

  • CVE-202: 3-33756: SpreadSheetPlugin's EVAL feature exposes information about paths and files on the server
  • CVE-2023-24698: Local file inclusion vulnerability in viewfile

Read more about it at https://blog.foswiki.org/Blog/Foswiki218IsReleased

Regards,
Michael.

No One Is Immune to Abuse

Once again I'm writing about a TPRC talk instead of a weekly challenge project, but that's because I feel it's a very important topic to be aware of both inside and outside our community as Perl programmers. Sawyer X gave a really great talk about the abuse he personally experienced as a member of the Perl community. I've never experienced abuse in this or any other technology community, but I have experienced abuse before in other contexts. Also, as a disclaimer, although I'm sure many have seen some of Sawyer's situation play out in public, I haven't, as I believe it happened during my extended break from Perl and development in general.

This week in PSC (115)

This week, we discussed several topics:

  • collecting bugfixes to put in a 5.38.1 maintenance release
  • Module::CoreList automated releases, and how we might get them created — what PAUSE user, etc…
  • once the PPC for meta:: officially exists, it would be worth having a release on CPAN, to experiment with
  • the PPC process still needs some refinement and further clarification on what gets done, when, and by whom

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.