Pizza Party for 100

Hi all, this is my first blog post! Yay!

Now that that's out of the way, I'd just like to go over my solution for this week's Perl weekly challenge.

The first challenge was to divide a pie between 100 people, in a manner where the first guest gets 1/100 (i.e. 1%) of the pie, and the second gets 2/100 (i.e. 2%) of what remained, etc etc. The question is, who got the biggest piece of pie.

If I were better at math, I would prove that the answer is the square root of the amount of guests, because that does seem to be the case. Since I'm not, I solved it procedurally, as follows.

We set up our guests. We allow for the user to pass in a value on the command line, to check values other than 100, but default to 100:

use v5.22; #that's my perl
my $guests = shift // 100;

Perl Weekly Challenge # 16: Bitcoin Addresses

In this post dated July 8, I provided solutions to the first challenge of Week 16 of the Perl Weekly Challenge organized by Mohammad S. Anwar. At the time, I admitted that I was having trouble understanding the requirement for the second challenge. After quite a bit of googling, I can finally provide some answers to the second challenge of Week 16.

I should acknowledge that I spent far more time on this than I would wish to admit. Far more time than I ever did on any of the previous challenges.

Validation of Bitcoin Addresses

Perl Weekly Challenge #016

Task #1: Pythagoras Pie Puzzle

This puzzle’s connection with Pythagoras is tenuous indeed: it originally appeared in the Dutch magazine Pythagoras (see here and here)! But the puzzle is interesting. Of course, the real challenge is to work out the answer mathematically, but for those of us who are mathematically declined a Perl script is the way to go.

The first draft of my solution was tied to the 100 guests specified in the puzzle statement, but it’s easy to extend the puzzle to allow any (positive integer) number of guests. So I include the number of guests as a constant $GUESTS and the central calculation becomes:


$piece = ($guest / $GUESTS) * $pie;

where $guest is any number in the series 1 .. $GUESTS and $pie is the fraction of original pie remaining at this point in the distribution.

Perl 5 solution

For my own interest I added code to display the size of each guest’s piece of pie. This code can be omitted from compilation by setting DEBUG to a false value.

File ch-1.pl

RPerl at the Perl Conference in Pittsburgh - Day 3

Howdy!

We're back for the final day of the Perl Conference. Wendy and Liz were very much missed this year, but we had enough Perl items to set up a booth, with the help of Ruth Holloway and Peter Sargent. The table was full of buttons, stickers, tuits, and other info from Perl Careers.

On this final day we attended the traditional Q&A with Larry Wall. People were able to send their questions via Twitter, and I asked Larry who his favorite musical composer is.
I'm not a technical person, but I am a violinist, which gives me something in common with Larry Wall! Pretty cool, right? Anyway, Larry's answer was Gustav Mahler. Very good answer Larry, I myself am a Mahler enthusiast. What I remember from this Q&A session is Larry's call for peace and respect. The Perl community has a lot of great people, very different from one another. The things we have in common should always surpass our differences.

Next stable DBD::SQLite will be released in the mid-August

DBD::SQLite 1.63_05 (with SQLite 3.29.0) is a release candidate for the next stable DBD::SQLite. There are no big changes, maybe except for two new db_config options to disallow double-quoted string literals.


  use DBD::SQLite::Constants qw/:database_connection_configuration_options/;

  $dbh->sqlite_db_config( SQLITE_DBCONFIG_DQS_DML, 1 );
  $dbh->do('INSERT INTO foo VALUES (1, "text")'); # Now this is an error


I'll wait for about a month as always, and release 1.64 in the middle of August (that means, after PerlCon) if there's no blocker nor request to wait for more. Thank you for your patience.

Infinite work is less work


The first task of last week's Weekly Challenge was to print the
first ten strong and weak primes. A prime pn is "strong" if it's larger
than the average of its two neighbouring primes (i.e. pn > (pn-1+pn+1)/2).
A prime is "weak" if it's smaller than the average of its two neighbours.

Of course, this challenge would be trivial if we happened to have a list
of all the prime numbers. Then we'd just filter out the first ten that
are strong, and the first ten that are weak. In fact, it would be even
easier if we happened to have a list of all the strong primes, and a
list of all the weak ones. Then we'd just print the first ten of each.

