Perl Weekly Challenge 55: Binary Numbers and Wave Arrays

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

Task # 1: Flipping Binary Numbers

You are given a binary number B, consisting of N binary digits 0 or 1: s0, s1, …, s(N-1).

Choose two indices L and R such that 0 ≤ L ≤ R < N and flip the digits s(L), s(L+1), …, s(R). By flipping, we mean change 0 to 1 and vice-versa.

For example, given the binary number 010, the possible flip pair results are listed below:

L=0, R=0 the result binary: 110
L=0, R=1 the result binary: 100
L=0, R=2 the result binary: 101
L=1, R=1 the result binary: 000
L=1, R=2 the result binary: 001
L=2, R=2 the result binary: 011

Paws XXXIX (The Paws is Dead. Long Live the Paws)

S3 is a wrap was quite the journey since September.

The end result

  • All non depreciated S3 actions on API work
  • A new test case 09_requests.t and test for each action was created
  • All none deprecated action now have a 10_response test as well
  • A new Caller that generates both 09 and 10 test case
  • NO changes needed to BOTO

The most important aspect of my changes in my opinion is figuring out how to handle the botocode correctly to cover all the use cases. It was a slow iterative process and what really saved my but was creating the test cases as I went along as I quickly found out if a change that fixed one thing broke something.

There was a combination of changes to the class templates to get the the correct perl class out of the Boto JSON, a number of changes to RestXmlCaller..pm convert those classes into the correct request XML content and a few changes to how the URL and URI where generated.

Are array and hash representations really needed in subroutine signatures?

Are array and hash representations really needed?

Currently, "@foo" is proposed as the array representation. "%foo" is proposed as the representation of the hash.

Are array and hash representations really needed?

Dancer2 0.208002

Your gift is arriving just a bit early this year: a new Dancer2 just in time for the holidays!

There are a number of documentation fixes and enhancements in this version. The largest change you will see under the hood removes Return::MultiLevel (and therefore Scope::Upper) from the list of Dancer2 dependencies, and makes your favorite lightweight web application framework just a little bit lighter.

The full changelog follows:

Perl Weekly Challenge 54: k-th Permutation Sequence and the Collatz Conjecture

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (April 5, 2020). 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: kth Permutation Sequence

Write a script to accept two integers n (>=1) and k (>=1). It should print the kth permutation of n integers. For more information, please follow the wiki page.

For example, n=3 and k=4, the possible permutation sequences are listed below:

Perl Weekly Challenge 038: Date Finder and Word Game

Date Finder

Create a script to accept a 7 digits number, where the first number can only be 1 or 2. The second and third digits can be anything 0-9. The fourth and fifth digits corresponds to the month i.e. 01, 02, 03…, 11, 12. And the last 2 digits respresents the days in the month i.e. 01, 02, 03…, 29, 30, 31. Your script should validate if the given number is valid as per the rule and then convert into human readable format date.

RULES

  1. If 1st digit is 1, then prepend 20 otherwise 19 to the 2nd and 3rd digits to make it 4-digits year.
  2. The 4th and 5th digits together should be a valid month.
  3. The 6th and 7th digits together should be a valid day for the above month.

For example, the given number is 2230120, it should print 1923-01-20.

As we’ve done several times, we’ll use the core module Time::Piece to handle dates.

Some blogs.perl.org 10 Year Stats.

blogs.perl.org recently turned 10 years old. I was curious about the level of traffic so grabbed all of the post URLs and meta information to create the lists below. These are accurate up until the posting of this post (excluding this post):

  • Total Posts: 8,091
  • Total Posts (2016 Onwards): 2,595
  • Total Unique Authors: 676
  • Authors With Only 1 Post: 246

Most Active Authors (All Time):

  • byterock - 604
  • jt_smith - 442
  • ovid - 382
  • sawyer_x - 304
  • brian_d_foy - 227
  • steven_haryanto - 160
  • yuki_kimoto - 153
  • ron_savage - 148
  • joel_berger - 132

Most Active Authors (2016 onwards):

  • byterock - 417
  • sawyer_x - 138
  • yuki_kimoto - 93
  • dean - 72
  • mohammad_s_anwar - 69
  • melezhik - 66
  • zoffix_znet - 65
  • ovid - 59
  • neilb - 55

Most Active Months:

  • 2012-07: 163
  • 2010-08: 134
  • 2012-04: 128
  • 2011-10: 121
  • 2014-03: 121
  • 2013-02: 119
  • 2012-05: 118
  • 2012-03: 117
  • 2010-07: 114
  • 2011-11: 111

Total Post Count By Year:

  • 2009 - 116
  • 2010 - 1,023
  • 2011 - 1,094
  • 2012 - 1,274
  • 2013 - 1,006
  • 2014 - 983
  • 2015 - 542
  • 2016 - 535
  • 2017 - 459
  • 2018 - 664
  • 2019 - 395

Perl Subroutine Signatures Opinion Blog

I have great respect for Perl developers.

I am always grateful for the work.


On the other hand, I have a very strong concern in the future of Perl.


I created a site for my opinions on subroutine signatures so that themes would not be missed in the discussion.

Perl Subroutine Signatures Opinion Blog


I have no final authority. I pray Perl developers make a good decision.

Perl Weekly Challenge 53: Rotate Matrix and Vowel Strings

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 29, 2020). 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: Rotate Matrix

Write a script to rotate the following matrix by given 90/180/270 degrees clockwise.

[ 1, 2, 3 ]
[ 4, 5, 6 ]
[ 7, 8, 9 ]

