I'm currently writing a program that will show the power spectrum of a
sound using a microphone as an input... When I do a FFT I get a complex
number and just take the magnitude. Is there a more efficient way of
doing this?

I'm trying to guess a 4-digit number with unique digits and after each
guess I'm told how many digits are correct and in the right place and
how many are correct but in the wrong place. I use that feedback to
make better and better guesses until I find the correct number. Is
there a general strategy to minimize the guesses needed?