Perl Weekly Challenge 201: Missing Numbers

These are some answers to the Week 201 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

You are given an array of unique numbers.

Write a script to find out all missing numbers in the range 0..$n where $n is the array size.

Example 1

Input: @array = (0,1,3)
Output: 2

The array size i.e. total element count is 3, so the range is 0..3.
The missing number is 2 in the given array.

Example 2

Input: @array = (0,1)
Output: 2

The array size is 2, therefore the range is 0..2.
The missing number is 2.

Missing Numbers in Raku

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

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

Perl Weekly Challenge 200: Arithmetic Slices and Seven Segment Display

These are some answers to the Week 200 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 January 22, 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: Arithmetic Slices

You are given an array of integers.

Write a script to find out all Arithmetic Slices for the given array of integers.

An integer array is called arithmetic if it has at least 3 elements and the differences between any three consecutive elements are the same.

Example 1

Input: @array = (1,2,3,4)
Output: (1,2,3), (2,3,4), (1,2,3,4)

Example 2

Input: @array = (2)
Output: () as no slice found.

Arithmetic Slices in Raku

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.

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

Perl Weekly Challenge 199: Good Pairs and Good Triplets

These are some answers to the Week 199 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 January 15, 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.

Contrary to usual, I started with the Perl implementations this week (not having Raku installed on the computer where I started to work on the challenge). So I’ll present the Perl implementations first.

Task 1: Good Pairs

You are given a list of integers, @list.

Write a script to find the total count of Good Pairs.

A pair (i, j) is called good if list[i] == list[j] and i < j.

Example 1

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:

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

Perl Weekly Challenge 198: Max Gap and Prime Count

These are some answers to the Week 198 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on January 8, 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: Max Gap

You are given a list of integers, @list.

Write a script to find the total pairs in the sorted list where 2 consecutive elements has the max gap. If the list contains less than 2 elements then return 0.

Example 1

Input:  @list = (2,5,8,1)
Output: 2

Since the sorted list (1,2,5,8) has 2 such pairs (2,5) and (5,8)

Example 2

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:

United Domains unterstützt den Deutschen Perl Workshop 2022

united domains, das ist ein Team von rund 80 qualifizierten und erfahrenen Mitarbeiterinnen und Mitarbeitern, die sich zuverlässig und mit Leidenschaft um Ihre Domains kümmern. Unser Versprechen lautet: »Die besten Adressen fürs Web«. Denn wir sind überzeugt, dass es einen Unterschied macht, wer Ihre Domains betreut. united-domains ist mit mehr als 1,6 Millionen registrierten Domains und mehr als 300.000 zufriedenen Kunden einer der führenden Domain-Registrare in Europa. Wir bieten über 850 Domain-Endungen: Von .ag wie Antigua bis .za für Südafrika oder neue Domain-Endungen wie .app oder .dev. Der weltweite Domain-Check, eine schnelle und sichere Domain-Registrierung und die übersichtliche Domain-Verwaltung sind unsere Markenzeichen.

Call for Papers, Perl & Raku Conference in Houston 2022

CFP closes March 1st, 2022 10am PST

"The Perl & Raku Conference is a high-quality, inexpensive, technical Conference that celebrates the family of Perl programming languages. The beauty of the conference is that it remains accessible to everyone regardless of experience, yet it is still valuable to the most skilled programmers.
The Perl & Raku Conference 2022 will be held in Houston, TX from June 21-25, 2022. The main conference will be June 22-24, 2022 with tutorials on June 21 and 25."

CFP: https://www.papercall.io/tprchou22

Conference: https://perlconference.us/tprc-2022-hou/

Perl Weekly Challenge 197: Move Zero and Wiggle Sort

These are some answers to the Week 197 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 January 1, 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: Move Zero

You are given a list of integers, @list.

Write a script to move all zero, if exists, to the end while maintaining the relative order of non-zero elements.

Example 1

Input:  @list = (1, 0, 3, 0, 0, 5)
Output: (1, 3, 5, 0, 0, 0)

Example 2

Input: @list = (1, 6, 4)
Output: (1, 6, 4)

Example 3

Input: @list = (0, 1, 0, 2, 0
Output: (1, 2, 0, 0, 0)

TWC 148: Numbrs, and Cubic Cards

In which we see that you can spell "numbers" without an e, and realize that first implies an ordering.

My Favorite Warnings: qw

When I first came to Perl I thought the qw{} construction was pretty neat. Give it a bunch of white-space-delimited text and it gives you back a list separated on the blanks. So

say for qw{ Fee fie foe fum! };

prints 'Fee', 'fie', 'foe', and 'fum!', each on its own line. But if you add punctuation, and warnings are enabled,

say for qw{ Fee, fie, foe, fum! };

gets you 'Possible attempt to separate words with commas ...'.

For a while, I was dealing with this using a weird assortment of quoting techniques. But then I discovered how to tell Perl I meant to do that:

no warnings 'qw';

Rother OSS GmbH / OTOBO unterstützt den Deutschen Perl/Raku-Workshop 12/01/22

Seit 2011 setzt die Rother OSS GmbH mit Sitz in Süddeutschland und über das ganze Land verteiltem Team auf die Kombination aus OS-Ticketsystem und Business Services vom Experten. Konkret: Consulting, Entwicklung und Support zu den freien OTRS-Versionen.

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.