Perl weekly challenge 95

Palindromic numbers

You are given a number $N. Write a script to figure out if the given number is Palindrome. Print 1 if true otherwise 0.

There is an easy solution to this - to use "reverse" in string context to reverse the number and comparing the two strings:


sub is_palindrome_rev {
  return ( $_[0] eq reverse $_[0]) ? 1 : 0;
}

But this just seems a touch too easy - so let's see if we can find an alternative solution. Something that will potentially work in any base - not just base 10!

Perl Weekly Challenge 95: Palindrome Numbers and Demo Stack

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

Spoiler Alert: This weekly challenge deadline is due in a few of days (January 17, 2021). 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: Palindrome Numbers

You are given a number $N.

Write a script to figure out if the given number is Palindrome. Print 1 if true otherwise 0.

Example 1:

Input: 1221
Output: 1

Example 2:

Input: -101
Output: 0, since -101 and 101- are not the same.

Example 3:

Input: 90
Output: 0

A Static Archive of rt.cpan.org

I have created a static archive of rt.cpan.org - it is avaliable at https://rt-cpan.github.io/. This is now what will be the official static archive once rt.cpan.org is sunset.

The static archive is a git repo, hosted using github pages. The repo can be found at https://github.com/rt-cpan/rt-cpan.github.io and it has a README that explains how the archive is/was built and URL structure.

The archive is generally complete, it will be updated one more time before the end of February this year. If you discover any issues then please raise an issue using the github link above. If you need to search the archive then you can do that using the gihub link above also, or git clone it and use the command line.

Happy New Year!

You think you're an X, but you're only a Y

The other day I was converting the output of a Git::Raw::Commit into JSON using my module JSON::Create, when I noticed an oddity:

