E. Choroba
- Website: www.perlmonks.org/?node_id=832495
Recent Actions
-
Commented on Perl wiki updated, 4 other wikis uploaded - Take 4
Do the links work in a Preview?...
-
Posted Strong Password to E. Choroba
The Weekly Challenge 287, Task 1
You are given a string,
$str
.
Write a program to return the minimum number of steps required to make the given string very strong password. If it is already strong t… -
Commented on Perl Weekly Challenge 287: Strong Password
aaaaa should return 2: e.g. replace aaAaa, then insert aaAaa0. Similarly, 000aaa000 should return 3 (we can replace the middle char in every group with A), but your code returns 4....
-
Commented on This week in PSC (157) | 2024-08-23
@Brett: Re: info() - I think such information belongs somewhere in perldoc, not a function. I definitely agree with the first two bullets, see also Syntax::Construct (especially the "Good Practice" part) to know more about my view on similar topics....
-
Commented on Caching & Memoization with state variables
No, I mean we only have one subroutine, but we want to use it to generate two different sequences....
-
Commented on Caching & Memoization with state variables
I don't like state variables in named subroutines. They make it hard to reuse the subroutines, imagine in this example we'd like to generate the Lucas sequence (L1 = 1, L2 = 3), too, but we can't, as we only...
-
Posted Equalise an Array to E. Choroba
The Weekly Challenge 270/2
In the week 270, the second task was really interesting and difficult. Here’s a slightly reformulated version:
We’re given an array of positive integers
@ints
-
Posted Changes in MooX::Role::Parameterized to E. Choroba
What is it good for?
If you’ve never worked with MooX::Role::Parameterized or MooseX::Role::Parameteri…
-
Posted Step Counter (Advent of Code 2023/21) to E. Choroba
The Task
We’re given a grid with obstacles, we’re supposed to count all the reachable plots in the grid in a given number of steps (we can only move one plot at a time horizontally or vertically).
… -
Commented on Perl Weekly Challenge 200: Arithmetic Slices and Seven Segment Display
Your Perl solution to Task 1 doesn't output 3 7 11 as one of the solutions to 3 5 7 9 11. Does it fit your definition of a slice?...
-
Posted Array Degree to E. Choroba
The Weekly Challenge 189/2
The Task 2 was rather interesting in the week 189.You are given an array of 2 or more non-negative inte…
-
Commented on What happened to Perl 7?
Shouldn't bareword_filehandles be disabled rather than enabled?...
-
Commented on The ordering operators
I also use it sometimes when there are three different actions based on a comparison, turning something like for my $x (1, 2, 3) { for my $y (1, 2, 3) { print "$x $y "; if ($x == $y)...
-
Commented on Access the Tesla API with Perl!
Matthew Persico: https://opensource.com/article/18/1/my-delorean-runs-perl...
-
Posted Eertree: Palindromic Tree to E. Choroba
The Weekly Challenge 145
The Task 2 of the Weekly Challenge #145 asked us to build a Palindromic Tree. It also linked to a ="https://medium.com/@alessiopiergiacomi/eertree-or-palindr…
-
Commented on In defence of OOP
Good points! Looking forward for the next parts....
-
Commented on Is it possible to return to development with traditional P5P mailing lists?
What problem should moving to a mailing list solve? The mailing list was public, anyway, so apart from security issues, there was no "secret room" for the elite to discuss stuff before disclosing it. GitHub just makes participation easier for...
-
Posted Perl Weekly Challenge 061: Product SubArray And IPv4 Partition to E. Choroba
Product SubArray
Given a list of 4 or more numbers, write a script to find the contiguous sublist that has the maximum product. The length of the sublist is irrelevant; your job is to maximize the product.
Example
… -
Posted Perl Weekly Challenge 060: Excel Column And Find Numbers to E. Choroba
Write a script that accepts a number and returns the Excel Column Name it represents and vice-versa.
Excel columns start at A and increase lexicographically using the 26 letters of the English alphabet,…
-
Posted Perl Weekly Challenge 059: Linked List and Bit Sum to E. Choroba
Linked List
You are given a linked list and a value k. Write a script to partition the linked list such that all nodes less than k come before nodes greater than or equal to k. Make sure you preserve the original rel…
-
Posted Perl Weekly Challenge 058: Compare Version and Ordered Lineup to E. Choroba
Compare Version
Compare two given version number strings v1 and v2 such that:
- If v1 > v2 return 1
- If v1 < v2 return -1 …
-
Posted Perl Weekly Challenge 057: Invert Tree and Shortest Unique Prefix to E. Choroba
Shortest Unique Prefix
Write a script to find the shortest unique prefix for each each word in the given list. The prefixes will not necessarily be of the same length.
Sample Input
[ "alphabet", "book", "…
-
Posted Perl Weekly Challenge 056: Diff-K and Path Sum to E. Choroba
Diff-K
You are given an array @N of positive integers (sorted) and another non negative integer $k. Write a script to find if there exists 2 indices $i and $j such that
$A[$i] - $A[$j…
-
Posted Perl Weekly Challenge 054: Kth Permutation Sequence + Collatz Conjecture to E. Choroba
Kth Permutation Sequence
Write a script to accept two integers n (>=1) and k (>=1). It should print the k-th permutation of n integers.
For example, n=3 and k=4, the po…
-
Posted Perl Weekly Challenge 053: Rotate Matrix and Vowel Strings to E. Choroba
Rotate Matrix
Write a script to rotate the following matrix by given 90/180/270 degrees clockwise.
[ 1, 2, 3 ] [ 4, 5, 6 ] [ 7, 8, 9 ]
For example, if you rotate by 90 degrees then expected r…
-
Posted Perl Weekly Challenge 052: Stepping Numbers & Lucky Winner to E. Choroba
Stepping Numbers
Write a script to accept two numbers between 100 and 999. It should then print all Stepping Numbers between them.
A number is called a stepping number if the adjacent digits have a difference of 1.…
-
Posted Perl Weekly Challenge 051: 3 Sum and Colourful Numbers to E. Choroba
3 Sum
Given an array
@L
of integers. Write a script to find all unique triplets such that a + b + c is same as the given target T. Also make sure a <= b <= c… -
Posted Perl Weekly Challenge 050: Merge Intervals and Noble Integer to E. Choroba
Merge Intervals
Write a script to merge the given intervals where ever possible.
[2,7], [3,9], [10,12], [15,19], [18,22]
The script should merge [2, 7] and [3, 9] together to return …
-
Commented on Perl Weekly Challenge: Smallest Multiple and LRU Cache
Note that $set->(3, 7) for 1 .. $capacity; removes all other keys from the cache (improbable for caches with a large capacity, though)....
-
Posted Perl Weekly Challenge 049: Smallest Multiple and LRU Cache to E. Choroba
Smallest Multiple
Write a script to accept a positive number as command line argument and print the smallest multiple of the given number consists of digits 0 and 1.
For example: For given number …
Comment Threads
-
Smylers commented on
What happened to Perl 7?
Thank you for such a clear update. As somebody who only manages intermittently to follow what's happening with the Perl core, this is really useful, and explains several things I'd be wondering about.
-
laurent_r commented on
Perl Weekly Challenge 200: Arithmetic Slices and Seven Segment Display
Hi Choroba, thanks for your comment. It appears that we don't understand the task in the same way. My understanding of the task is that the differences between any three *consecutive* elements of the original array of integers should be the same. 3 7 11 is indeed an arithmetic sequence, but these numbers are not consecutive items in the original 3 5 7 9 11 input sequence.
-
chrisarg commented on
Caching & Memoization with state variables
I am not sure I follow; are you saying that two different named subroutines can't have the same name for their state variables, i.e. it is not possible to have ?
sub lucas ()
{
state $statevar;
...
}sub fibo ()
{
state $statevar;
...
}would
-
Brett Estrade commented on
Caching & Memoization with state variables
I love state variables, but oddly only use them when creating sub based state machine xD - which is typically just for show. But the idea of co-routines in Perl is nifty.
I think E. Choroba means something like:sub foo { state $foo = 1; ... say $foo; ++$foo; }
foreach my $i (1 .. 10) {
foo();
}
versus,
my $foo = 1; foreach my $i (1 .. 10) { my $sub = sub { my $myfoo = $foo; ... say $myfoo; }; ++$foo; $sub->(); }
-
Aristotle commented on
This week in PSC (157) | 2024-08-23
PHP has the
info()
function for a very different reason: it tells you ⓐ what options the language has been compiled with because ⓑ you cannot examine them directly without shell access to the host. So it covers a set of requirements that simply do not exist for us, because there is no way to compile a perl with only some of its features. Whether you have any given feature or not depends solely on which version of the perl interpreter you’re running, not how it was compiled. A function that provides this information would just duplicate the documentation at a point where…
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.