Create a gist now

Instantly share code, notes, and snippets.

anonymous /pankajsisodiya.rb Secret
Created Oct 15, 2009

What would you like to do?
Pankaj Sisodiya
Hi, This is Pankaj Sisodiya. I Love Programming.
I am very new to Ruby. I can't write the code for this program in Ruby, in exactly the manner you people need.
I am not aware of classes & syntax of Ruby & so can't create a function in Ruby which can take n number of parameters.
But i did try to solve your problem.
Let me tell you what i did:
1. set expectedtime (this is fixed)
2. set different arrival times (delayed time)
3. find the difference between each arrival times & expectedtime
4. now sum all the diferences (i don't how its returning on minutes, from a Riby tutorial I found that when we make difference between two Time in Ruby, it returns us Seconds)
5. take average
6. averagetime = expectedtime + average
7. display averagetime
expectedtime =
arrivedtime1 =
arrivedtime2 =
arrivedtime3 =
arrivedtime4 =
expectedtime = Time.local(2009,10,15,10,0,0)
arrivedtime1 = Time.local(2009,10,15,11,51,0)
arrivedtime2 = Time.local(2009,10,15,11,56,0)
arrivedtime3 = Time.local(2009,10,15,12,1,0)
arrivedtime4 = Time.local(2009,10,15,12,6,0)
arrivedtime5 = Time.local(2009,10,15,12,11,0)
d1 = (arrivedtime1 - expectedtime).to_i
d2 = (arrivedtime2 - expectedtime).to_i
d3 = (arrivedtime3 - expectedtime).to_i
d4 = (arrivedtime4 - expectedtime).to_i
d5 = (arrivedtime5 - expectedtime).to_i
puts d1,d2,d3,d4,d5
avg = (d1+d2+d3+d4+d5)/5
puts avg
avgtime =
avgtime = expectedtime + avg
puts avgtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment