Posts Tagged ‘datetime

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.




Challenges

How often I post

July 2017
M T W T F S S
« Dec    
 12
3456789
10111213141516
17181920212223
24252627282930
31  

This is everything