Here's my Perl solution. Works even if the first triple is not a double in the second number. Also uses regex backreferences, but only uses a regex for the first number. The much faster index is used to find the exact string in the second number.
#!/usr/bin/perlusev5.24;usestrict;usewarnings;usefeatureqw(signatures);nowarnings"experimental::signatures";useList::Utilqw(any);sub tripledouble($num1, $num2) {any{index($num2,"$_$_")>0}$num1=~/(\d)\1\1/g;}useTest::Moretests=>3;ok(tripledouble(451999277,41177722899),"(451999277, 41177722899) has triple/double");ok(tripledouble(4519992777,4117772289),"(4519992777, 4117772289) has triple/double");ok(!tripledouble(45199277,411777228999),"(4519992777, 4117772289) does not have triple/double");
any from List::Util lets us search all "triples" from the global regex, and as long as one of them matches as a double in $num2, this will return a true value.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's my Perl solution. Works even if the first triple is not a double in the second number. Also uses regex backreferences, but only uses a regex for the first number. The much faster
index
is used to find the exact string in the second number.any
from List::Util lets us search all "triples" from the global regex, and as long as one of them matches as a double in$num2
, this will return a true value.