Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Print max count of repeated consecutive numbers in an array

by jo37 (Deacon)
on Oct 06, 2021 at 17:28 UTC ( [id://11137272] : note . print w/replies, xml ) Need Help??


in reply to Print max count of repeated consecutive numbers in an array

If you'd like to use a sledgehammer to crack a nut:

#!/usr/bin/perl use v5.16; use strict; use warnings; use PDL; my $list = long(2,2,2,3,3,4,4); my $rle = long(rle $list); my $ind = maximum_ind $rle->slice('X,(0)'); say $rle->slice("($ind)");

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$