A map widget zooms by a fixed scale per step: zooming in steps times multiplies the size by scale that many times, and a negative steps means zooming out, which divides instead.
Write zoomPower(scale, steps) that returns scale to the power steps. steps can be very large, so use about log |steps| multiplications instead of |steps|. Answers within 1e-5 (relative) are accepted.
Input: scale = 2, steps = 10 Output: 1024
2^10 = 1024.
Input: scale = 2, steps = -2 Output: 0.25
A negative power divides: 1 / 2^2 = 0.25.
-100 <= scale <= 100, scale !== 0-10^12 <= steps <= 10^12-10^4 and 10^4, and at least 10^-4 in size when it isn't 0.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #640 Zoom Level Power. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.