Day 8 checkpoint 4

This one was hard… like I was on the struggle bus. It was the second part of functions and math… I’m not great at math. Also anything over basic math kind of makes me sweat. This was the sum of all my fears.

The checkpoint was take a number and find the square root of it. Easy right? Just use the sqrt function. Sadly, Paul is a meanie, (JK I love you guy!), you need to brute force it. So say you need to find the square root of 625, you can’t just go sqrt(625). You need to take the range 1…100 and then take 1 x 1 does this equal 625? No then 2 x 2? all the way up to 25 and THAT hits.

Also you need to have catches if the number is under 1 or over 10,000. THANKFULLY you can keep it at Int so you don’t need to worry about doubles.

Here’s the code, it’s uploaded to my GitHub as well. And now, I need to lay down.

Take care and be well,

MJ

Leave a Reply

Discover more from Putting up or shutting up

Subscribe now to keep reading and get access to the full archive.

Continue reading