Monthly Report - March

I lost a friend of mine, Jeff Goff (aka DrForr), who passed away on 13th March, 2020, while snorkeling with a group in the Bahamas. He will be missed by many of his friends. May his soul rest in peace.

Most of the time last month was occupied by COVID-19. Being a type-2 diabetic didn't help the cause either. I have suffered with consistent cough all my life. It is really scary when think from COVID-19 point of view. I have survived so far by the grace of ALLAH s.w.t.

I have been working from home since the first week of March. I have been kind of self quarantined. Kids, specially the twins (3 years old) not allowed to play with me. It is really hard to focus on work but somehow I have managed so far. I am getting used to it now.

Tree as a tool for enumeration - CY's take on PWC#053 Task 2

This is a part of Perl Weekly Challenge(PWC) #053 and the followings are related to my solution. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email) if possible, before reading my blog post.

Do tell me if I am wrong or you strongly oppose my statements!

( The first task is simple.
Not much to say about this task.
4-3 = 1; 4-2 =2; 4-1 = 3.
(Honestly I haven't coded on it. :P) )

Here for the second task.

Somehow, it looks like those base-10 special property tasks, e.g. multiples consisting of 1's and 0's(#49), stepping numbers(#052), gapful number(#047) or colourful numbers(#051). Like those base-10 tasks, the possible brute-force way is: list out all possible combinations or permutations, and then exclude unfit candidates (equivalently, only print suitable candidates).

Perl Weekly Challenge 76: Letter Grid

These are some answers to the Week 76 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 Aug. 16, 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: Prime Sum

I’ve written a Raku program to solve this task, but it is unfortunately a bit buggy: it works in most cases, but there are a few rare cases where it doesn’t find the minimum number of prime numbers whose summation gives you the target number. I certainly don’t want to publish here a program which I know to be faulty in some cases, and I no longer have time before the deadline to fix it. So, I’ll skip this task for now.

Task #2: Word Search

PTS 2020 Cancelled

The Perl Toolchain Summit (PTS) won't be happening this year. It had been planned for Vienna, so we're hoping that PTS 2021 will be held in Vienna.

We had wondered about delaying it, or seeing whether there's interest in a virtual PTS, but right now we all have much more important things to worry about. When the time is right, we'll see what makes sense.

In the meantime, stay safe, and look after yourselves, your loved ones, and your neighbours.

Philippe, Laurent, Thomas, & Neil

Enter the Matrix ... with PDL

We interrupt this k-Means broadcast to bring you an important message about threading (the PDL kind, not the Perl kind - darn those overloaded terms!)

The Assignment

Take two vectors, x and y, and create a matrix C from a function of the values of each element pair, such that

On my technical Background - a beginner's story

Different people have come to an interest or develop a skill for different reasons. Nowadays, lots people are learning Python, R, JavaScript, Java, etc. for job hunting as data scientists or software engineers...

Beginner's Enthusiasm in Programming

For me, solitaires (games) always attract me. Programming has been felt like a solitaire . (Some people must disagree with me on this line. They are lucky. And I also want myself can grow as strong as a contributor to the opensource programming community.) Testing. Possible modifications. I learnt LOGO programming language in the primary school. As I can remember, while I was in junior high school, I lost my sleep one night just because of thinking using LOGO to write a Chinese Chess program! (The workload would be too much... LOGO is derived from LISP, I know. Ha.)

Perl Weekly Challenge 75: Coin Sums and Largest Rectangle Histogram

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

Spoiler Alert: This weekly challenge deadline is due in a few days from now (August 30, 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: Coins Sums

You are given a set of coins @C, assuming you have infinite amount of each coin in the set.

Write a script to find how many ways you make sum $S using the coins from the set @C.

Example:

Perl Weekly Challenge 051: 3 Sum and Colourful Numbers

3 Sum

Given an array @L of integers. Write a script to find all unique triplets such that a + b + c is same as the given target T. Also make sure a <= b <= c.

Here is wiki page for more information.

Example:

@L = (-25, -10, -7, -3, 2, 4, 8, 10);

One such triplet for target 0 i.e. -10 + 2 + 8 = 0.

I hadn’t checked the wiki page before writing my solution; and I hadn’t changed the solution after I read it. Therefore, it presents the naive and inefficient solution that iterates over all the possible triplets (but not starting from 0 in the inner loops to avoid checking the same triplet several times).

KBOS methods

After scopes, types and signatures we got all the prerequisites to talk about the syntax and semantics of KBOS methods. Unless you want to contribute to Kephra or write a plugin, you may never use them, but please join me in the thought experiment - maybe we get a littler smarter.

()

$ perl -Mstrict -we'$_ = time; print "$_\n"'
1583887020

<.<

$ perl -Mstrict -we'$_ = CORE::time; print "$_\n"'
1583887039

>.>

$ perl -Mstrict -we'$_ = time - CORE::time; print "$_\n"'
0

-_- ...

$ perl -Mstrict -we'BEGIN{*CORE::GLOBAL::time=sub{42}} $_ = time - CORE::time; print "$_\n"'
42

(┛◉Д◉)┛彡┻━

$ perl -Mstrict -we'BEGIN{*CORE::GLOBAL::time=sub{42}} $_ = time() - CORE::time; print "$_\n"'
-1583886770


🧑🔬

$ alias deparse='perl -Mstrict -MO=Deparse,-p -we'

$ deparse 'BEGIN{*CORE::GLOBAL::time=sub{42}} $_ = time - CORE::time; print "$_\n"'
BEGIN { $^W = 1; }
use strict;
sub BEGIN {
(*CORE::GLOBAL::time = sub {
42;
}
);
}
($_ = time((-time))); # !!!
print("$_\n");
-e syntax OK

$ deparse '$_ = time - CORE::time; print "$_\n"'
BEGIN { $^W = 1; }
use strict;
($_ = (time - time)); # O.o
print("$_\n");
-e syntax OK

$ deparse 'BEGIN{*CORE::GLOBAL::time=sub{42}} $_ = time() - CORE::time; print "$_\n"'
BEGIN { $^W = 1; }
use strict;
sub BEGIN {
(*CORE::GLOBAL::time = sub {
42;
}
);
}
($_ = (time() - time)); # ✓
print("$_\n");
-e syntax OK


🤔

Perl Weekly Challenge 74: Majority Element and FNR Character

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

Spoiler Alert: This weekly challenge deadline is due in a few hours from now. 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: Majority Element

You are given an array of integers of size $N.

Write a script to find the majority element. If none found then print -1.

Majority element in the list is the one that appears more than floor(size_of_list/2).

Example 1: Input: @A = (1, 2, 2, 3, 2, 4, 2) Output: 2, as 2 appears 4 times in the list which is more than floor(7/2).

Example 2: Input: @A = (1, 3, 1, 2, 4, 5) Output: -1 as none of the elements appears more than floor(6/2).

Majority Element in Raku

BLOG: The Weekly Challenge #051

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

No Paws in this post (well maybe a litte)

Well back to the PAWs game again. This is one group of actions that has really got me distracted.

In my last post I manged to get 'SubscribeToShard' to work with my stream decoder though it is really just beta code for now. What first go me distracted was reading along in the Amazon doc I saw a bit about streaming an audio file.

Well the last time I worked on this sort of stream was in the dieing days of the last century??

This got me thinking and I went downstairs and dusted off my good old 2201 and fired it up thinking it might come in useful. Next I had to find some 'C' code and files I had from that time that I think I had on on 3.5 floppy in my upstairs closet.

Well I found the disks and once my HP Pavilion booted up I found that the disks where sill readable and still compiled. Well step one and two done.

Extracting coronavirus SARS-CoV-2 spike protein sequences with BioPerl

As I started learning Perl I found out that there is a collection of Perl modules for bioinformatics tasks and it is called BioPerl. Intrigued I decided to try to use it for a simple task as it would help me in learning Perl. So the next question was: what task should I choose? Maybe download file with biological sequences, parse it and filter according some criteria? Thinking about this further I made a choice. I will work with sequences of infamous coronavirus which is more precisely named as SARS-CoV-2!

Spikes of coronaviruses – why are they so important?

Perl Weekly Challenge 73: Min Sliding Window and Smallest Neighbor

These are some answers to the Week 73 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 Aug. 16, 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: Min Sliding Window

You are given an array of integers @A and sliding window size $S.

Write a script to create an array of min from each sliding window.

Example:

BLOG: The Weekly Challenge #050

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

Perl Weekly Challenge 050: Merge Intervals and Noble Integer

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]

This sounds so similar to PWC 039 I first thought I could solve it in the same way. Unfortunately, Set::IntSpan gives a different result:

  k-Means
k-Means-er

As we take another lap around the k-Means race trace, the Porsche 914-2 and Volvo 142E are still neck and neck. This time we'll try a straight-forward normalisation that linearly scales all values to the range [0,1] and see if they still end up in the same cluster.

Perl Weekly Challenge 72: One-Liners for Trailing Zeros and Line Ranges

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

Spoiler Alert: This weekly challenge deadline is due in a few hours. This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.

Since both tasks in this week challenge are quite simple, I decided to use only one-liners to solve each task, both in Raku and in Perl.

Task 1: Trailing Zeros

You are given a positive integer $N (<= 10).

Write a script to print number of trailing zeroes in $N!.

Example 1:

Input: $N = 10
Output: 2 as $N! = 3628800 has 2 trailing zeroes

Example 2

Input: $N = 7
Output: 1 as $N! = 5040 has 1 trailing zero

Example 3:

CY's Take on Perl Weekly Challenge #052

This is a part of Perl Weekly Challenge(PWC) #052 and the followings are related to my solution. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email) if possible, before reading my blog post.

Do tell me if I am wrong or you strongly oppose my statements!

I register a free account on blogs.perl.org . The process is surprisingly easy but I am a bit nervous that my posts are put along those of experienced coders on the frontpage of blogs.perl.org .

Back to the main topic.

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.