Spoiler Alert: This weekly challenge deadline is due in a few days from now (on September 19, 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: Odd Number
You are given an array of positive integers, such that all the numbers appear even number of times except one number.
Write a script to find that integer.
Example 1:
Input: @N = (2, 5, 4, 4, 5, 5, 2)
Output: 5 as it appears 3 times in the array where as all other numbers 2 and 4 appears exactly twice.
Today I released Zydeco::Lite, a re-implementation of Zydeco but just using standard Perl syntax. So for example, class { ... } becomes class(sub { ...});.
This has the advantage of much faster compile time, similar run time speed, fewer dependencies, and compatibility with older versions of Perl before the keyword API was introduced. Of course, in some circumstances these aren't important concerns, so the nicer syntax of the full Zydeco will be preferred.
Zydeco and Zydeco::Lite are both based on MooX::Press which itself is based on Moo, Type::Tiny, and other modules. I've taken the synopsis example from the Zydeco documentation and rewritten it using the different layers of abstraction.
"This release includes numerous bug fixes for some issues that have been around for some time. PulledPork v0.7.4 has been tested with Snort 2.16.1 and Snort 3.0.1."
"Add missing Raku_or_Prolog() subroutine; new languages and file types LLVM IR, Logos, Meson, Mojo, Odin, Jinja Templates, WXML, WXSS; support MATLAB block comments; minor bug fixes."
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).
I found that I gained unnecessary promotion due to being in a GMT+8.00 timezone - my blogpost appears on the top of https://blogs.perl.org for longer hours.
---
Task 1 Fibonacci Sum
Another dish for math geek!
Really??
Coding Process
I spent a whole day on the Perl script on Fib Sum task. I worked on
it until night. Then I have a rest. In the morning next day, finally I
gave up a subroutine for cases like "7, 5, 3" => "6, 5, 4, 3, 2, 1" or "11, 9" => "10, 9, 8, 7".
The hard time made me recall what I learnt after Challenge #055 Task 2
Wave Array, using a hash to remove any duplicates occurred -- instead of
crazy handling of exception cases again and again.
So I like to keep local copies of my blogs.perl.org blog posts as Atom entries, but noticed yesterday that I had a few gaps in my collection. The Atom feeds offered by blogs.perl.org only have the most recent articles though, so I decided to write a quick script to scrape the posts. Luckily, I managed to get a table containing the URLs for each post I needed, so I didn't need to bother with following links to find the pages; I just needed to grab the content from them.
I thought some people might find the code interesting especially for its use of lazy attributes. This is one of those "it only needs to be used once, so making the code maintainable isn't important" kinds of projects, do bear that in mind. I've cleaned up the whitespace and added comments for this blog post, but other than that, it's just a quickly hacked together script.
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.
it would be nice to see more than ten perl lovers to join the fun, which will also permit to be seen in the loop back stats, unlike the previous contest.
i would like also to highlight:
the community developed an extension to write code locally.
the community can write contests from easy to expert: see Bender 1, 2, 3, against 4 ; or Pikaptcha 1, 2, 3, 4.
the admins will accept to upgrade to perl 7 when time has come, but, i guess, the level of priority will depend on the number of people asking for it.
As a programmer whose first job was in the mortgage software industry, “TIL” has always meant “Truth In Lending” to me: you know, that document that the bank is required to give you when you get a mortgage, that’s supposed to explain how much you’re really paying after all the bank’s hidden finance charges, except the numbers don’t seem to make any sense so you just sign it anyway and don’t know anything more than you did before? Yeah, that one.
Of course, nowadays it means something else, and I’ve had to redirect my ossified mental patterns into new channels, so that, now when I see “TIL,” I can have my brain recognize it as “Today I Learned.” Which is a handy phrase: it encapsulates feelings of discovery, serendipity, and epiphany all into one. And TIL1 that the way I’ve always tried to write code has a name, a history, and a venerable progenitor—most of my life, without even realizing it, I’ve been trying to use literate programming (only without the tangling).
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.
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.
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.
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.
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.
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.
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.