fork download
  1. def solve(f, min, max)
  2. middle = 0
  3. while(min != max) do
  4. middle = (min+max)/2
  5. if (f(middle)>0)
  6. max = middle
  7. else
  8. min = middle
  9. end
  10. return middle
  11. end
  12.  
  13.  
  14. p solve(1, -1000, 1000)
  15.  
Runtime error #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
Standard output is empty