Perl Weekly Challenge 78: Leader Element and Left Rotation

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

Spoiler Alert: This weekly challenge deadline is due in a few days (September 20, 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: Leader Element

You are given an array @A containing distinct integers.

Write a script to find all leader elements in the array @A. Print (0) if none found.

An element is leader if it is greater than all the elements to its right side.

Example 1:

Input: @A = (9, 10, 7, 5, 6, 1)
Output: (10, 7, 6, 1)

Example 2:

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

Zydeco::Lite

Today I released Zydeco::Lite, a re-implementation of Zydeco but just using standard Perl syntax. So for example, class { ... } becomes class(sub { ...});.

This has the advantage of much faster compile time, similar run time speed, fewer dependencies, and compatibility with older versions of Perl before the keyword API was introduced. Of course, in some circumstances these aren't important concerns, so the nicer syntax of the full Zydeco will be preferred.

Zydeco and Zydeco::Lite are both based on MooX::Press which itself is based on Moo, Type::Tiny, and other modules. I've taken the synopsis example from the Zydeco documentation and rewritten it using the different layers of abstraction.

Mid September Software Releases 2020

Perl5-IDEA 2020.2.3 (Perl5 plugins for IntelliJ IDEA)

"Profiler support and bugfixes"

https://github.com/Camelcade/Perl5-IDEA/releases/tag/2020.2.3

LemonLDAP-NG Apache::Session::Browseable v1.3.8

"This release contains fixes for CVE-2020-16093, which concerns LDAP server certificate verification when using LDAPS."

https://github.com/LemonLDAPNG/Apache-Session-Browseable/releases/tag/v1.3.8

Pulled Pork 0.7.4

"This release includes numerous bug fixes for some issues that have been around for some time. PulledPork v0.7.4 has been tested with Snort 2.16.1 and Snort 3.0.1."

https://github.com/shirkdog/pulledpork/releases/tag/v0.7.4

LedgerSMB

Releases on each maintained branch

https://github.com/ledgersmb/LedgerSMB/releases/tag/1.8.2

https://github.com/ledgersmb/LedgerSMB/releases/tag/1.7.21

https://github.com/ledgersmb/LedgerSMB/releases/tag/1.6.25


CLOC (Count Lines of Code) 1.88

"Add missing Raku_or_Prolog() subroutine; new languages and file types LLVM IR, Logos, Meson, Mojo, Odin, Jinja Templates, WXML, WXSS; support MATLAB block comments; minor bug fixes."

https://github.com/AlDanial/cloc/releases/tag/1.88

SSL Tools (rolling)

Pull requests accepted

https://github.com/noxxi/p5-ssl-tools

Week #77: Fibonacci Sum and Lonely X

Please follow the blog where I discuss the "Fibonacci Sum" and "Lonely X" task of "The Weekly Challenge - 077".

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

Expand one into two - CY's Take on TWC#077

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).

I found that I gained unnecessary promotion due to being in a GMT+8.00 timezone - my blogpost appears on the top of http://blogs.perl.org for longer hours.

---

Task 1 Fibonacci Sum

Another dish for math geek!

Really??

Coding Process

I spent a whole day on the Perl script on Fib Sum task. I worked on it until night. Then I have a rest. In the morning next day, finally I gave up a subroutine for cases like "7, 5, 3" => "6, 5, 4, 3, 2, 1" or "11, 9" => "10, 9, 8, 7". The hard time made me recall what I learnt after Challenge #055 Task 2 Wave Array, using a hash to remove any duplicates occurred -- instead of crazy handling of exception cases again and again.

Task Explanation

Web Scraping with Zydeco

So I like to keep local copies of my blogs.perl.org blog posts as Atom entries, but noticed yesterday that I had a few gaps in my collection. The Atom feeds offered by blogs.perl.org only have the most recent articles though, so I decided to write a quick script to scrape the posts. Luckily, I managed to get a table containing the URLs for each post I needed, so I didn't need to bother with following links to find the pages; I just needed to grab the content from them.

