DEV Community

Discussion on: Daily Challenge #16 - Number of People on the Bus

Collapse
 
kaspermeyer profile image
Kasper Meyer • Edited

Ruby 2.6

require "minitest/autorun"

class BusStopSimulator
  def self.call bus_stops
    bus_stops.map { |stop| stop.reduce(:-) }.sum
  end
end

class BusStopSimulatorTest < MiniTest::Test
  def test_four_bus_stops
    assert_equal 7, BusStopSimulator.call([[8,4],[1,0],[2,5],[6,1]])
  end
end