Perl Weekly Challenge 207: Keyboard Word and H-Index

These are some answers to the Week 207 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 March 12, 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: Keyboard Word

You are given an array of words.

Write a script to print all the words in the given array that can be types using alphabet on only one row of the keyboard.

Let us assume the keys are arranged as below:

Row 1: qwertyuiop
Row 2: asdfghjkl
Row 3: zxcvbnm

Example 1

Input: @words = ("Hello","Alaska","Dad","Peace")
Output: ("Alaska","Dad")

Example 2

TWC Episode 154 - Padawan Missing

In which we search for a needle in a lendee
(or maybe a chatchka in a haystack),
and delight in some lazy CPAN comfort.

Cloud Provider Performance Comparison - Perl & more

UPDATE: For the newer (2023) comparison see here.

Last year, impressed with the apparent speed of an M1 Mac Mini I bought to try out, I explored its perl performance and wrote about it in a  blog post . I used mainly my own benchmarks which were mostly representative of workloads I was interested in.

I start to write the book "Perl for Beginners to Mastering Perl in a week"

I start to write the book "Perl for Beginners to Mastering Perl in a week".

I wrote two Japanese books from a years ago.

Perlテキスト処理のエッセンス

PerlでポータブルなLinuxファイル管理入門

Finally, I decided to write English books.

Recently it becomes easy to publish both e-books and paperbacks.

The title of my first English Perl book is "Perl for Beginners to Mastering Perl in a week".

This book is for Perl beginners to learn Perl quickly.

Perl Weekly Challenge 206: Shortest Time and Array Pairings

These are some answers to the Week 206 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 March 5, 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: Shortest Time

You are given a list of time points, at least 2, in the 24-hour clock format HH:MM.

Write a script to find out the shortest time in minutes between any two time points.

Example 1

Input: @time = ("00:00", "23:55", "20:00")
Output: 5

Since the difference between "00:00" and "23:55" is the shortest (5 minutes).

Example 2

My Favorite Modules: Devel::NYTProf

'It is a capital mistake to theorize before one has data.' -- Sherlock Holmes, "A Scandal in Bohemia"

The mental excursion that led to this blog post started with a report from Olaf Alders that my Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter was generating a false positive on variables used only as defaults in subroutine signatures. After the first cut at fixing this I thought a regression test was in order. I did this by running both unpatched and patched versions of the policy against my Mini CPAN, and then diff on the outputs.

This has always taken the better part of a day to run, and given that it had to expand all the distributions first and then run a fairly brute-force policy against anything it found, I accepted this as the price of conscientiousness.

Finding unused variables in your Perl code

I've put together a brief overview of some of the ways to automate finding unused variables in your Perl code:

https://www.olafalders.com/2022/02/22/finding-unused-perl-variables/

The progress of the SPVM language 2022

Hi, I write the progress of the SPVM module 2022.

SPVM is a programming language that is build on top of the Perl ecosystem and provides fast calculation and array operation to Perl.

SPVM can be transpiled to C language, and it can be compiled to shared libraries and executable files.

SPVM can call C/C++/Cuda libraries by writing pure C/C++/Cuda language without XS.

I wrote SPVM from 2016. I finally implement the all features that I think they are needed for modern applications.

Next, I need to do many tests of SPVM module by creating modules and applications.

Documentations

The following are the official documentations of SPVM.

SPVM

Tutorial

SPVM Tutorial.

Tutorial

Language Specification

SPVM Language Specification.

Language Specification

Standard Functions

SPVM Standard Functions

Standard Functions

Standard Modules

SPVM Standard Modules.

Standard Modules

Performance Benchmark

SPVM Performance Benchmark.

Benchmark

Exchange API

SPVM Exchange API converts Perl data structures to SPVM data structures, and vice versa.

ExchangeAPI

Native API

SPVM Native API is C API used in SPVM native method.

NativeAPI

Perl Weekly Challenge 205: Third Highest and Maximum (Bit-Wise) XOR

These are some answers to the Week 205 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 February 26, 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: Third Highest

You are given an array of integers.

Write a script to find out the Third Highest if found otherwise return the maximum.

Example 1

Input: @array = (5,3,4)
Output: 3

First highest is 5. Second highest is 4. Third highest is 3.

Example 2

Some tricks for prettier xs

XS has a reputation of being ugly and cumbersome, but in my experience, it doesn't have to be. Let's take for example this snippet from my Thread::Csp::Promise class:

MODULE = Thread::Csp PACKAGE = Thread::Csp::Promise PREFIX = promise_

SV* promise_get(Promise* promise)

bool promise_is_finished(Promise* promise)

SV* promise_get_notifier(Promise* promise)

Please help test big pull request for DBD::Oracle

This large pull request hopes to solve segfault at cleanup and problems with multiple charsets in multiple connections to Oracle.

If you use DBD::Oracle please grab the PR and give it a try, then send your feedback.

https://github.com/perl5-dbi/DBD-Oracle/pull/147

My Favorite Warnings: regexp

'A fair jaw-cracker dwarf-language must be.' -- Samwise Gamgee, The Lord of the Rings, II/iii: "The Ring Goes South", as quoted in regcomp.c, the Perl regular expression compiler.

