+0  
 
-1
921
3
avatar+174 

We call a number sticky if every digit in the number is either a 3 or next to a 3 For example, the numbers  333, 3773  and 83 are all sticky, but the numbers  53225  and 3999 are not sticky.

How many positive 3-digit numbers are sticky?

 Feb 5, 2020
 #1
avatar
+1

We can break into cases:

 

333 - 1 number

33* - 10 numbers

3*3 - 10 numbers

*33 - 10 numbers

*3* - 100 numbers

 

Total of 131 sticky numbers.

 Feb 5, 2020
 #2
avatar+23246 
+1

I beleive that the other person over-counted.

Numbers of the form:   *3*  --->  90    [don't count numbers starting with a '0']

Numbers of the form:   3*3  ---> 9      [actually, there are 10, but '333' has already been counted]

Numbers of the form:   *33  and  33* have already been counted.

 

So, I think that there are only 99.

 Feb 5, 2020
 #3
avatar
+1

a=1;b=0;c=0;p=0; cycle:d=a*100+b*10+c;if(b==3 or a==3 and c==3 or a==3 and b==3 or b==3 and c==3 , goto loop, goto next); loop:printd," ",;p=p+1; next:c++;if(c<10, goto cycle, 0);c=0;b++;if(b<10, goto cycle, 0);b=0;c=0;a++;if(a<10, goto cycle,0);print"Total = ",p

 

OUTPUT = 99 such numbers.

 Feb 5, 2020

0 Online Users