Perl Weekly Challenge 139: JortSort and Long Primes

These are some answers to the Week 139 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 November 21, 2021 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: JostSort

You are given a list of numbers.

Write a script to implement JortSort. It should return true/false depending if the given list of numbers are already sorted.

Example 1:

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

Since the array is sorted, it prints 1.

Example 2:

Adventures in Perl

(Originally published on samirparikh.com.)

Just over one year ago, I wrote about how I had become enchanted with the D programming language as part of my journey in exploring new programming languages. I still really like D for all of the reasons I wrote about, but as I alluded to in the conclusion of that piece, I fully expected to “get distracted by the next new shiny thing that comes along.” Turns out that the next new shiny thing happens to be … Perl!

That’s right: a language that Larry Wall first developed back in 1987 happens to have caught my fancy and I’m as surprised as anyone.

Amusewiki 2.500

Well, well, today I released Amusewiki 2.500 and I noticed that time has passed since the last announcement here. This doesn't mean that the Amusewiki development has stopped. On the contrary. The development pace has been steady, with new features, improvements and bug-fixes. In the meanwhile Amusewiki got a new logo as well!

The most notable changes are:

  • Installation size has been cut down to the minimum with a TeXlive! repackaging (which can be installed on the fly by the installation script or via the unofficial Debian packages).

  • Support for attached files has been extended. You can now upload and display audio and video files.

  • Custom category types: you are no longer limited to authors and topics, you can have custom categories.

As usual, documentation for old and new features can be found at amusewiki.org, unofficial Debian package are at packages.amusewiki.org and sources are at https://github.com/melmothx/amusewiki.

Detailed changelogs can be found here: https://amusewiki.org/category/topic/releases.

It's worth noting that the Emacs Muse markup is supported by Pandoc (as a reader and a writer) since version 2.0, and if you use the Atom editor, there is a package for it.

Enjoy!

CY's Take on PWC#083

If you want to challenge yourself on programming, especially on Perl and/or Raku, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email).

... before coding

Long time no blogging for The Weekly Challenge!

I found that I use "and/or" quite frequently in writing. I know, (mathematical-)logically we only need "or". It seems to me to be a language tricky part as the use of gender neutral terms.

I made a logical error for the "Lonely X" task in challenge 077.

$segment =~ s/XI/II/g;
$segment =~ s/IX/II/g;
$segment =~ s/XX/II/g;

should be

$segment =~ s/XX/II/g;
$segment =~ s/XI/II/g;
$segment =~ s/IX/II/g;

Task 1 Words Length

I immediately checked out the "Llama book" and checked the usage of match variables in regular expressions. The result is a 3-line solution! Yo:

$_ = <STDIN>;
/(^\w+\s)((\w+\s*)+)(\s\w+$)/;
print length $2,"\n";


Oooooooooooops, it works for 3-word string.

Perl Weekly Challenge 136: Two Friendly and Fibonacci Sequence

These are some answers to the Week 136 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 October 31, 2021 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: Two Friendly

You are given 2 positive numbers, $m and $n.

Write a script to find out if the given two numbers are Two Friendly.

Two positive numbers, m and n are two friendly when gcd(m, n) = 2 ^ p where p > 0. The greatest common divisor (gcd) of a set of numbers is the largest positive number that divides all the numbers in the set without remainder.

Example 1:

Why you should use ppport.h in your XS code modules


The answer comes down to two words: Security and Reliability.
As a bonus, less work on your part.

It's surprising to find that there are modules on CPAN that aren't using
ppport.h that could stand to benefit from it.

ppport.h is a file that is part of the Devel::PPPort distribution. As you
know, Perl has evolved over the years, adding new features, and new API for XS
writers to use. Some of that is to support the new features, and some to make
tasks easier to accomplish. ppport.h implements portions of the API that
people have found desirable to have when a module gets installed in a Perl that
was released before that API element was created. You can write your module
using the latest API, and have it automatically work on old Perls, simply by
#including ppport.h in your XS code. ppport.h generally provides support for
an API element as is reasonably practicable, with many supported to 5.03007.

System Setup for Modern Perl Projects

From 2015, but it came across my screen this morning. Seems like it is still relevant.

System setup for modern perl projects

A lifetime of programming books ... to give away

I am writing this blog post to hand over all my programming books, (mostly perl) to any person that would like to use them.

This includes about a dozen O'rielly perl books (including the camel book) as well as other classics like:

The C programing language by K+R
TCP/IP by Comer
Design Patterns by GHJV

all free, but must take the whole box.

Contact me at freddo411 (at) gmail.

I am located in the Seattle area.

Perl Weekly Challenge 135: Middle 3-Digits and Validate SEDOL

These are some answers to the Week 135 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 October 24, 2021 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: Middle 3-digits

You are given an integer.