I thought some people might find the code interesting especially for its use of lazy attributes. This is one of those "it only needs to be used once, so making the code maintainable isn't important" kinds of projects, do bear that in mind. I've cleaned up the whitespace and added comments for this blog post, but other than that, it's just a quickly hacked together script.

Perl Weekly Challenge: Fibonacci Sum and Lonely X

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (September 13, 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: Fibonacci Sum

You are given a positive integer $N.

Write a script to find out the smallest combination of Fibonacci Numbers required to get $N on addition.

You are NOT allowed to repeat a number. Print 0 if none found.

Example 1:

Input: $N = 6
Output:
    1 + 5 = 6

Example 2:

Input: $N = 9
Output:
    1 + 8 = 9

game code challenge

hi, as already indicated in that reddit post, a new bot contest was planned for next fall: it has now a planned starting date.

it would be nice to see more than ten perl lovers to join the fun, which will also permit to be seen in the loop back stats, unlike the previous contest.

i would like also to highlight:
  • the community developed an extension to write code locally.
  • the community can write contests from easy to expert: see Bender 1, 2, 3, against 4 ; or Pikaptcha 1, 2, 3, 4.
  • the admins will accept to upgrade to perl 7 when time has come, but, i guess, the level of priority will depend on the number of people asking for it.

TIL about Literate Programming

As a programmer whose first job was in the mortgage software industry, “TIL” has always meant “Truth In Lending” to me: you know, that document that the bank is required to give you when you get a mortgage, that’s supposed to explain how much you’re really paying after all the bank’s hidden finance charges, except the numbers don’t seem to make any sense so you just sign it anyway and don’t know anything more than you did before?  Yeah, that one.

Of course, nowadays it means something else, and I’ve had to redirect my ossified mental patterns into new channels, so that, now when I see “TIL,” I can have my brain recognize it as “Today I Learned.” Which is a handy phrase: it encapsulates feelings of discovery, serendipity, and epiphany all into one.  And TIL1 that the way I’ve always tried to write code has a name, a history, and a venerable progenitor—most of my life, without even realizing it, I’ve been trying to use literate programming (only without the tangling).

Week #76: Prime Sum

Please follow the blog where I discuss the "Prime Sum" task of "The Weekly Challenge - 076".

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

Sum of Individuals Gives Meaning - CY's Take on PWC#076

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).

---

Task 1 Prime Sum

What a dish for math geeks! Goldbach's conjecture is immediately recalled. I have chosen to print the answer first, than give the expression and explanation.

RxPerl release candidate is out

I was working on the completely fresh rewrite of perlmodules.net, when I decided I want to use WebSockets with this site.

So "innovations" started flowing through my mind in order to achieve WebSocketry, and ended-up deciding it would be very helpful if I could use ReactiveX on my Mojolicious site, in terms of size and neatness of the code, buglessness and maintainability.

This is how we ended up with RxPerl, a project I spent a lot of time to make it work well.

Now at version v0.16.0 on CPAN, it is a release candidate. I would like to ask anyone interested to take a look and see if they can find things they don't like about it, in advance of its proper v6.0.0 release which could happen late next week.

https://metacpan.org/pod/RxPerl

Thanks.

A concise mtime sorted directory listing application