But there are an infinite number of primes and of weak primes (and
possibly of strong primes too, though that's still only conjectured)
,
so building a complete list of the various subspecies of primes
is impractical in most programming languages.

Meet The Champion - Joelle Maslak

As a part of weekly series "Meet The Champion", we are talking to the last week winner Joelle Maslak.

# Perl Weekly Challenge # 16: Pythagoras Pie

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

Spoiler Alert: This weekly challenge deadline is due in several days from now (July 14, 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.

Challenge # 1: Pythagoras Pie

At a party a pie is to be shared by 100 guest. The first guest gets 1% of the pie, the second guest gets 2% of the remaining pie, the third gets 3% of the remaining pie, the fourth gets 4% and so on. * Write a script that figures out which guest gets the largest piece of pie. (Challenge proposed by Jo Christian Oterhals)*

RPerl at the Perl Conference in Pittsburgh - Day 2

Day 2 of the Perl Conference, and I am now a seasoned volunteer! I know all about HDMI recorders and cameras - well, almost…

This second day saw the very first meeting of the Perl Mongeresses, a Birds-Of-a-Feather for women in the Perl community. This year’s Perl Conference was notable for the highest known attendance of women to The Perl Conference ever! By highest, I mean… about 15 ladies total. Yes, there’s still work to do. This meeting was the opportunity to discuss issues that women are facing in the programming world.

Thank you, Ruth Holloway, for the Perl Mongeress initiative! I’m looking forward to the second edition next year. If some of my female readers plan to attend the PerlCon in Riga next month, you still have time to add one to the BoFs...

Leaving irc.perl.org

This article just popped up on Twitter. Whilst I mostly idle on irc.perl.org (say hello in #australia) I have no idea who runs or ran it. Whilst I noticed that there seems to be several servers (at lease one of which being apparently provided by shadowcat systems). I had assumed this was largely just people keen to run their own local instance - irc serving not requiring much in terms of system resources.

I guess my reaction to the article is to feel some contribution to the "use but not contribute", although i'm not even an admin in a channel. IRC across the board is waning in the face of CPU and RAM hungry chat softwares.

It seems that if you can make chat software that requires you to upgrade your CPU and RAM you've got yourself a hot start up, even if you're largely replicating features available in irc and email lists.

With other efforts to reinvigorate this blog site, and other key perl websites, perhaps its time to include IRC (or others) in a strategic plan?

Perl Weekly Challenge - Meet The Champion

We have started weekly series "Meet The Champion" where we would speak to the winner of the "Perl Weekly Challenge". So far we have had two winners. Please checkout the interviews with the champions.

Please let us know if we missed anything.

Functional Programming in Perl: Strong and Weak Primes (Perl Weekly Challenge)

In this other blog post, I provided some answers to Week 15 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Here, I want to use the opportunity of this challenge to illustrate once more some possibilities of functional programming in Perl (both Perl 5 and Perl 6) using the example of the first challenge of this week. I have already covered some aspects of functional programming in Perl in a post related to Weekly Challenge 9.

Draw a hexagon and fill it with color using Imager

Draw a hexagon and fill it with color using Imager

Source code.

Seamless Proxy Auto-Config for CLI apps

Suppose you are in a corporate network environment and often times find yourself manually setting/unsetting the HTTP_PROXY environment variable in order to access different hosts (for instance, "yay proxy" for the external hosts and "nay proxy" for the internal ones). Sounds familiar? In this case, a pure-Perl tool I've written might help you :)

Perl Weekly Challenge 015: Strong and Weak Primes, and Vigenère Cipher

Strong and Weak Primes

Write a script to generate first 10 strong and weak prime numbers.

The two sets of primes are defined with the following formulas:

  • p(n) is Strong when p(n) > [ p(n-1) + p(n+1) ] / 2
  • p(n) is Weak when p(n) < [ p(n-1) + p(n+1) ] / 2

It took me some time to realise there is a third set of primes which isn’t mentioned in the above list: there are also Balanced primes. The comparison operator for them is =.

To generate primes, I reused the (slightly modified) module I created for the Challenge 012. It caches the primes found so far and extends their list when needed.

Perl Weekly Challenge # 15: Strong and Weak Primes and Vigenère Encryption

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

Spoiler Alert: This weekly challenge deadline is due in several days from now (July 7, 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.

Challenge # 1: Strong and Weak Prime Numbers

Write a script to generate first 10 strong and weak prime numbers.

Draw sin curve using Imager

Write sin curve using Imager.

Chart::GGPlot author say to me "It is hard to use graphic basic library for me".

so I want to illustrate basic drawing.

Cairo seems to be good as features but portability is not good.

so I try to plot sin curve by Imager.

Curve is continue of very short lines.

I wrote a graph of sin.

Performance is very fast. Generation of graph is in a second.

Monthly Report - June

Last month I was mostly involved with the "Perl Weekly Challenge". I didn't get any spare time to do anything else. Weekends were mostly busy with preparing weekly challenge. Then recap of every Perl5 solutions of previous week. It becomes even busier when I am working on Perl Weekly newsletter in that week. As the team growing, it is not going to be any easier. Luckily I have got help from Kian-Meng Ang who does the Perl5 code review every week.

We also started picking winner every week with the start of "Perl Weekly Challenge - 013" last month. We have had 2 winners so far, Laurent Rosenfeld and Jaldhar H. Vyas.

Let's take a quick look through last month main activities.

  • Pull Request
  • Git Commits
  • Perl Weekly Challenge
  • Pull Request Club
  • Perl Blog
  • PerlWeekly Newsletter
  • Adopt CPAN Module

Pull Request

53 Pull Requests submitted in the month of June. With this I have now completed 50+ Pull Request every month so far in the year 2019, one of my new year resolutions.

As simple as possible...but no simpler

The first task of last week's Weekly Challenge
was to generate van Eck's sequence:

0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0,...

The first challenge is to understand just what van Eck's sequence is,
as the various online explanations are less than instantly helpful.

Van Eck's sequence is a list of integers starting at zero, where the next number
in the sequence is given by the distance between the current number
and the nearest preceding occurrence of that same number.

For example, if the current number at index N (let's call it: Aₙ) is 7,
then to compute the number at index N+1 we look back through the
sequence for the most recent preceding occurrence of 7
(at some earlier index M). Then the next number in the sequence
is simply the distance between those two occurrences of 7.
Namely: N - M

SUSE Hackweek Day 4 - Fighting with XS and C

On thursday evening and friday of the Hackweek I decided to work on the integration of YAML::PP and libyaml.

Previous hackweek posts:

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.