Perl Weekly Challenge 258: Sum of Values

These are some answers to the Week 258, Task 2, 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 March 3, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 2: Sum of Values

You are given an array of integers, @int and an integer $k.

Write a script to find the sum of values whose index binary representation has exactly $k number of 1-bit set.

Example 1

Perl Weekly Challenge #236 - Lemonade Stand

Welcome back to another round of the weekly challenge, with just one solution this week. I'm setting up a lemonade stand and need to deal with change. Interestingly, I can only sell one juice per person, so I hope you're not super thirsty!

We can take $5, $10, and $20 bills, and we don't start with any change, so we need our previous customers to provide us with change for future customers. Let's find out if we can make change for a set of customers.

Here's the code:

This Week in PSC (128) | 2023-12-14

This week, Graham was on holidays, so Paul and Philippe:

  • reviewed new mailing list threads. Just one - a rethink of signatures.
  • submitted a talk proposal to the Perl dev room at FOSDEM
  • continued to discuss the complexities of moving past the number ‘5’ for the major part of the language version

Quote of the week: “There are features that make the language slow, but those are the features that make the language.”

Single Color Methods of GTC

Whohoo release 1.7 (and 1.6) brought a thorough architectural rewrite, new color spaces (HSV, HWB, YIQ), new formats ([named] array, string and css_string), choosable value ranges, closed both open issues, and introduced the named argument API I wrote last time about. And as promised, this post is about the methods: distance, set, add and blend.

Perl Weekly Challenge 258: Count Even Digits Numbers

These are some answers to the Week 258, Task 1, 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 3, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 1: Count Even Digits Number

You are given a array of positive integers, @ints.

Write a script to find out how many integers have even number of digits.

Example 1

Input: @ints = (10, 1, 111, 24, 1000)
Output: 3

There are 3 integers having even digits i.e. 10, 24 and 1000.

Example 2

Input: @ints = (111, 1, 11111)
Output: 0

Example 3

Of Go, C, Perl and fastq file conversion Vol IV : gone in 60 seconds (or less)

In the final part of this series, we will test the performance of the four parsers, in a scenario emulating the batch analysis of sequencing data. We will use the sample fastq file 3_OHara_S2_rbcLa_2019_minq7.fastq from https://zenodo.org/record/3736457. This is a 35MB file of 21791 long sequences for a nanopore experiment. Download the data and save them to a directory in your hard disk. Then use the following bash time_fastq2a_shell.txt (change the extension to .sh before running!) to process this file 500 times with each of the four methods : seqtk (C), seqkit (Go), perl - regex (code presented here  saved into fastq2a_regex_comp_in_func.pl file) and perl - flag (code presented there saved into the fastq2a_flag.pl file).


Issue the following from the command line to store the timings as a tab separated file:

This week in PSC (116) | 2023-09-14

There were only two of us this week, and the list is still a bit quiet.

The main topic was stalled PPC work: we have a few PPCs that have been approved and are in the “Implementing” state, but still waiting for an implementor. We’ll send a separate email asking for volunteers on those.

CGI::Tiny & Dispatch::Fu - nearly a perfect match

CGI::Tiny is a very nice, Perlish way to construct CGI scripts these days. It is perfectly suited as a replacement to CGI.pm and is quite at home in a shared hosting environment.

Here's the example from the POD [1] on metacpan:

    use CGI::Tiny;
    cgi {
      my $cgi = $_;
      # set up error handling on $cgi
      # inspect request data via $cgi
      # set response headers if needed via $cgi
      # render response with $cgi->render or $cgi->render_chunk
    }; 
        

I recently coupled this with my new module Dispatch::Fu [2], and it worked exceedingly well. It is a darn pleasure to consider from a distance, if I do say so myself:

Perl Weekly Challenge 257: Reduced Row Echelon

These are some answers to the Week 257, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Warning: I wrote the program below and this blog post from an hospital bed in a heart intensive care unit. I think my mind is clear, but there may very well be a better way to solve the task. Also, I do not have the energy to port this Raku program to other languages, nor to provide lengthy explanations.

Task 2: Reduced Row Echelon

Given a matrix M, check whether the matrix is in reduced row echelon form.

A matrix must have the following properties to be in reduced row echelon form:

Perl Weekly Challenge #234 - Sharing is Caring

Hi everybody! Back this week with a (surprisingly long) solution to just Task 1 of the weekly challenge. Task 2 makes no sense to me at all because it seems like examples 1 and 3 disagree with each other. Just sticking to one challenge for that reason. Anyways, let's dive into it!

The goal here is to find the letters that all the provided words share. Here's the code:

Get more from you constants with constant::more

