algorithm set implement with Java and Python