Posts Tagged ‘date

14
Oct
09

Average Arrival Time For A Flight, part 1

To be honest this was a bit of a disappointment when I first read it, but upon starting the challenge I realized there are way more subtleties than I first gave it credit for. My initial thought was to take a base time as milliseconds then convert all inputs to milliseconds, find the difference, average and put it back into regular hours. I started reading Date classes and found a pretty easy way to do this.
After working on this for a while I realized that I would have to use more than just DateTime. As usual, it was pretty much in the instructions to use Time. Once I brought that class in, this problem becomes pretty trivial. I’ll post my solution once it ends, but I think it’s pretty good. It’s only 18 lines, any tips on how to make it more Ruby-like would be much appreciated.

Advertisements



Challenges

How often I post

January 2018
M T W T F S S
« Dec    
1234567
891011121314
15161718192021
22232425262728
293031  

This is everything