Range - count
res = (1..10).count { |ix| sprintf("%b", ix) == sprintf("%b", ix).reverse }
puts res
# puts (1..10).map{|ix| sprintf("%b", ix) == sprintf("%b", ix).reverse; sprintf("%b", ix) }
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
res = (1..10).count { |ix| sprintf("%b", ix) == sprintf("%b", ix).reverse }
puts res
# puts (1..10).map{|ix| sprintf("%b", ix) == sprintf("%b", ix).reverse; sprintf("%b", ix) }