Write a script find out the middle 3-digits of the given integer, if possible otherwise throw sensible error.

Example 1:

Input: $n = 1234567
Output: 345

Example 2:

Input: $n = -123
Output: 123

Example 3:

Input: $n = 1
Output: too short

Example 4:

Load a list of lines into an array (easily)

This blog post describes a common task my colleagues ask often about repeating a dynamic string in a defined token and adding some or, and, = in between, plus finishing smartly.

I like to use the Perl's __DATA__ token at the end of my scripts for this. The __DATA__ token strength is to make possible to « "embed” a file inside a Perl program then read it from the DATA filehandle ». It saves you the creation and opening of a real file and is very handy for quick prototypes and tests.

San Diego Perl Mongers Meeting, Tuesday, October 13th

This is a quick reminder that the quarterly San Diego Perl Mongers meeting will be occurring on Tuesday evening, starting at our normal time of 7 PM PDT.  As has been for the last several meetings, we’re going to meet online, as in-person meetings are discouraged, and online meetings seem to be a bit more popular.

Tau Station, The Internal Adventures: DBIx::Class::Row cache (avoid the rabbits!)

Tau Station, "the free-to-play narrative sci-fi MMORPG (TM)", has a nicely complex database. Currently, we have 190 tables with 740 relationships between those tables. DBIx::Class does an amazing job at managing that complexity, since each relationship is simply an accessor on the DBIx::Class::Row object.

However, there is a subtle issue when using those relationship accessors. Using a relationship accessor creates a new Row object and stores it in the calling object. This behavior can easily leads to duplicate DBIC Row objects for a single database row. At best, the duplicates cause wasted resources duplicating the Rows. At worst, they cause update anomalies, since updates done to one Row object are not seen by the duplicate objects.

With a highly-connected schema like we have in Tau Station, trying to handle the object duplication can pretty soon feel like we're trying to handle rabbits in Australia.

In order to avoid this Row duplication, we have developed a cache of DBIC Row objects that is shared within the application. In most cases, this allows us to ensure that we have one DBIC Row object per database row while processing an HTTP request, avoiding those subtle update anomalies.

Perl Weekly Challenge 134: Pandigital Numbers and Distinct Term Count

These are some answers for Week 134 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 October 17, 2021 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: Pandigital Numbers

  • Write a script to generate first 5 Pandigital Numbers in base 10.*

As per the https://en.wikipedia.org/wiki/Pandigital_number, it says:

A pandigital number is an integer that in a given base has among 
its significant digits each digit used in the base at least once.

Week #081: Common Base Strings & Frequency Sort

Please follow the blog where I discuss the "Common Base Strings" and "Frequency Sort" task of "The Weekly Challenge - 081".

https://perlweeklychallenge.org/blog/weekly-challenge-081

MNIST Handwriting Recognition Deep Learning Written in Pure Perl

The MNIST handwriting recognition deep learning written with Pure Perl is released.

Because it is pure Perl code, it can be used by Perl users to get an overview of deep learning algorithms.

MNIST Handwriting Recognition Deep Learning Written in Pure Perl

What do I use to release a module to CPAN for the first time?

Several months ago I read a tutorial on module creation. It got me thinking about releasing some of my modules. I got to work getting my code organized. At the time I had all of my work in the directory for my site. So I moved my general purpose modules to their own directory and then started reading more about what is needed to get a module published on CPAN.

I first installed Module::Starter. It seemed like a good place to start, but then Dist::Zilla was suggested, so I installed it. Most recently Minilla suggested, and now it is installed. The problem is, I do not know which one to use. Do I use any of those at all, or is there yet another packaging module (with executable) out there?

Perl Weekly Challenge 133: Integer Square Roots and Smith Numbers

These are some answers for Week 133 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 October 10, 2021 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: Integer Square Root

You are given a positive integer $N.

Write a script to calculate the integer square root of the given number.

Please avoid using built-in function. Find out more about it https://en.wikipedia.org/wiki/Integer_square_root.

Examples:

Opt-in your CPAN repos for Hacktoberfest

If you haven't heard, Hacktoberfest has now become opt-in, to reduce the number of spammy, or pointless, pull requests that people were doing, to get the t-shirt. In this post I'll describe how to opt your repos in, how to find opted-in repos, and why your repo might not be turning up in searches.

So if you've got repos with issues that you'd be happy to receive pull requests on, add the topic hacktoberfest, and make sure that your repo turns up in searches.

Week #080: Smallest Positive Number & Count Candies

Please follow the blog where I discuss the "Smallest Positive Number" and "Count Candies" task of "The Weekly Challenge - 080".

https://perlweeklychallenge.org/blog/weekly-challenge-080

Perl4::CoreLibs y2k20 issue

timelocal, timegm yk20 problem

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.