export common scanf function for guesses to a separate function

My code is too messy

Signed-off-by: Liew Zhao Wei <zhaoweiliew@gmail.com>