Serial Boxing

Wherein we record for posterity the passage of time, without which everything would be in critical danger of happening at once…


“If I were to become a serial glitter-bomber, it would seriously impact my ability to get close enough to candidates to ask them a stupid question.”

— Vermin Supreme

Sequence Number

Submitted by: Mohammad S Anwar

You are given list of strings in the format aa9999 i.e. first 2 characters can be anything 'a-z' followed by 4 digits '0-9'.

Write a script to replace the first two characters with sequence starting with '00''01''02' etc.

Example 1
Input: @list = ( 'ab1234', 'cd5678', 'ef1342')
Output: ('001234', '015678', '021342')
Example 2
Input: @list = ( 'pq1122', 'rs3334')
Output: ('001122', '013334')

contextual dissertation

I suppose you could typify me as a “big picture” sort of problem-solver. In my experience, problems are often misidentified, so when asked to perform some cryptic task, the common first response is to ask: “Why?”

What, exactly, are we trying to achieve here?

Because of the somewhat unusual way my brain works, I can sometimes see clearly at the onset that the given solution either solves the wrong problem or creates unexpected collateral damage that makes it unworkable in the end. Properly identifying the goal then, and from there the right path to the goal, and from that place identifying the necessary steps required to navigate the path — this method works for me, in general. Starting with the problem, though — and proceeding from there — makes some assumptions that often lead to force-fitting the goal into the solution instead of the other way around. And what we end up with too often is some elaborately well-thought-out process that doesn’t actually do what we need.

Yea, well, that sucks. I observe the common way out is to end up redefining the objectives and pretend that’s what they wanted to do all along. Which can be fine, sometimes (Really! Sometimes that randomness leads to cool stuff you didn’t ever plan on doing. You need to be flexible!), but the thing is: after all that we still haven’t done what needed to be done in the first place.

So we’re back to square one.


So what, may I ask, are we trying to do here? The task is straightforward, but are we mapping letter combinations to numeric prefaces, or just tossing out the alphabetic data and replacing it with a serial numbering system recording the order in which the data was presented to us?

Without some sort of larger context it’s not possible to say. We have two cases: in the former, should the letter prefix “ab” come up again we should reuse the numeric prefix “00” we already assigned to it. In the latter, we’re just throwing the prefix data out forever, which is always a red flag for me. Are we sure we want to do that?

The two examples given are alphabetically sequential, but also stated to contain any values. The prefixes used do not in fact repeat. So there’s no clarity coming from that front. One more note is that given a two-letter prefix where the letters “can be anything” there are 26 x 26 ordered combinations available, or 676 possible prefixes. We are specifically asked, however, to provide a two-number serial code to the numeric portion of each element. Not to put too fine a point on it, should that really be a three-number code? To allow a proper one-to-one bijective mapping between letter prefixes and our serial numbers? Again we are in the dark.

Without any additional information I see no better option than to solve the problem exactly as stated, removing the alphabetic prefix and substituting two-digit a serial number prefix.

Such is life. Hope that’s right.


use warnings;
use strict;
use utf8;
use feature ":5.26";
use feature qw(signatures);
no warnings 'experimental::signatures';

say join ' ', serialize( 'ab1234', 'cd5678', 'ef1342' );

sub serialize ( @input ) {
    my $i = 0; 
    my @out = map { sprintf "%02d%s", $i++, substr $_, 2 } @input;

    return @out;

The Perl Weekly Challenge, that idyllic glade wherein we stumble upon the holes for these sweet descents, is now known as

The Weekly Challenge – Perl and Raku

It is the creation of the lovely Mohammad Sajid Anwar and a veritable swarm of contributors from all over the world, who gather, as might be expected, weekly online to solve puzzles. Everyone is encouraged to visit, learn and contribute at