As you would expect, this category gets you warnings about possibly-problematic regular expression constructions. A couple specific examples are:

Assuming NOT a POSIX class ...

This warning is about things that look kind of like POSIX character classes, but do not parse that way. The full diagnostic gives examples like [[:alnum]] (missing colon) and [[:digit:xyz] (missing right square bracket). These parse like simple character classes ([:[almnu]\] and [:[dgitxyz] respectively), so without the warning you get a hard-to-diagnose bug.

Unescaped left brace in regex is passed through ...

Efforts to eliminate unescaped left braces so that they are available for new syntax have been underway since 5.17.0, released May 2012. As I recall, this effort turned to be much harder than originally anticipated because at least one toolchain external to Perl (autoconf if memory serves) relied on this behavior.

Perl Weekly Challenge 204: Monotonic Arrays and Reshape Matrix

These are some answers to the Week 204 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 February 19, 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: Monotonic Array

You are given an array of integers.

Write a script to find out if the given array is Monotonic. Print 1 if it is otherwise 0.

An array is Monotonic if it is either monotone increasing or decreasing.

Monotone increasing: for i <= j , nums[i] <= nums[j]

Monotone decreasing: for i <= j , nums[i] >= nums[j]

Example 1

Input: @nums = (1,2,2,3)
Output: 1

Example 2

Input: @nums (1,3,2)
Output: 0

Strato unterstützt den Deutschen Perl/Raku Workshop 2022

Wer sind wir?

1997 gegründet, gehört STRATO mit über 4 Millionen Domains und mehr als 2 Millionen Kunden heute zu den größten Webhosting-Anbietern weltweit. STRATO beschäftigt rund 500 Mitarbeiter und betreibt zwei TÜV-zertifizierte Rechenzentren mit über 70.000 Servern in Berlin und Karlsruhe. Die STRATO AG ist ein Unternehmen der United Internet-Gruppe.

Wo brauchen wir Deine Perl-Kenntnisse?

TWC 150: bAbAbbAb and a few Composites

In which we see Leonardo outside his native Nums, and that the World is not made of Ones.

(Placeholder; still editing)

TWC Task #1 - Fibonacci Words

Raku

Perl

Dart

TWC Task #2 - Square-free Integer

Raku

Perl

Dart

My Favorite Modules: re

The re module provides functionality relating to Perl's regular expressions. It is either a module in the sense of potentially exporting stuff into your name space or a pragma in the sense of modifying the behavior of Perl within a lexical scope, or both, depending on how you use it.

The pragmatic functionality tweaks the regular expressions themselves in various ways:

Perl Weekly Challenge 203: Special Quadruplets and Copy Directory (Functional Programming Approach)

These are some answers to the Week 203 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 February 12, 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: Special Quadruplets

You are given an array of integers.

Write a script to find out the total special quadruplets for the given array.

Special Quadruplets are such that satisfies the following 2 rules. 1) nums[a] + nums[b] + nums[c] == nums[d] 2) a < b < c < d

Example 1

Input: @nums = (1,2,3,6)
Output: 1

Since the only special quadruplets found is $nums[0] + $nums[1] + $nums[2] == $nums[3].

Example 2

Annual Report - 2021

Good bye 2021 and Welcome 2022 !!!

Time to look back and review how the year 2021 was for me.

Perl Weekly newsletter

As you all know, I have been editing Perl weekly newsletterGabor Szabo. We agreed, I edit the even numbered newsletter and Gabor would do odd numbered ones. So that way, I got the honour to edit the 500th edition of the weekly newsletter. I am now looking forward to my personal, 100th edition. As of today, I have edited 96 in total.

The [Perl] Weekly Challenge

Thanks to the Team PWC, I completed one more year of weekly challenge. It may not sound a big deal but for me it is. I wouldn't have done without the support of the team. I would like to mention one name, Colin Crain, our in-house, Perl reviewer for the hard work in reviewing Perl solutions every week without fail for so many months now.

TWC 149: Limited Fibs, and Bases of Unusual Size

(Currently editing)

In which we see that you don't need all the Fibs, and have trouble turning 21.

TWC Task #1 - Fibonacci Digit Sum

Given an input $N, generate the first $N numbers for which the sum of their digits is a Fibonacci number.

(i.e. Generate OEIS A028840)

Observations:

Raku

Perl

C

TWC Task #2 - Largest Square

(i.e. Generate OEIS A287298)

Given a number base, derive the largest perfect square with no repeated digits and return it as a string. (For base>10, use ‘A’..‘Z’.)

Observations:

Raku

Perl

C

My Favorite Warnings: precedence

Perl possesses a rich and expressive set of operators. So rich, in fact, that other adjectives can come to mind, such as prolix, or even Byzantine.

Requests for help navigating Perl's operator space appear repeatedly on outlets such as PerlMonks. These seem to me to involve two sorts of confusion: precedence (discussed here) and functionality (string versus numeric -- maybe another blog post).

The precedence warnings category has some help here, though as of Perl 5.34 there are only two diagnostics under it:

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.