def getRealFloor floor floor <= 0 ? floor : floor > 13 ? floor - 2 : floor - 1 end
require "test/unit" class GetRealFloorTest < Test::Unit::TestCase def test_get_real_floor assert_equal 0, get_real_floor(0) assert_equal 2, get_real_floor(3) assert_equal 6, get_real_floor(7) assert_equal 18, get_real_floor(20) assert_equal 0, get_real_floor(1) assert_equal -6, get_real_floor(-6) end end #1 tests, 6 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby Oneliner
Some tests