One of my 'nuts and bolts' modules is constant::more. It declares constants, just like constant , however also gives you the ability to set these values in a consistent way from the command line or environment variables.

This can give module authors constants with 'default values', and allow the top level application code to override from the command line if they choose.

This has worked well for my needs to date. I've just released v0.3.0 with some additional features I feel make it even more useful and might make it more useful for others:

Flat list of for multiple constants

Originally I made the interface only work like constant for simple use cases. This meant multiple constants had to be inside a hash ref of actually multiple use constant::more... lines.

use constant::more {CONST1=>1, CONST2=>2};

Now a flat list is usable, which I personally find much more appealing:

use constant::more CONST1=>1, CONST2=>2;

Enumerations

Announcing Dancer Core Team Changes

We’re excited to announce that Ruth Holloway (GeekRuthie) has joined the Dancer Core Team.

Ruth is a longtime user of Dancer2, and has been one of our most vocal supporters in the greater Perl community. She’s responsible for a number of excellent additions to the Dancer2 ecosystem, and is an active member of our wonderful community.

Please join us in welcoming Ruth to our team. We’re looking forward to her continued contributions to the framework and community.

In other news, Steven Humphrey has retired from the Core Team. We’re grateful for his contributions to Dancer2, and wish him well in his future endeavors.

Perl Weekly Challenge 257: Smaller than Current

These are some answers to the Week 257, Task 1, 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 25, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 1: Smaller than Current

You are given a array of integers, @ints.

Write a script to find out how many integers are smaller than current i.e. foreach ints[i], count ints[j] < ints[i] where i != j.

Example 1

A bit of history about The Gecko Book, aka "Learning Perl on Win32 Systems"... (from my "Half my life with Perl" talk a decade ago)

Screenshot 2023-09-08 at 11.40.16 AM.png

This week in PSC (115) | 2023-09-07

This week, we discussed several topics:

  • collecting bugfixes to put in a 5.38.1 maintenance release
  • Module::CoreList automated releases, and how we might get them created — what PAUSE user, etc…
  • once the PPC for meta:: officially exists, it would be worth having a release on CPAN, to experiment with
  • the PPC process still needs some refinement and further clarification on what gets done, when, and by whom

Of Go, C, Perl and fastq file conversion Vol II : the Jedi regex

In the second part of this series about fast parsers for sequencing applications,  I will review the code for the regex based parser. This is shown below (I use v5.38, as you should! because the year is 2023 and you should not have to type use strict; use warnings)

Perl Weekly Challenge 256: Merge Strings

These are some answers to the Week 256, Task 2, 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 18, 2024 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 2: Merge Strings

You are given two strings, $str1 and $str2.

Write a script to merge the given strings by adding in alternative order starting with the first string. If a string is longer than the other then append the remaining at the end.

Example 1

Input: $str1 = "abcd", $str2 = "1234"
Output: "a1b2c3d4"

Example 2

Input: $str1 = "abc", $str2 = "12345"
Output: "a1b2c345"

Example 3

Perl Weekly Challenge #233 - Similar Words and Frequency Sort

Hello everybody! For this week's weekly challenge I thought the challenges looked really easy, but they both had a couple slight complicating factors. Also, this was the first time I've used sub signatures.

Similar Words

For this one, we're looking for words that share all characters. We print out each pair of countries.

This Week in PSC (127) | 2023-12-07

This week we:

  • Worked out final resolving actions for security issues.
  • Discussed recent mailing-list posts about making method non-public by default. This probably won’t work but we could open a PPC discussion on my method + $obj->&method syntax.
  • Reviewed Projects in Flight - posted below
  • Merged the PR for PPC 0022 (Metaprogramming API). Discussions on individual points can be made using GH Issues

Projects in Flight

  • HTTPS out of the box — (Paul) has nudged Mark Gardner by email
  • PPC 0013 overload in join — (Philippe) should open an issue with his thoughts on the topic
  • PPC 0014 English names — (Paul) should check in with Joe McMahon
  • PPC 0019 qt Strings — (Paul) now has TPF Core Development Grant so can start writing this Any Day Now(TM)
  • PPC 0021 Optional chaining — (Paul) should check in with Veesh Goldman
  • PPC 0022 Metaprogramming API — (Paul) has a CPAN module, would be nice if anyone started using it for any reason
  • (Graham) to write a PPC for ->&
  • Perl roadmap for 2024 — Yeah it’d be nice if we had one, but without having any weight of promise behind it it’s just words
  • TODDR to write a draft pod/security_disclosure_process.pod (not in December), and also offered to coordinate the next incident

GTC API (how to design a rich interface)

After written about the origin and goals of Graphics::Toolkit::Color -- let's take a look at the public methods and make it a little study of good API design. But lets work our way up from a few examples:

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.