[RUBY] How can I efficiently fill an array with values?

I will post somehow. I was writing a program in ruby, but I noticed that I am still not familiar with arrays. For example this

qiita.rb


xc,yc,r_1,r_2 = gets.chomp.split(' ').map{|i| i.to_i}
n = gets.to_i
x = []
y = []
n.times do
  a,b = gets.chomp.split(' ').map{|i| i.to_i}
  x.push a
  y.push b
end
c = 0

while n > 0 do
  if r_1**2 <= ((x[c] - xc)**2 + (y[c] - yc)**2) && (x[c] - xc)**2 + ((y[c] - yc)**2) <= r_2**2
    puts "yes"
  else
    puts "no"
  end
  n = n - 1
  c = c + 1
end

I don't care about the contents of the process (while) this time.

By the time Definition of x and y arrays Define variables a and b Store a and b variables in an array in order

Is repeated. While thinking that I'm writing a code that looks like a fool I can't think of any better means.

Normally, a, b, etc. are not used

qiita.rb


x,y = gets.chomp.split(' ').map{|i| i.to_i}

I wish I could store it in this form from the beginning. I would like to find a way again.

Recommended Posts

How can I efficiently fill an array with values?
Rails6 I want to make an array of values with a check box
How to output standard from an array with forEach
I want to convert an array to Active Record Relation with Rails
Can I try all combinations with an app that has 20 checkboxes?
[Java] How to turn a two-dimensional array with an extended for statement
How to convert an array of Strings to an array of objects with the Stream API
I want to ForEach an array with a Lambda expression in Java
How to crop an image with libGDX
I made an eco server with scala
How much IDEA can help us with Java-Spock
How to use an array for HashMap keys
[Rails] How to build an environment with Docker
How to request by passing an array to the query with HTTP Client of Ruby