Hey Jesse,

Can you take a look at my new upload. I implemented benchmark…also fixed a good chunk of my specs. I’m still getting 2 failures though.

Also can you explain to me the nil.to_i == 0 thing?

Also I can’t how to I get rid of texas_cities = [], if benchmark needs that array to pull from.

Thanks,
Patil
On Dec 4, 2013, at 12:23 PM, Jesse Wolgamott <notifications@github.com> wrote:

> In lib/calculates_route.rb:
> 
> >      remaining_points = points
> >      route = []
> > -    route << remaining_points.slice!(0)
> > -    until remaining_points == [] do 
> > -      next_point = shortest_distance(route.last, remaining_points)
> > -      route << remaining_points.slice!(remaining_points.index(next_point))
> > +    conf = remaining_points.index(start_point)
> > +
> > +    if conf.nil?
> You can simplify this code using some Ruby coolness.
> 
> Given that nil.to_i == 0
> 
> And
> 
> array = [5, 6, 7]
> array.slice! nil.to_i
> =>[5]
> array
> =>[6,7]
> We could deal with conf wether it is a number, or zero:
> 
> Remove these lines:
> 
> conf = remaining_points.index(start_point)
> if conf.nil?
>   route << remaining_points.slice!(0)
> else
>   route << remaining_points.slice!(conf)
> end
> And replace with this one liner
> 
> route << remaining_points.slice! remaining_points.index(start_point)
> —
> Reply to this email directly or view it on GitHub.
>