Sometimes I know I'm going the long way around with an algorithm, but my brain isn't awake enough to figure it out.

Today I had code like this:

((width * resizeFactor) * (height * resizeFactor)) / (width * height)

To find out the % of pixels after resizing…
I knew it wasn't ideal, but wasn't in the mood for maths. If you're in this situation, boil it down to single-letter variables:

((x * y) * (z * y)) / (x * z)

Then give it to an online equation-solver https://bit.ly/3ddxh5n .

Turns out all I needed was Math.pow(resizeFactor, 2)
I guess I should have been able to figure it out, but the equation simplifier saved me a lot of time.
Ugh, the link got mangled. Here it is https://cutt.ly/RyGuUUU 
You can follow @jaffathecake.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: