secret
anonymous / pankajsisodiya.rb
Last active

Pankaj Sisodiya

  • Download Gist
pankajsisodiya.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
=begin
 
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
=end
 
expectedtime = Time.new
 
arrivedtime1 = Time.new
arrivedtime2 = Time.new
arrivedtime3 = Time.new
arrivedtime4 = Time.new
 
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 = Time.new
avgtime = expectedtime + avg
puts avgtime

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.