class Integer

  def popcount
    digits(2).count(1)     
  end

  def evil?
    self >= 0 && popcount.even?
  end

end

puts ,  (0...30).map{|n| (3**n).popcount}.join(' ')
puts   , 0.step.lazy.select(&:evil?).first(30).join(' ')
puts , 0.step.lazy.reject(&:evil?).first(30).join(' ')