Red Green Repeat Adventures of a Spec Driven Junkie

TDD Practice - Divide without Divide (continued)

From this post how is the runtime of your solution to implement divide without /? Is it linear? Can the solution be O(1)?

(The first post in this series is here)

Given the tests are:

it 'divides by 1' do
  divide(1,1).to eq(1)
end

it 'divides by 2' do
  divide(1,2).to eq(0)
end

This would be my solution:

def divide(a,b)
   return b > 1 ? 0 : 1
end

Is your solution similar? Different? How? Why is it different? Continued here