Well, the first step to solving this problem is coming up with some more interesting fake data to play with, so the following __DATA__ segment contains 20 60 character strings with sequences of 4 numbers or more.
Script included so you can expand your data set if you so desire:
I verified that each of the above data sets all contain an absolute maximum. Here are the solutions:for (1..20) { my @str = map {int rand 10} (1..60); my $diff = join '', map {($str[$_] - $str[$_+1]) % 10} (0..$#str-1 +); redo unless $diff =~ /1{4}|9{4}/; print join('', @str) . "\n"; } __DATA__ 461771621368210983721913243963580233112903255149955120374576 412182871611285727937329810487417347645678899662426008558163 806445168622715729854145415356850576789033724164441981190358 737993205942843210944632043755783070487691419376068748520835 797836732611301651049157941402677493925908901268033467721123 800343673335834413425690063499636965547527671535789010360222 364556954738232740095412905428192849218058869868234154321153 656886016318465389850845261620694916565611559209695154321950 439823085483918818243602360632486757938483367890464586909210 275010825726438419734041987657085162773815821872771619322197 362862003186986435628956392997462270571538785287890111165953 865788969800483978909876396956896428059483834654443783640994 084943262444682256649196170826699756789404699917511813404654 038022435612197850835139478901471838789042407199858583654421 244712325541896615697820925442735727638540309574604984321042 799272593665633014792964321006295907297545039391442339309443 875134840933937552505069624569692178901372764210973501240868 160604373233208765433548554842941708483446447649679473623104 787966403724853567890040276258105492183424704761915858524942 234565329824361008677075492264130762647177370538202678949041
pos = 12, str = '21098' pos = 37, str = '45678' pos = 35, str = '67890' pos = 13, str = '432109' pos = 41, str = '89012' pos = 48, str = '78901' pos = 52, str = '54321' pos = 52, str = '54321' pos = 43, str = '67890' pos = 24, str = '98765' pos = 47, str = '78901' pos = 19, str = '09876' pos = 34, str = '56789' pos = 25, str = '78901' pos = 53, str = '43210' pos = 23, str = '43210' pos = 34, str = '78901' pos = 14, str = '876543' pos = 15, str = '567890' pos = 0, str = '23456'
Update: Added expected results for fake data.
In reply to Re: Find Length Of Longest Ascending/Descending Sequence
by wind
in thread Find Length Of Longest Ascending/Descending Sequence
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |