Perl Weekly Challenge 43: Olympic Rings and Self-Descripting Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (January 19, 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.

Challenge # 1: Olympic Rings

There are 5 rings in the Olympic Logo as shown below. They are color coded as in Blue, Black, Red, Yellow and Green.

olympic_rings-1.jpg

We have allocated some numbers to these rings as below: Blue: 8 Yellow: 7 Green: 5 Red: 9

The Black ring is empty currently. You are given the numbers 1, 2, 3, 4 and 6. Write a script to place these numbers in the rings so that the sum of numbers in each ring is exactly 11.

Asking for Rakudo.js grant feedback

Work on the Rakudo.js grant has been completed and now I'm add the stage where community feedback is needed. It would be super grateful for Your feedback. You can provide it in blog comments on this post.
The final grant status update is available HERE

Monthly Report - November

November was the quietest month for me. I would give credit to the book Why We Sleep, gifted by Neil Bowers. I haven't finished reading the book yet but whatever I read so far made a big difference. A very big THANK YOU to Neil. I no longer do late nights, technically that means no work after midnight for me. However I do wake up early on weekends and finish the pending work. One more change, I noticed that I don't visit MetaCPAN very often. Earlier I used to checkout every 30 minutes during the day. But now I do it once every couple of days. Having done 160 Pull Requests in October, then doing only 51 Pull Requests in November feels so light. In fact I reached my monthly target of 50+ Pull Requests in the third week of November. Last one week was relaxing, I made conscious efforts not to look for Pull Request.

Paws XXXII (80+ paws)

Today's post proves that test suite, even one that uses canned data, requests and responses, is a very valuable asset to have about.

As I was charging though some 80 action calls copying the requests from my successful unit tests into my t/09_request.t test cases I ran into the odd real bug.

The first one I ran into was to do with the 'PutBucketLogging' action; My real unit test case would work with no problem but as I transferred this real world unit test into canned test cases I got a fail on some of the composed XML.

The test parameters for the request where

Perl Weekly Challenge 42: Octal Numbers and Balanced Parentheses

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (January 12, 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.

Challenge # 1: Octal Number System

Write a script to print decimal number 0 to 50 in Octal Number System.

For example:

Decimal 0 = Octal 0
Decimal 1 = Octal 1
Decimal 2 = Octal 2
[ ... ]

For this task, I’ll start with Raku, because it is so easy in Raku.

Octal Number System in Raku

Raku has a base method to convert a number into a string representation in any base between 2 and 36.

By Any k-Means Necessary

You want to get to know your data, questions like, can they be broken down into a simple set of classes. You don't know what these classes might be, so your task is clustering and you reach for one of the oldest clustering algorithms around k-means.

k-means is popular because it's simple to understand, converges fast, works in higher dimensions and gives you an answer. It's also usually the wrong choice unless you've already got nicely clustered data just waiting for you to guess k, the most appropriate number of clusters to answer your question. But it is a decent warm up exercise in becoming friends with your data set.

Giblog 1.1 Released - Github Project pages support

Good news!

Giblog 1.1 is released! Giblog is the web site and blog builder for git . It generate static HTML files. You can mange Web site using git.

In this release, Github Project pages are supported.

Deploy website on Github Project page

See the URL "https://yuki-kimoto.github.io/giblog-theme1-public/". This is really Github Project pages.

Config file is the following. "base_path" option is set.

use strict;
use warnings;
use utf8;

{
  site_title => 'mysite😄',
  site_url => 'https://yuki-kimoto.github.io',
  base_path => '/giblog-theme1-public',
}

This site resource repository is

giblog-theme1

This site public repository is

giblog-theme1-public

If you know more, see the Giblog site(Currenty only Japanese).

Paws XXXI (Digging up more dirt)

I ending up in my last post with a test that was running but most of the tests where failing.

ok 1 - Call S3->CreateBucket from /home/scolesj/aws-sdk-perl/t/09_requests/s3-create-bucket.request
ok 2 - Got content eq from result
…
ok 11 - Got method eq PUT from result
I had a look at the request object I was getting back

Perl Weekly Challenge 41: Attractive Numbers and Leonardo Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (January 5, 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.

Challenge # 1: Attractive Numbers

Write a script to display attractive number between 1 and 50.

A number is an attractive number if the number of its prime factors is also prime number.

The number 20 is an attractive number, whose prime factors are 2, 2 and 5. The total prime factors is 3 which is also a prime number.

First comment: we’re obviously interested only with proper prime factors, i.e. prime factors of a number other than 1 and the number itself.

Perl 5 development has moved to Github

I didn't notice much public discussion, but in the last month, Perl 5 development has moved to Github. The logistics of the move were mostly handled by Todd Rinaldo although I'm sure there were other people helping.

The change involved moving the main development repository from perl5.git.perl.org to https://github.com/Perl/perl5, moving the issues from rt.perl.org to Github issues, renaming them in the process, and fixing the code that used the hostnames or URLs for decisions.

Bundling With Platypus

If you've heard of FFI::Platypus you probably know that you can use it to easily write Perl bindings for existing system libraries:

use FFI::Platypus 1.00;
use FFI::CheckLib qw( find_lib_or_die );
my $ffi = FFI::Platypus->new( api => 1 );
# uses the system libarchive
$ffi->lib( find_lib_or_die( lib => 'archive' ) );

You may even know that Platypus integrates nicely with Alien for seamless installation experience, even if the library isn't already installed:

use FFI::Platypus 1.00;
use Alien::Libarchive3;
my $ffi = FFI::Platypus->new( api => 1 );
$ffi->lib( Alien::Libarchive3->dynamic_libs );

Paws XXX (Three of a kind)

Goodness Paws 30 and I am at least code compete as far as running through all of the different action found on S3. Now that leads me to a very important part.

I now have to do a little bit of back peddling and come up with a test suite for all the now fixed S3 actions. 90% of the bugs and fixes I have done so far on S3 have been for requests to the server not checking responses form the server.

Following on with this it makes sense that I test how things are sent to the server as well. I had a peek about in the test suite and except for a few of the basic actions there are no tests on request calls.

Perl Weekly Challenge # 39: Guest House and Reverse Polish Notation

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (December 22, 2019). 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: Guest House

A guest house had a policy that the light remain ON as long as the at least one guest is in the house. There is guest book which tracks all guest in/out time. Write a script to find out how long in minutes the light were ON.

The guest book looks as follows:

New Perl project. Interactive Perl coding tasks to run in the browser

Some time ago I have created a small web project about Perl programming language. The site where you can execute Perl code online — PerlBanjo.com. (blog post about the release)

Today I'm happy to announce the new small project about Perl. This is the place with interactive coding tasks. You solve the task, enter the solution, system run it and tell you if it accept your submission. (PerlBanjo.com is used as a backend to run Perl code)

This is the link:

https://SquarePerl.com/en/problems

Now there are only several tasks. The source code for all the all tasks is hosted on GitHub, so anybody can propose a fix for the task or create the new task.

I start to write Mojolicious Startup

I start to write Mojolicious Startup. This is Japanese. Please use google translation.

Mojolicious Startup

#TPCiH to be @ Hilton Houston North Jun 23-27, 2020

The Hilton Houston North has been selected as the #TPCiH venue! #savethdates June 23-27, 2020. The 3-day tech conference goes from Wednesday, June 24 through Friday, June 26. Master-class tutorial sessions will be offered Tuesday, June 23 and Saturday, June 27 #perlcon #rakulang

Perl Weekly Challenge 38: Date Finder and Word Game

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

Challenge # 1: Date Finder

Create a script to accept a 7 digits number, where the first number can only be 1 or 2. The second and third digits can be anything 0-9. The fourth and fifth digits corresponds to the month i.e. 01,02,03…,11,12. And the last 2 digits represents the days in the month i.e. 01,02,03….29,30,31. Your script should validate if the given number is valid as per the rule and then convert into human readable format date.

Rules:

1) If 1st digit is 1, then prepend 20 otherwise 19 to the 2nd and 3rd digits to make it 4-digits year.

2) The 4th and 5th digits together should be a valid month.

3) The 6th and 7th digits together should be a valid day for the above month.

