Algorithm && Python