Write a script to get the maximum points. You are allowed to take out (kill) any integer and remove from the list. However if you do that then all integers exactly one-less or one-more would also be removed. Find out the total of integers removed.
Example 1
Input: @int = (2, 3, 1)
Output: 6
First we delete 2 and that would also delete 1 and 3. So the maximum points we get is 6.
Around the beginning of 2022 I started noticing a large number of warnings when compiling XS modules under macOS 12 Monterey. These looked like warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro], and appeared to originate fairly deeply in Perl's macro stack.
This week I was moved to address them for my one lone XS distribution, Mac-Pasteboard. Not only are they really annoying, but they would make it difficult or impossible to find anything more serious.
A little web searching seemed to say that this warning was added in clang 12.0, and is enabled by default. Beyond that, I did not find much. A Ruby ticket turned up, but the patch involved rewriting the relevant macros so that the warning was not tickled. A desultory check of a few other XS modules that came to mind did not provide any help -- they all showed the same behavior.
As a bystander in the evolution of Object-Oriented Programming in Perl,
and someone who is really only just starting to get the hang of Perl modules and packages
(still not any good at it), I get really quite overwhelmed by ideologies.
There is considerable debate about the right way to program things, the right
style, the right direction that Perl should go. It is Vim vs Emacs, Atari ST
vs Amiga, Mods vs Punks. Really one needs a language to do what one needs it
to do, simply, quickly and consistently. For an amateur, Perl has been able
to do exactly that for me. I code rubbishly, but hey, who's looking?
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on March 26, 2023 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: Special Bit Characters
You are given an array of binary bits that ends with 0.
Valid sequences in the bit string are:
[0] -decodes-to-> "a"
[1, 0] -> "b"
[1, 1] -> "c"
Write a script to print 1 if the last character is an “a” otherwise print 0.
Last year, impressed with the apparent speed of an M1 Mac Mini I bought to try out, I explored its perl performance and wrote about it in a
blog post
. I used mainly my own benchmarks which were mostly representative of workloads I was interested in.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on March 19, 2023 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: Minimum Index Sum
You are given two arrays of strings.
Write a script to find out all common strings in the given two arrays with minimum index sum. If no common strings found returns an empty list.
'It is a capital mistake to theorize before one has data.' -- Sherlock Holmes, "A Scandal in Bohemia"
The mental excursion that led to this blog post started with a report from Olaf Alders that my Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter was generating a false positive on variables used only as defaults in subroutine signatures. After the first cut at fixing this I thought a regression test was in order. I did this by running both unpatched and patched versions of the policy against my Mini CPAN, and then diff on the outputs.
This has always taken the better part of a day to run, and given that it had to expand all the distributions first and then run a fairly brute-force policy against anything it found, I accepted this as the price of conscientiousness.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on March 12, 2023 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: Keyboard Word
You are given an array of words.
Write a script to print all the words in the given array that can be types using alphabet on only one row of the keyboard.
XS has a reputation of being ugly and cumbersome, but in my experience, it doesn't have to be. Let's take for example this snippet from my Thread::Csp::Promise class:
'A fair jaw-cracker dwarf-language must be.' -- Samwise Gamgee, The Lord of the Rings, II/iii: "The Ring Goes South", as quoted in regcomp.c, the Perl regular expression compiler.
As you would expect, this category gets you warnings about possibly-problematic regular expression constructions. A couple specific examples are:
Assuming NOT a POSIX class ...
This warning is about things that look kind of like POSIX character classes, but do not parse that way. The full diagnostic gives examples like [[:alnum]] (missing colon) and [[:digit:xyz] (missing right square bracket). These parse like simple character classes ([:[almnu]\] and [:[dgitxyz] respectively), so without the warning you get a hard-to-diagnose bug.
Unescaped left brace in regex is passed through ...
Efforts to eliminate unescaped left braces so that they are available for new syntax have been underway since 5.17.0, released May 2012. As I recall, this effort turned to be much harder than originally anticipated because at least one toolchain external to Perl (autoconf if memory serves) relied on this behavior.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on March 5, 2023 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: Shortest Time
You are given a list of time points, at least 2, in the 24-hour clock format HH:MM.
Write a script to find out the shortest time in minutes between any two time points.
Example 1
Input: @time = ("00:00", "23:55", "20:00")
Output: 5
Since the difference between "00:00" and "23:55" is the shortest (5 minutes).
1997 gegründet, gehört STRATO mit über 4 Millionen Domains und mehr als 2 Millionen Kunden heute zu den größten Webhosting-Anbietern weltweit. STRATO beschäftigt rund 500 Mitarbeiter und betreibt zwei TÜV-zertifizierte Rechenzentren mit über 70.000 Servern in Berlin und Karlsruhe. Die STRATO AG ist ein Unternehmen der United Internet-Gruppe.
The re module provides functionality relating to Perl's regular expressions. It is either a module in the sense of potentially exporting stuff into your name space or a pragma in the sense of modifying the behavior of Perl within a lexical scope, or both, depending on how you use it.
The pragmatic functionality tweaks the regular expressions themselves in various ways: