Lets see how much of a novice you are anon
>>50770822
Don't even need to program that, though it's not the most elegant solution (if you guys have any regex tips, please lemme know)
grep -P -q '(1{2,}|2{2,}|3{2,}|4{2,}|5{2,}|6{2,}|7{2,}|8{2,}|9{2,}|0{2,})'.
>>50770866
Just use the digit code instead of typing them all out.
eg. ^(\d)\1+$
>>50770932
Woah, that's pretty damn cool. Managed to shorten it to grep -P -q '(\d)\1' to check for existence, or grep -P -o '(\d)\1{2,}' for outputting matches.
int rptdig(int a){
int b=-1,c=0;
while(a){
if(b==a%10||b==-1){b=a%10; a/=10;++c;}
else break;
}
return c;
}
/thread
>>50770822int rptdig(int a){
if(!a)return 1;
int c=1;
for(int b=a%10;b==(a=a/10)%(10);++c);
return c;
}
>>50771668
>>50771656
Doesn't handle cases where there are no repeating digits - and it doesn't work anyway.
You should at least do something like:int derp(int a) {
if(!a) return -1;
for(int b=a%10;a;b=a%10) if(b==(a=a/10)%10) return a%10;
return -1;
}
>>50771668
>s/==/!=/
Still not good, but at least it works now.
>>50771857
Scratch that, you never set b after initialization, so it's still fucked.
>>50770822
Can't do it. I don't belong here.
>>50772064
It's just the OP's homework. He doesn't belong here either.
>>50771857
>>50771834
>doesn't handle cases where there are no repeating digits
this post works and does that >>50771668
Is this what you were referring to?
It outputs the number of consecutive digits
if it is a single digit it puts out one
if its dubs it puts out two
trips? 3
quads? 4
There will never be an int case with less than one digit
>>50772610
It doesn't, did you even try it?
You return 1 if a is 0, how does that even make sense?
>>50770822
Do you want a script that highlights dubs or something?
>>50774091
Yes it does.
It works. For all numbers barring infinity; you have at least one digit. If for some odd reason you decide to use infinity with this, then you could have it return infinite digits.
The code certainly compiles and produces a result.