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('')&amp;a).any?}).each_cons(2).slice_before{|m,n|m+1&lt;n}.map{|a|c=a.map &amp;:last;c.count&gt;9?[c[0],'--&gt;',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('')&amp;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 &lt; n # "Slice" the array if m and n are not consecutive
}.map { |a|
  c = a.map &amp;:last # Get all the last elements in `a`
  if c.count &gt; 9
    # 10 or more consecutive elements. Get the first and last, and
    # an arrow in-between
    [c[0],'--&gt;',c.last]
  else
    c
  end
}.join ' ' # Add space in-between all elements, and print result