For example, the given number is 2230120, it should print 1923-01-20.

Feedback sought

I've been trying to update the docs for Type::Tiny and want feedback. Is there anything that's hard to understand, or needs explaining more?

In particular, it's Type::Tiny::Manual and the other pod pages in that namespace that I'm working on.

Rewriting Legacy Code in Raku

I'm already working on Part II, but here's Part I in all its glory: http://www.theperlfisher.com/index.php/2019/11/24/rewriting-legacy-code-for-raku/ - I'm writing OLE::Storage_Lite from the original Perl 5 source, and this article series is my thoughts on the process so far.

Perl Weekly Challenge 035: Binary Morse Code

The Encoder

Write a program to encode text into binary encoded Morse code.

Before we can encode Morse code into its binary representation, we need to encode normal text into Morse code. As a former Woodcraft member, I was able to write the following lines by heart:

my %to_morse = qw( a .-   b -... c -.-. d -..  e .    f ..-. g --.
                   h .... i ..   j .--- k -.-  l .-.. m --   n -.
                   o ---  p .--. q --.- r .-.  s ...  t -    u ..-
                   v ...- w .--  x -..- y -.-- z --.. );

The encoding subroutine is straightforward: split each word into separate characters, then replace each with the value from the above hash.

sub encode_to_morse {
    join '/', map $to_morse{$_} // "", split //, shift
}

Note that space is not present in the translation table, so it gets translated to an empty string, which creates the expected double slashes between words.

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.