{
"commits":[
    {
        "body":null,
        "id":"27ed4669e32ce2d14831c719dfd5b341a659788e",
        "message":"Remove a stray html ending tag\n",
        "time":"1609997818"
    },

The "time" part always comes out as a string, even though it's clearly a number. Was this a bug in my module, some kind of dual-string-and-number wannabee variable which JSON::Create falsely turned into a string?

CY's Take on PWC#094

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

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

Task 1 of #094 looks like a sibling of Task 1 of #092 (which Perl codes are recently reviewed, my submitted code here) and Task 2 of #094 looks like a sibling of Task 2 of #093 (where I use the array representation of binary tree, code here).

Task 1: Group Anagrams

Now I was thinking of CJK characters. When comparing terms, put -CA; and inside scripts, put use utf8; use open ':std', ':encoding(UTF-8)';.

And my approach is similar to that of Week #092. On #092, a sub learn_pattern produces a hash from the first parameter; and sub verify_pattern for the second parameter returns true or false. Now, this time we face a bulk of terms, therefore we have to &collect_alphabets: [1]

Perl weekly challenge 94

The two challenges this week were a nice introduction to the new year.

Challenge 1 - Group words into groups of anagrams.

This is a nice hash or "arrayref"s question - a Perl staple. For each group we need to generate a key, and put every anagram into this bin.

The simplest key is just to sort the letters into alphabetical order:

join q(), sort split m{}

This means the meat of the method can be written as a one liner.

sub group_anagrams {
  my $anagrams = {};
  push @{ $anagrams->{join q(),sort split m{}} }, $_ foreach @_;
  return $anagrams;
}

Challenge 2 - Flattening Trees & Linked Lists

Again with simple Tree and LinkedList classes this becomes a good
example of simple OO coding.

SanDiego.pm Meeting, Tuesday, January 12th, 2021

This is your friendly reminder that the SanDiego.pm quarterly meeting will be this Tuesday, January 12th, starting at 7 PM PST. As has been the case for the last several meetings, we'll be meeting again on Zoom (details below).

Topics for the meeting include Perl (of course), COVID-19, CentOS, and anything else that people would like to talk about.

Perl Weekly Challenge 94: Group Anagrams and Binary Tree to Linked List

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

Spoiler Alert: This weekly challenge deadline is due in a few of days (January 10, 2021). 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: Group Anagrams

You are given an array of strings @S.

Write a script to group Anagrams together in any random order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

Example 1:

Input: ("opt", "bat", "saw", "tab", "pot", "top", "was")
Output: [ ("bat", "tab"),
          ("saw", "was"),
          ("top", "pot", "opt") ]

Example 2:

Input: ("x")
Output: [ ("x") ]

ABC Mart

800px-ABCMART_Minamisomaharamachi_Shop.jpg

One thing which I like about Mojolicious is that they put all the functions and methods in alphabetical order. When you get used to that then go back to a module like Git::Raw::Repository with a large number of functions in apparently random order, it does seem like quite a smart move for the reader to use the alphabetical ordering.

Anyway I thought so, so I've been putting all the functions, methods, and other things in my modules into alphabetical order. I even started to write tests that they are all alphabetical, since I usually manage to slip up on these things.

Let us Have a Productive Year of 2021

pusheen.jpg

Bye, 2020

There are 28 entries on this blog in the Year 2020.

In February, I started to join "The Weekly Challenge"(PWC in short, as initially it was called "Perl Weekly Challenge" while the name "Perl6" hadn't been replaced by Raku). Then I slowly involved in the Perl community as a beginner.

At first, my codes were messy! I have forgotten from where I heard of Perl Best Practices(by Damian Conway; btw, I have to revisit it again), but have been trying to adopt some of its pieces of advice as many as possible. And then I read more codes and decided to maintain my code more modularized and structured; in addition, I have learnt to use the unit testing package in Perl (thanks to Perl Monks).

Annual Report - 2020

Lets wipe out the memory of 2020

Am I bitter about 2020?

No, not at all. I like to find happiness in every little things in life. It is an art that I am still learning. I am writing this as a part of my monthly routine sharing last month activities. However this is special as it also has overall annual report of the year 2020.

I am embarassed looking back what I had planned at the start of the year.

Do I have any plan for 2021?

No way, I am not going to repeat my mistake. For a change, I want to see how I deal with my life without any plan.

Perl weekly challenge 093

This is a Raku answer for the 093 Perl Weekly Challenge . This is also my first post.

Exercise 1

Using a similar approach than James Curtis-Smith , the solution looks at points with equal slope to see if they are in a straight line. Being less literate in Raku, using classes help me to organize coding ideas.

This exercise gives me the opportunity to work with the type BagHash. The highest value of the slopes stored in a BagHash gives the number of points in a straight line. Happily, the first example in Raku documentation is for a Class Point, an example reused in this solution.

First Perl Steering Council elected to replace Pumpking position

The most important Perl Governance poll yet has concluded. The position of Pumpking is no more, and is instead now held by a shared 3 person Steering Council, as defined in perlgov.pod: https://github.com/Perl/perl5/pull/18357/files

To quote RJBS:

Perl has two well-defined bodies involved in its governance: a core team of a few dozen and a steering council of three people. The core team sets the rules of Perl governance, votes on membership of the two groups, and delegates substantial decision making power to the steering council. The steering council has broad authority to make decisions about the development of the Perl language, the interpreter, and all other components, systems and processes that result in new releases of the language interpreter. Right now, the core team has 25 members, although this may change over time.

The new Perl Steering Council is now:

RJBS + Neil Bowers + Sawyer X

Thanks to all of them for stepping up and donating their efforts to the Perl community. :)

Further information on these matters can be found on the p5p mailing list and the public perl core mailing lists.

Perl dying? Well now I don't care

It is a bit of a long story how I got burned by bad perl internal politics.

For many years I wanted images in Pod. And many others wanted too. And of course, each time I raised this in lists and on facebook, an answer was, if you want it, go and write it yourself. I would tell that myself, the classic "patches are welcome". Until one day I said, well, now, why actually not, right? Especially that I do have experience in creating and actively using images in pod using various hacks, such as direct inclusion of html with images, and even writing a standalone POD viewer capable of showing said images.

The Twelve Days of Dancer, 2020 Edition

Need some joy this holiday season? Head over to the Dancer Advent Calendar for this year's Twelve Days of Dancer. With a little help from our friends, we've put together a 12-day mini advent calendar featuring some great software built in Dancer, some helpful tips and tricks, new features, and more.

Thanks for being such a great community, and for your continued support of Dancer! Wishing you the happiest of holiday seasons!

CromeDome (on behalf of the Dancer Core Developers)

Strawberryperl.com - https any time soon?

Throwing this one out to the wider community, if anyone can assist in adding https support to strawberryperl.com that'd be great, with browsers and corporate firewalls moving towards a stricter mode of operation. An existing issue is here, with some history for those interested. Thanks in advance.

Development community that we can see to development of Perl Part1 - C language specification creating group

The Perl core team seems to be looking for resources to help in language development.

Currently, it seems the material in python.

perlgov: the perl governance document

I feel that Perl and Python cultures are quite different.

It's also based on an improvised document in 2019 when the Python reader quit.

I can understand how envious we are when we see Python attracting users(although
I'm watching a lot of cheating at the same time).

On the other hand Perl has long been a conservative culture.

So, we can refer to the methods used by developers of languages, operating systems and tools that also have a conservative mindset.

The first thing I would like us to refer to is the method used by the group that creates C language specifications.

C language specification creating group

C89, C99, C11

Development of C language has continued some slowly, but functions that users think are lacking have been added.

Specially C99 is added good features I wanted.

It would be worthwhile to ask the C specification group how it was achieved.

I think it's less repulsive and less likely to fail if we adopt a method from a culture similar to Perl rather than a culture opposite to Perl.

Monthly Report - November

Welcome last month of the year 2020

Generally, I always look forward to festive month, December. But I don't expect it to be any different from other months, unfortunately.

With so much going on in my personal life, it is hard to focus on anything. One thing that I really miss these days are personal time. I am constantly working on it with the help of experts in the field. I try to look at the positive side of the life but I can't ignore the fact I am not giving 100% to my pet project The Weekly Challenge. Having said that I must thank the entire team for the support and encouragement in this difficult time. As of today, we entered into the 89th week. I can't wait to see when we get to the 100th week.

Perl Weekly Challenge 088

Despite the holiday week here in the U.S., I was able to tackle this week's Perl Weekly Challenge. I have to say that this week's challenge was the most satisfying for me as it allowed me to not only come up with a novel solution (for me!), but it also provided an opportunity for me to leverage two areas of Perl programming that have been a real challenge for me: recursion and references. The deadline to submit solutions for this challenge is fast approaching so if you haven't solved it yourself yet, you may want to come back to this post later.

Task 1

Task #1, "Array of Product", asks the following:

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:

Where is Rob?

Does anybody know Rob Seegel (aka RCS), the author/maintainer of Tk::MListbox?

I tried to contact the author by e-mail but didn't get any feedback so far.
I would like to adopt the module Tk::MListbox (and the other packages).

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.