Perl Weekly Challenge 127: Disjoint Sets and Conflict Intervals

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

Task 1: Disjoint Sets

You are given two sets with unique integers.

Write a script to figure out if they are disjoint.

The two sets are disjoint if they don’t have any common members.

Example:

Input: @S1 = (1, 2, 5, 3, 4)
       @S2 = (4, 6, 7, 8, 9)
Output: 0 as the given two sets have common member 4.

Input: @S1 = (1, 3, 5, 7, 9)
       @S2 = (0, 2, 4, 6, 8)
Output: 1 as the given two sets do not have common member.

Disjoint Sets in Raku

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.

Perl Weekly Challenge 126: Count Numbers and Minesweeper Game

These are some answers to the Week 126 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 August 22, 2021 at 24:00). 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 integer $N.

Write a script to print count of numbers from 1 to $N that don’t contain digit 1.

Example

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.

Monthly Report - August

Time for another monthly report? Time just flies.

It was the most busiest month of the year 2020 for me. Of course, most of my spare time was dedicated to The Weekly Challenge. We, as a team, created record of 100+ contributions 4 weeks in a row. It was hectic and exhausting, I must admit.

With every passing week, the team is also growing. Team members are blogging more often. As of today, we have received 3000+ Perl contributions and 2000+ Raku contributions. For blogs, very soon we would cross 1000 mark, currently it stands at 940. Did I expect such response in the beginning? No, never dream of such support.

Encouraged by Gabor Szabo, I created my Patreon profile for the first time. I am overwhelmed by the support I have received so far. I would like to take this opportunitity to thank each and every supporters.

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.

Perl Weekly Challenge 125: Pythagorean Triples

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

Task 1: Pythagorean Triples

You are given a positive integer $N.

Write a script to print all Pythagorean Triples containing $N as a member. Print -1 if it can’t be a member of any.

Triples with the same set of elements are considered the same, i.e. if your script has already printed (3, 4, 5), (4, 3, 5) should not be printed.

The famous Pythagorean theorem states that in a right angle triangle, the length of the two shorter sides and the length of the longest side are related by a²+b² = c².

A Pythagorean triple refers to the triple of three integers whose lengths can compose a right-angled triangle.

Example:

How and What to do in Programming (CY's Take on PWC#075 Task 2) [Edited]

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

---

Continued from the discussion of Task 1.

Task 2 Largest Rectangle Histogram

I am not a narcissist; though some of my actions are narcissistic traits, it does not imply that there is yet another narcissist; I am motivating myself for a better self.

Back to the task. This look like a task testing our overall commanding of the language (especially when the bonus is also considered), not an algorithm-oriented task.

At the first sight, looking for the largest rectangle seems uneasy. My order of coding has been: Perl code, Python code, Java code (3 at a time because I got a day-off on Tuesday) and (after a few days) Lisp code. The following is my note during coding the Perl of the task, informally:

Week #075: Coins Sum & Largest Rectangle Histogram

Please follow the blog where I discuss the two tasks "Coins Sum" and "Largest Rectangle Histogram" of "The Weekly Challenge - 075".

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

Thoughts on Marshalling and Unmarshalling in Zydeco

Prompted by a recent question on PerlMonks, I've been thinking a bit recently on marshalling and unmarshalling Perl objects. If you're happy using Data::Dumper's format, then it's trivial, but today we're looking at JSON.

If you just want to encode your objects as JSON, that's very easy. Just add a TO_JSON method to all your classes. This can be done in a role to eliminate duplication, and in most cases can be as simple as:

The difficulty comes in going the other direction.

Perl Weekly Challenge 124: Happy Women Day and Tug of War

These are some answers to the Week 124 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 August 8, 2021 at 24:00). 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: Happy Women Day

Write a script to print the Venus Symbol, international gender symbol for women. Please feel free to use any character.

Example:

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)

Self Challenge and Weekly Challenge (CY's Take on #074 Task 1)

board-game-challenge.jpg

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

Thanks for the volunteers, there are code Reviews on Perl/Raku; in addition, on each Monday, you can read the RECAP linking others' solutions and blogs; I often learn something from both RECAP and Perl Review.

---

One week to the end of August!

Alan J. Perlis said, “A language that doesn’t affect the way you think about programming, is not worth knowing.

I would add a clause to it: unless it helps you earn your living...


Self Challenge

Making risky/improbable promises are usually looked down in Hong Kong, though some people do support the venturesome spirit (not quite for females, but – personal feelings). “Jump-in, jump-out” is not welcomed, as for my understanding to Hongkongers. (I actually stay on Internet more than in Hong Kong society.)

BLOG: The Weekly Challenge #074

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

Perl Weekly Challenge 123: Ugly Numbers and Square Points

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

Spoiler Alert: This weekly challenge deadline is due on August 1, 2021 at 24:00. 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: Ugly Numbers

You are given an integer $n >= 1.

Write a script to find the $nth element of Ugly Numbers.

Ugly numbers are those number whose prime factors are 2, 3 or 5. For example, the first 10 Ugly Numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12.

Example

Input: $n = 7
Output: 8

Input: $n = 10
Output: 12

Ugly Numbers in Raku

TPF Survey: Marketing and Branding

As announced on TPF news the Marketing committee of TPF have been running a survey "to learn your responses to the ideas about branding, naming and the perceptions of the values concerning the Perl Foundation itself."

This survey will close in just a few hours, so if you have yet to give your feedback please do so asap!

P.s. Please join the more than 4,000 members of "Perl Programmers" on Facebook

Time Challenge (CY's Take on PWC#075 Task 1)

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

Thanks for the volunteers, there are code Reviews on Perl/Raku; in addition, on each Monday, you can read the RECAP linking others' solutions and blogs; I often learn something from both RECAP and Perl Review.

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

---

While the weekly challenge is fighting towards new record of number of submissions, I am starting my own programming adventure. Congratulations to CY Fung, she knows how to code in Python and Java now. I am going to submit guest solutions in these two languages for the coming challenges.

Task 1 Coins Sum

BLOG: The Weekly Challenge #073

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

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.