I spent quite a lot of time trying to work out what this error message meant:
Error: Unterminated '#if/#ifdef/#ifndef' in Libpng.xs, line 1328
The first problem here is that line 1328 is the end of the file, so that wasn't a big help.
After spending a lot of time counting #if and #endif statements in the file over and over again, in the end I had the bright idea of looking at the actual XS output, and managed to find the problem. Apologies for quoting it in full here but I can't think of a good way to truncate it:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on December 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: Calculator
You are given a string, $s, containing mathematical expression.
Write a script to print the result of the mathematical expression. To keep it simple, please only accept+ - * ().
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).
After the long-haul Sudoku Task, this week we come to meet two tiny tasks.
Task 1 Longest Consecutive Sequence
It seems unavoidable for me that we have to sort the input first:
sub long_consec{ my @list = sort {$a<=>$b} @_; #...
Then I use a for loop and a temporary list variable @potential_max_opp
my $max_len = 1; my @max_opp;
my @potential_max_opp = ($list[0]); for (1..$#list) { if ($list[$_-1] == $list[$_]-1) {
push @potential_max_opp, $list[$_];
} else
{ if (scalar @potential_max_opp > $max_len) {
$max_len = scalar @potential_max_opp;
@max_opp = @potential_max_opp;
}
@potential_max_opp = ($list[$_]);
}
}
return \@max_opp;
}
Pretty straight-forward.
Some ideas: There should be some more efficient algorithms, maybe similar to counting sort , if the range of integers is given and the integers are "dense" enough.
For a long time (since 2012), REST::Neo4p has provided a way for Perlers to play, and even work, with the graph database Neo4j.
Neo4j has made many changes and improvements in its server and its query language in that time. However, as it has become successful commercially, it has made breaking API changes of one kind or another more and more regularly. In the last major release, version 4.0, Neo4j retired the REST endpoint on which REST::Neo4p was based. This endpoint was "entity-based", as it were, allowing direct access to nodes, relationships, and the like via entity IDs. It was well suited to the object (HAR HAR) of REST::Neo4p. But Neo4j decided to focus exclusively on its declarative query language Cypher, and to move away from the "graph walking" paradigm that the REST endpoint represented.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on December 12, 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: Divisor Last Digit
You are given positive integers, $m and $n.
Write a script to find total count of divisors of $m having last digit $n.
Example 1:
Input: $m = 24, $n = 2
Output: 2
The divisors of 24 are 1, 2, 3, 4, 6, 8 and 12.
There are only 2 divisors having last digit 2 are 2 and 12.
# (I will write more some hours later. This may not be a good practice. But) #HKT November 15, 2020 3:32 PM
I am excited by the Sudoku task and eager to share.
If you want to challenge yourself on programming, especially on Perl and/or Raku, go to https://perlweeklychallenge.org, code the latest challenge - Challenge 086, submit codes on-time (by GitHub or email).
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on December 5, 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: Number Divisors
Write a script to find lowest 10 positive integers having exactly 8 divisors.
Example:
24 is the first such number having exactly 8 divisors.
1, 2, 3, 4, 6, 8, 12 and 24.
This is quite straight forward. We can look at consecutive integers, count their factors, and stop when we reach ten integers having 8 divisors.
Like any well-entrenched programming language, Perl has a rich history and a number of personalities who shape and lead its community. In addition to wanting to learn its syntax and how to write simple scripts with it, I'm also trying to learn more about that history and the people who influence it today. I do this by following some blogs (which perhaps I'll write about later) and reading online books and articles but the best way for me is to listen to relevant podcasts. I'm an avid podcast listener and love learning about new concepts or technologies while walking the dog, doing the dishes, or pre-pandemic, sitting in traffic. Over the past few weeks, I've been listening to some contemporary as well as not so recent Perl-related podcasts and thought I'd share some select episodes that others may find interesting:
Dave Cross already suggested to use other forums for Perl-related posts, especially pointing to dev.to where our posts can be more visible to the outside world than here on bpo.
I followed his advice and started to post there too. I even volunteered to become a moderator of the #perl tag on dev.to.
So I'd like to invite you to follow that tag and to post articles there using the #perl tag and other tags that might be relevant to your posts.
Ed J has taken over maintenance of my suite of GraphViz2 modules.
The first change has been to split it into multiple distros, so that
anyone using just GraphViz2 will have a much smaller download and only
6 pre-reqs.
Another change is to rework the decision, which I copied from the
original www.graphviz.org, and which meant nodes and port names were
joined with a colon. For e.g. MS Windows users wanting to represent disk
names like C:, this is clearly problematic.
There is a new option combine_node_and_port, which defaults to true but
in May 2021 or so will switch to defaulting to false. When true, the
current problematic behaviour occurs. When false, more DWIM-ish
behaviour happens:
The latest installment of the Perl Weekly Challenge just dropped so I thought I would take a crack at it. Please note that the challenge is still currently open (as of date of publishing) in case you are participating.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on November 28, 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: Add Binary
You are given two decimal-coded binary numbers, $a and $b.
Write a script to simulate the addition of the given binary numbers.
The script should simulate something like $a + $b. (operator overloading)
The other day I wanted to send my friend some silly emojis on LINE and so I updated my flaky old Unicode browser to the new-fangled Unicode with values above 0x10000, so that I could fetch the Emojis, which start around here. The thing also features a perl script which fetches values from Unicode::UCD using the charinfo function. I also updated to Perl 5.32 around the same time. Now the funny thing was that I started getting all kinds of errors about invalid JSON in the browser console. My Perl script was sending something of the form {... "script":Common ...} from my module JSON::Create, which is not valid JSON due to not having quotes around Common, and obviously my module was faulty.
I don't usually take part in the Perl Weekly Challenge but one of this week's challenges caught my eye. I thought it could be a fun thing to attempt and decided to use Zydeco to help solve it.
The problem is that you're given a matrix of 0s and 1s:
You need to find any squares (equal length sides) where all four corners are 1s: