def palindromesgapful(digit, pow)
  r1 = digit * (10**pow + 1)
  r2 = 10**pow * (digit + 1)
  nn = digit * 11
  (r1...r2).select { |i| n = i.to_s; n == n.reverse && i % nn == 0 }
end

def digitscount(digit, count)
  pow  = 2
  nums = []
  while nums.size < count
    nums += palindromesgapful(digit, pow)
    pow += 1
  end
  nums[0...count]
end

count = 20
puts 
(1..9).each { |digit| print  }

count = 100
puts 
(1..9).each { |digit| print  }

count = 1000
puts 
(1..9).each { |digit| print  }