Problem-solving with loops and decision-making