程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python element sorting problem

編輯:Python

Define a function named , This function takes a list of integers and a target value as arguments . This function should return a sorted by a unique 2 An ordered list of element tuples , Each value in the tuple comes from the parameter list , And the sum of two tuple elements is equal to the total number of parameter targets .get_pair_sum (numbers_list target_total)
Be careful :
The parameter list may contain duplicate values .
. Each pair of values added to the sum in the formal parameter list should only appear once in the tuple list . for example , If the parameter list is [3,2,1,1,3], The total number of targets is 4, Then the output tuple list will contain only unique tuples (1,3), Without tuples (3,1).
. The tuple list must be arranged in ascending order .
Each tuple must be in ascending order ( for example (1,3) instead of (3,1)).


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved