Perl Weekly Challenge 058: Compare Version and Ordered Lineup
Compare Version
Compare two given version number strings v1 and v2 such that:
- If v1 > v2 return 1
- If v1 < v2 return -1
- Otherwise, return 0
The version numbers are non-empty strings containing only digits, and the dot (“.”) and underscore (“_”) characters. (“_” denotes an alpha/development version, and has a lower precedence than a dot, “.”). Here are some examples:
v1 v2 Result 0.1 < 1.1 -1 2.0 > 1.2 1 1.2 < 1.2_5 -1 1.2.1 > 1.2_1 1 1.2.1 = 1.2.1 0
When I read the task assignment, I thought to myself: I’m not the first person in the world that needs to compare versions. There already must be a module on CPAN that does exactly that. As usually, it wasn’t so simple.
Perl Weekly Challenge 92: Isomorphic Strings and Insert Intervals
These are some answers to the Week 92 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.
Task 1: Isomorphic Strings
You are given two strings $A and $B.
Write a script to check if the given strings are Isomorphic. Print 1 if they are, otherwise 0.
Example 1:
Input: $A = "abc"; $B = "xyz"
Output: 1
Example 2:
Input: $A = "abb"; $B = "xyy"
Output: 1
Example 3:
Input: $A = "sum"; $B = "add"
Output: 0
Isomorphic Strings in Raku
PWC 057: Task #1, Invert Tree & Task #2, Shortest Unique Prefix
PWC Task #1, Invert Tree
jaredor submission for Task #1
The problem is in two parts, flipping the tree and pretty-printing it.
The flipping part is pretty easy, but since I'm a huge fan of Higher Order Perl I thought I should at least try to make it sort of like the tree walking code I remembered reading, where you give the tree-walker the function you want to operate on each node. (That word, "remembered" should be a hint that I haven't read the book in years and you should really go read the master.) I wrote both a depth-first and a breadth-first binary tree walker. For the purposes of flipping the whole tree, either one would have sufficed, but it is handy to have the option when you are experimenting.
the Giant Planet of Perl
Finally I saw posts of PWC#056 on blogs.perl.org .
I haven't found what to discuss about #056 Task #1. Just to keep people know this code producer is alive and healthy, I share my recent life:
On Perl resources:
1. Perl Monks
From a blogpost[1], I was hooked to https://www.perlmonks.com/ . Apart from many advanced Perl discussions, there is a book review section (not very active):
Book Reviews of Perl Monks
Yesterday I got the "Perl Debugged" and "Perl Best Practices" on my hand, which are both recommended for fresh-to-intermediate Perl programmers. Yeah!
( The Best Practices seems to be accepted as one of commons among Perl programmers. There is Perl::Critic (learnt from the PWC Champion Interview March 2020). And there is a reference sheet on the book. )
The monks also have a tutorial section:
Tutorials of Perl Monks
2. Perl Weekly
I discovered the perlweekly.com by... Searching my own name on the Internet. (Sorry, I have some kinds of narcissistic behaviour).
Perl Weekly Challenge 91: Count Numbers and Jump Games
These are some answers to the Week 91 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a few days (December 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: Count Numbers
You are given a positive number $N.
Write a script to count number and display as you read it.
Example 1:
Input: $N = 1122234
Output: 21321314
as we read "two 1 three 2 one 3 one 4"
Example 2:
PWC 056: Task #1, Diff-K & Task #2, Path Sum
After posting two separate blogs for PWC 055 and seeing how awkward the explanations were, I'll try a new tack: Both submissions will be elaborated in one blog post. The elaborations will not be explanations. I'll focus more on the "idea" part and let any programming details come out in the comments, if at all.
PWC Task #1, Diff-K
jaredor submission for Task #1
Input
For input I decided that all the numbers in the array would be command line arguments. That meant that 'k' would have to be a command line option. There was some validation that the stated requirements were met.One input requirement "given an array @N of positive integers (sorted)" seemed to say that the input array should be sorted. The algorithm I chose worked without any sorting requirement on input, so this was not checked.
Case 1: k > 0
Perlmongers Conferences in the Time of Corona
I’m collecting different setups here. Other efforts are underway to organize a virtual conference. The setups listed below aim for smaller audiences with hopefully lower effort in setting things up.
I don’t discuss the other stuff needed for organizing a conference, like the social aspects (”hallway track”, “moderation”, “timekeeping”) or how people can forward questions from the chat to the speaker. The logistic aspects are mostly that outside of the “producer”, ideally nobody needs to install software beyond Chromium or another browser compatible enough with Jitsi to do video streaming.
CY's take Perl Weekly Challenge on #055
This is a part of Perl Weekly Challenge(PWC) #055 and the followings are related to my solution.
Do tell me if I am wrong or you strongly oppose my statements!
Oh.
Perl Weekly Challenge 90: DNA Sequence and Ethiopian Multiplication
These are some answers to the Week 90 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a few days (December 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: DNA Sequence
DNA is a long, chainlike molecule which has two strands twisted into a double helix. The two strands are made up of simpler molecules called nucleotides. Each nucleotide is composed of one of the four nitrogen-containing nucleobases cytosine (C), guanine (G), adenine (A) and thymine (T).
You are given DNA sequence, GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG.
Write a script to print nucleobase count in the given DNA sequence. Also print the complementary sequence where Thymine (T) on one strand is always facing an adenine (A) and vice versa; guanine (G) is always facing a cytosine (C) and vice versa.
To get the complementary sequence use the following mapping:
Docker::Names::Random
If you are using Docker, you may have noticed that it creates random names for containers when you haven't provided any specific name. These names are a combination of an adjective and a proper name of an individual. The individuals are famous men and women picked from the history of scientific exploration and engineering.
This package allows you to use the same system in your own programs. You would get combinations like interesting_mendeleev, epic_engelbart, lucid_dhawan, recursing_cori, ecstatic_liskov and busy_ardinghelli.
The combination boring_wozniak is not allowed because Steve Wozniak is not boring. This same limitation exists in the original code.
SYNOPSIS
KBOS attributes
Welcome to the fifth post about the Kephra Base Object System, where I explain the need for three kinds of attributes: data, delegating and wrapping and gas a little about their properties. It is especially advised to have read the first part (scopes) and the previous part, since accessors are methods.
In case you wonder how practical this exercise is - I already implemented a slightly simpler version and currently rewrite it. It's a standalone bundle of modules with its own tests and docs named Base-Class (Kephra::Base::Class) (123kB), which depends only on the bundle Base (there are the data types) (32 kB). So once ready it could be released on CPAN without much work.
Perl Weekly Challenge 89: GCD Sums and Magic Squares
These are some answers to the Week 89 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Task 1: GCD Sums
You are given a positive integer $N.
Write a script to sum GCD of all possible unique pairs between 1 and $N.
Example 1:
Input: 3
Output: 3
gcd(1,2) + gcd(1,3) + gcd(2,3)
Example 2:
Input: 4
Output: 7
gcd(1,2) + gcd(1,3) + gcd(1,4) + gcd(2,3) + gcd(2,4) + gcd(3,4)
GCD Sums in Raku
An existential threat (that isn't COVID-19)
Many of you will know my good friend Peter Scott as a Perl luminary. More recently he has turned his attention and his considerable talents to focus on the future of AI, both as an unprecedented opportunity for our society...and as an unprecedented threat to our species.
A few years back, he released an excellent book on the subject, and just recently he was invited to speak on the subject at TEDx. His talk brilliantly sums up both the extraordinary possibilities and the terrible risks inherent in turning over our decision-making to systems whose capacities are increasingly growing beyond our own abilities, and perhaps soon beyond even our own understanding.
Whether our accelerating use of AI brings us utopia or extinction, the very real possibility of either outcome surely makes these twelve minutes well worth paying attention to.
Dancer2 0.300001 Released
On behalf of the Dancer Core Team, I’d like to announce the availability of Dancer2 0.300001. This maintenance release brings brings a revamped tutorial, fixing of a YAML-related regression, repair of an encoding bug, and a slew of documentation fixes.
The full changelog is as follows:
Perl Weekly Challenge 054: Kth Permutation Sequence + Collatz Conjecture
Kth Permutation Sequence
Write a script to accept two integers n (>=1) and k (>=1). It should print the k-th permutation of n integers.For example, n=3 and k=4, the possible permutation sequences are listed below:
123 132 213 231 312 321The script should print the 4th permutation sequence 231.
The straightforward way is to generate all the permutations in the correct order and then output the kth one. To generate them, we can use recursion: To get all the permutations of n elements, start with each element and extend it with all the permutations of the remaining elements.
Perl Weekly Challenge 88: Array of Products and Spiral Matrices
These are some answers to the Week 88 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (November 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: Array of Products
You are given an array of positive integers @N.
Write a script to return an array @M where $M[i] is the product of all elements of @N except the index $N[i].
Example 1:
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.



