Graph game problem,

initial solution with bug