For example, if you rotate by 90 degrees then expected result should be like below:

[ 7, 4, 1 ]
[ 8, 5, 2 ]
[ 9, 6, 3 ]

Apache SpamAssassin 3.4.3 has been released!

Apache SpamAssassin 3.4.3 contains numerous tweaks and bug fixes as we prepare to move to version 4.0.0 with better, native UTF-8 handling. There are a number of functional patches, improvements as well as security reasons to upgrade to 3.4.3. In this release, there is also one new plugin and there are bug fixes for two CVEs:
  • CVE-2019-12420 for Multipart Denial of Service Vulnerability
  • CVE-2018-11805 for nefarious CF files can be configured to run system commands without any output or errors.
*** On March 1, 2020, we will stop publishing rulesets with SHA-1 signatures. If you do not update to 3.4.2 or later, you will be stuck at the last ruleset with SHA-1 signatures. ***

Download: https://spamassassin.apache.org/downloads.cgi?update=201912112330

See also https://spamassassin.apache.org/news.html

Paws XXXV (Well not a wrap but close)

Well it looks like a wrap for Paws S3

I made up my own test creation caller. No rocket science in this one. I just added in a few useful attributes;

Type::Tiny 1.8.0 released

Type::Tiny 1.8.0 (1.008000) was released today.

The new features are pretty minor. Most of the improvements are in documentation and testing.

  • Totally rewritten manual/tutorial.

  • Every issue on RT has been handled.

  • Bigger test suite. The exact number of tests run varies based on the availability of optional dependencies, but I just ran the test suite with EXTENDED_TESTING set to false and most of the optional dependencies installed, and it was nearly 7500 tests, compared to just over 2700 for Type::Tiny 1.6.0. With EXTENDED_TESTING true, there are nearly 13900 tests.

    This includes a set of tests for each built-in type which are intended to function both as test cases and advanced documentation.

Perl Weekly Challenge 52: Stepping Numbers and Lucky Winner

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

Task 1: Stepping Numbers

Write a script to accept two numbers between 100 and 999. It should then print all Stepping Numbers between them.

A number is called a stepping number if the adjacent digits have a difference of 1. For example, 456 is a stepping number but 129 is not.

Just to make things slightly clearer, I would say that all adjacent digits should have an absolute difference of 1, so that 542, 454, or 654 are also stepping numbers.

Stepping Numbers in Perl

Given that the range is quite small, we can use a brute force approach on all numbers between the input values: check for every number in the range whether it fits the definition.

Why is the specification of subroutine signatures so complicated?

As a general Perl user who uses Perl for text processing on Linux, I have a simple question.

Why is the specification of subroutine signatures so complicated?

Jumbo Signatures extensions discussion

The most common criticism of Perl is that it cannot read Perl grammar.

If Perl grammar evolves in an easy-to-understand direction, you are welcome.

If you are going to increase the complexity blame for Perl, think a little more.

Is this feature really useful for users who want to do text processing on Linux/Unix?

A single language cannot satisfy every need.

I have not yet seen what purpose Perl is aiming for.

CPAN Testers at meta::hack v4

For this year's MetaCPAN Hackathon, I decided I wanted to start turning the CPAN Testers mockup I made 3 years ago into a real, working site. Along the way, I built a much better development environment for CPAN Testers, making it even easier for someone to start working on the project. I also released Mojolicious::Plugin::Moai, a UI widget kit for Mojolicious.

Thanks to cPanel and Booking.com for their continued sponsorship of this event!

Rewriting Perl Code for Raku IV: A New Hope

Part IV starts to get into the heart of OLE::Storage_Lite by covering the pack/unpack builtins.

Perl Weekly Challenge # 50: Merge Intervals and Noble Numbers

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

Task 1: Merge Intervals

Write a script to merge the given intervals where ever possible.

[2,7], [3,9], [10,12], [15,19], [18,22]

The script should merge [2, 7] and [3, 9] together to return [2, 9].

Similarly it should also merge [15, 19] and [18, 22] together to return [15, 22].

The final result should be something like below:

[2, 9], [10, 12], [15, 22]

The example shows that intervals should be merged only if they overlap, but not if they are contiguous (in the example, [2,9] is not merged with [10, 12]).

Merge Intervals in Perl

For each interval except the first one, we check whether it overlaps with the previous one (stored in the $current variable); if it does overlap, we build a new interval merging it with $current.

Paws XXXVI (Still not finished.)

Well finally got the last of my tests done for S3, not much of a story as most of the test cases at least for the 'PUT' actions cases were mostly made up of two tests 'load' the results class and check the value of the '_request_id'.

That being said I still had some 80 tests that where failing most of them where this '_request_id' test. Seems when I was doing my test generator I was creating the test for '_request_id' but forgot to add it to the test content.

So a little change to 'FullTestMakerLWPCaller.pm'

Perl Weekly Challenge 037: Weekdays and Daylight Gain/Loss

Weekdays

Write a script to calculate the total number of weekdays (Mon-Fri) in each month of the year 2019.

I used the core module Time::Piece and its companion from the same distribution, Time::Seconds. Let’s start on the first day of the month, and keep adding one day while we stay in the same month. Along the way, count the days that aren’t Saturdays and Sundays.

Working with CSV files using PDL

Ahh, the venerable comma separated variable format, beloved of data scientists.

I grabbed a couple of csv files from Matt Pettis’ csvkit talk to prepare for the datafile that I should be getting my mitts on and tripped and bumped my way through the documentation for PDL::IO::CSV and metaphorically skinned my knees, as you do when you don’t read too carefully.

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.