Can you guys make a regular expression to search/match with dubs.
\d+(00|11|22|33|44|55|66|77|88|99)
>>51533793
^dubs$
>>51533834
OP here, you fucked up it doesn't catch dubs
/(\d)\1$/
>>51533793
(\d)\1$
i wrote a thing that would find all the dubs, trips, etc... in a number range. here's the function that checked if characters repeated:def dubChecker(n):
check=str(n)
for i in range(len(check),1,-1):
if len(set(check[-i:]))==1:
return i
return n
you could changereturn ntoreturn Falseor something if you wanted to make it less ambiguous, but a single-digit integer should be sufficiently clear and allows you to use a dict that maps 3: trips, 2: dubs, etc...
if (postNumber == 00000000) ...
else if (postNumber = 00000011)...
else if (postNumber = 00000022)...
...
else if (postNumber = 99999999)...
>>51534200
Was going to call you stupid for str in range, but actually a clever use of len of str to quickly get digit size!
>>51534047
> not knowing how RegEx work
Stop being stupid anytime.
>>51534262
Its always nice to meet a fellow CS grad
>>51533793/[[:checkem:]]/
>>51534262
I see you made a typo where you're assigning to postNumber instead of checking for equality. I'm going to need you to go ahead and manually correct all 10,000,000 typos.
>>51533793<?php
function dubs($postNumber) {
if(!is_int($postNumber) || $postNumber < 10) return false;
list($n1,$n2) = sscanf(strrev($postNumber), "%01d%01d");
return $n1 === $n2;
}
?>
>>51534315
i felt like the intuition of getting the length of the set was a little cleverer (since repeating digits will always resolve to a single-element set), but thanks
>>51534566
Nice fatal error, faggot. Might as well do what your process did and kill yourself.
>>51534674
don't hurt yourself on that edge, kid
\d+(\d)\1
>>51535575
Thanks for not fucking up
\d{2}
>>51533834
Dumbass