Move create and solve logic to CPP