Output all numbers below certain number containing certain digits
Ruby, 186 181 177 bytes
a=gets.split;puts ([0]+(0...gets.to_i).select{|x|(x.to_s.split('')&a).any?}).each_cons(2).slice_before{|m,n|m+1<n}.map{|a|c=a.map &:last;c.count>9?[c[0],'-->',c.last]:c}.join' '
Ungolfed explanation:
# Read numbers from input and split into array
a = gets.split
# Loop from 0 to maximum number, exclusive
puts ([0]+(0...gets.to_i).select { |x|
# Only include numbers that include at least one input digit
(x.to_s.split('')&a).any?
}) # Add dummy element to the beginning of array
.each_cons(2) # Get each array of 2 consecutive elements
.slice_before { |m, n| #
m + 1 < n # "Slice" the array if m and n are not consecutive
}.map { |a|
c = a.map &:last # Get all the last elements in `a`
if c.count > 9
# 10 or more consecutive elements. Get the first and last, and
# an arrow in-between
[c[0],'-->',c.last]
else
c
end
}.join ' ' # Add space in-between all elements, and print result
JavaScript (E6) 153 157 161 163 177
Input and output via prompt
The main loop filters the numbers with a regexp and builds spans of consecutive numbers (as arrays). The O function concatenates the spans converting them to string. If the elements in a span array are 10 or more, instead of taking all elelements it just take the first and last number.
Test in FireFox/FireBug console
P=prompt,m=P(d=P());
O=_=>(
o+=s[9]?s[0]+" -->"+p:s.join(''),s=[]
);
for(s=[o=''],p=n=0;n<m;++n)
(n+'').match("["+d+"]")&&
(
n+~p&&O(),s.push(p=' '+n)
);
O(),P(o)
Mathematica, 233 191 171 165 bytes
t=StringSplit;Flatten[Split[Cases[Range@Input[d=t@InputString[]]-1,m_/;ToString@m~t~""⋂d!={}],#2-#<2&]/.{e:{__Integer}/;Length@e>9:>{#&@@e,"-->",Last@e}}]~Row~" "
I'm taking the input from two prompts which is as close to command line as it gets in Mathematica.
Ungolfed:
t = StringSplit;
Flatten[
Split[
Cases[
Range@Input[d = t@InputString[]] - 1,
m_ /; ToString@m~t~"" \[Intersection] d != {}
],
#2 - # < 2 &
] /. {e : {__Integer} /; Length@e > 9 :> {# & @@ e, "-->", Last@e}}
]~Row~" "
I'm simply filtering a range with all numbers to the relevant ones and then I'm collapsing consecutive subsequences with a repeated rule replacement.