Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on Aug. 14, 2022 at 23:59). 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: Damm Algorithm
You are given a positive number, $n.
Write a script to validate the given number against the included check digit.
I was just going to use a variation on last week's "Nybble Swap" task for this, but then I foolishly thought, "No, I've read Hacker's Delight I should twiddle bits!"
Okay, now that I told you about my first mistake, let me tell you, the bit twiddling was fun once it started working but I do have a little regret that it's straightforward bit-twiddling: I created a bit mask to pick out alternating bits, then just did the shifting and OR-ing you would expect to switch the even/odd bits. I can't help but wonder if there isn't some clever one-liner in Hacker's Delight. I can't claim to have remembered it even once though: I skimmed the book.
Some contents of the PerlMonks article are largely repeated here.
This piece of PerlMonks article is already 19-year-old, but it is
still valid. One of the good things of the article is that you need not
install new modules or programs if you are on a *nix system.
Prerequisites
One should have some knowledge on modules, packages and, not really necessary, object-oriented Perl ("Perl OO" in short).
I explain how to create your website using Giblog and Perl by live coding. Giblog is a Perl module to create web sites. If you see this movie, you can create your web site using Giblog and Perl(although you need some Linux knowledge).
Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on Aug. 7, 2022 at 23:59). 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: Permuted Multiples
Write a script to find the smallest positive integer x such that x, 2x, 3x, 4x, 5x and 6x are permuted multiples of each other.
For example, the integers 125874 and 251748 are permuted multiples of each other as
251784 = 2 x 125874
and also both have the same digits but in different order.
In which Raku solutions give shape to Perl solutions, and vice versa, and then Raku does what Raku does best.
Task 1: Swap Nibbles - basic and extended solutions in Raku and Perl.
Task 2: Sequence of symbols 123 without adjacent 1’s. Solutions in Raku and Perl, then a radically different approach that I would have never discovered in anything but Raku.
Hello everyone, I'm back after a year's absence, good to see everything is going as strong as ever. I have some extra time this weekend, so thought I'd try my hand at an answer again.
But, oh golly, looking back over my earlier posts on earlier problems was just painful--too many details! Going forward I'll just broad-brush things (and I mean it this time). If anyone has a question about details, then ask about them in the comments.
The swap nibbles problem is equivalent to a "swap hex-chars problem" and since we have the bigint module then any hex string can be represented by an integer. When a little investigation brought up that every bigint object has an as_hex() method, I found the restriction to positive integers less than 255 too restrictive: I decided to do them all! (Well, not quite all, since there are an infinite number of integers, but you know what I mean.)
As you all know, I have recently started taking part in the weekly challenge again. I have always complained about the lack of time doing things I always wanted to do. But then it doesn't stop me taking up new projects. I have to learn how to prioritize projects. May be one day, I will get there. Right now I am actively working on 2 new projects simultaneously. First is preparing the talk for the upcoming Raku Online Conference. It is going to be my personal journey to Raku. And the second is very close to my heart, working on my first book about Perl in association with Dave Cross.
Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on July 31, 2022 at 23:59). 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: Last Sunday
Write a script to list Last Sunday of every month in the given year.
For example, for year 2022, we should get the following:
One of the remarkable things about the
Date-Manip package is
its flexibility in the matter of input. If I mean "tomorrow noon," I do
not have to think of what today is, I simply specify "tomorrow noon," or
its equivalent in any of sixteen other languages.
One day, I thought: what about "tomorrow sunrise?" And thus was born
Date-ManipX-Almanac.
In principal, there can be support for any almanac event from any
astronomical body in the
Astro::Coord::ECI
ecosystem. In practice at least most of them are covered, though I have
not audited for 100% coverage. This includes the bodies in the
Astro-Coord-ECI-VSOP87D
distribution, should you want planets through Neptune. Pluto was not
covered by the VSOP models -- its exclusion is not a political
statement, at least not by me. Satellites are not supported, and
currently there are no plans for them.
a measurement of the risk resulting from information and capabilities not being shared among team members, derived from the phrase "in case they get hit by a bus."
For CPAN our definition is "a measurement of how risky it might be to start relying on a CPAN module, which might not be actively maintained".
Originally, the Perl Weekly Challenge called for solutions in Perl and Raku (also known as Perl 6 at the time). But, very soon, people started to provide solutions in other “guest” languages. See for example my blog post providing solutions to the task described below in about 18 different guest languages.
One of the languages I tried for the first time last week with Sylvester’s sequence is dc, and it turned out to be much more difficult and challenging than I initially thought. One of the problems is that there is only very limited documentation on this old programming language. So I thought it might be useful to describe in some details how I solved it. I provided detailed explanations in this other blog post. I’ll now do the same with the disarium number task of this week, which is a bit more complicated.
You have 46- hours to play with it if you align with official deadline. It probably spends you 2~5 hours in this weekend. Beware! Doing the bonus part may spend you a block of extra 2 hours or more.
I wish more people will participate and show different approaches to the task. (And, may the participant give me some feedback as a puzzle creator?)
One may have advantage if s/he has played chess.
As the puzzle creator, of course I had a sketch of a solution in my mind.
Yesterday I solved (== coded) the puzzle and is blogging about it this morning. [Spoiler Alert] If you are interested in my solution... source code , blogpost
Miscellaneous:
My blog is moved to GitHub, mainly because I think soon or later I will blog on other programming languages or issues. At this moment, it has a few posts. :o)
DBD::SQLite 1.67_07 (with SQLite 3.36.0) is a release candidate for the next stable DBD::SQLite. This release has a notable change to improve how to deal with Unicode/Latin-1 characters, contributed by Felipe Gasper. If you write a new application, it is recommended to use one of the newly added modes like this:
Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on July 24, 2022 at 23:59). 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: Disarium Numbers
Write a script to generate first 19 Disarium Numbers.
A disarium number is an integer where the sum of each digit raised to the power of its position in the number, is equal to the number.
For example,
518 is a disarium number as (5 ** 1) + (1 ** 2) + (8 ** 3) => 5 + 1 + 512 => 518
I thought I’d try out Tau Station for a couple of days and get a quick blog post out of it. That was three months and 11 levels ago. It took 2 months to wind down my obsessive nature and if not for Tau, I could have pushed a couple of new module versions to CPAN by now. That’s rather the reason that I don’t play games in the first place, so I can’t give great comparisons.
To sum up, Tau Station is a web-based, second-person adventure with resource management in real-time: a Choose-your-own-Adventure book crossed with Freeciv. Oh, and it’s free. Well, freemium, but the least obtrusive freemium game I’ve ever seen.