8-puzzle - Functions not working correctly

Done. Any ideas as to why the functions aren't working as they should?