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)
endThis would be my solution:
def divide(a,b)
return b > 1 ? 0 : 1
endIs your solution similar? Different? How? Why is it different? Continued here