Today we will focus on a simple task: listing the files contained in a directory, sort them by modification time (see mtime and display the result in a JSON array.

We are gonna use Mojo::File for the file system part and Mojolicious::Lite to expose those data on a simple but effective JSON API.

Why I don't try the Perl Weekly Challenges

A little over a month ago I learned about the Perl Weekly Challenges. The site states the challenges are for any skill level. So, I went and took a look. After looking at the first challenge that week, I realized “any skill level” did not mean my skill level.

My skill level is pretty basic.

I can …

  • open, read, and close text files and do simple manipulation of the data.
  • add, subtract, multiply, and divide when it comes to math.
  • tack on words or phrases to the beginnings or ends of strings okay with loops.
  • write some basic regexen.
  • even roll things randomly.
  • do most of the above conditionally.

… that is about it.

I read the challenges and my mind is totally blank on where to start after…

#!/usr/bin/perl
use strict;
use warnings;

I wish I could grasp the concepts in the Perl Weekly Challenges, especially the math. I have not taken a math class in over 30 years, and what math I remember is, as I said, pretty basic.

Oh, and one needs to be more than a little familiar with Git and GitHub to contribute, which I am not.

Marketing & Branding Survey Results

You can see the results here.

The following is my reflection on those results and doesn't reflect anyone else's opinions. They may not even really be my opinions.

Who responded?

Some 85.9% respondents self identify as Perl programmers and 22.7% as Raku programmers, 33.2% as Software project leaders, and 30% as Business Owners.

Brand Values

In regards to brand values there is a huge gap between perception and expectation. I've cut off the long tail of "Other" responses for clarity, follow the link at the top to see them.

Screenshot_2020-08-23_17-44-47.png
(The long titles overlap. The first 5 are Amateur, Passionate about helping software projects, Powered by Volunteers, Professional, Secretive)
Screenshot_2020-08-23_17-46-25.png
(The long titles overlap. The first 5 are Passionate..., Powered by Volunteers, Professional, Servant Leadership, Supportive)

Perl 7 By Default

Perl 7 has been announced as the next direction of Perl development. My previous blog post explored at a high level the risks and benefits of the announced direction, as well as those of a more incremental proposal. The primary and critical difference between these two approaches is the decision to change interpreter defaults in an incompatible manner; specifically, to have strict and warnings and possibly other features enabled by default for code that does not specify otherwise. I would like to explore each of the arguments presented for this design choice.

Optimizing For New

The primary benefit of changing the implicit defaults is, of course, to allow Perl programmers to write code in a more modern way and newcomers to program in a safer environment without having to know the sometimes arcane or niche ways to activate such an environment.

Patreon eh?

I read today's Perl Weekly and it suggested supporting module authors on patreon. Figured I would give it a try.

I maintain several perl modules, if you depend on any (Such As Test-Simple, Test2, or yath) here is a way to show your support :-)

https://www.patreon.com/exodist

Supporting Perl-related creators via Patreon and GitHub

Yesterday I posted about this in the Perl Weekly newsletter and both Mohammad and myself got 10 new supporters. This is awesome.

There are not many ways to express the fact that you really value the work of someone.
You can send them postcards or thank-you notes, but when was the last time you remembered to do that?

Right, I also keep forgetting to thank the people who create all the free and awesome stuff I use.

Giving money as a way to express your thanks is frowned upon by many people, but trust me, the people who open an account on Patreon to make it easy to donate them money will appreciate it.

In any case it is way better than not saying anything.

What is Patreon?

Patreon is a service where you can give a monthly donation to your favourite creator. Donations can be as low as $1 / month.

What is GitHub Sponsors?

Perl7 is a fork of values

Before reading this, you should watch this video where Bryan Cantrill explains a value-conflict between Joyent and Node.js, I believe we have a similar problem.

In it he defines a list of project values:

values

All these values are important - but they are in tension. In the end one has to choose between them.

Perl's has traditionally prioritized certain values over these others, and in my experience these are:

  • Expressiveness
  • Extensibility
  • Stability

Next stable DBD::SQLite will be released at the end of August

DBD::SQLite 1.65_03 (with SQLite 3.32.3) is a release candidate for the next stable DBD::SQLite. There are no big changes, maybe except for the ncrease of the default upper bound on the number of parameters from 999 to 32766 (since SQLite 3.32).

I'll wait for about a month as always, and release 1.66 at the end of August if there's no blocker nor request to wait for more. Thank you for your patience.

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.