1樓:
In [27]: import functools
In [28]: check_add_one = lambda arr:functools.
reduce(lambda x,y:(x+1==y if isinstance(x,int) else x[0] and x[1]+1==y, y),arr)[0]
In [29]: check_add_one([1,2,3,4,5])
Out[29]: True
In [30]: check_add_one([5,6,7,8])
Out[30]: True
In [31]: check_add_one([5,6,7,8,9])
Out[31]: True
In [32]: check_add_one([5,6,7,8,9,11])
Out[32]: False
2樓:ohmyfish
使用 Perl 6:
my @a = [1,2,3,4,5,6,7,9,10a)?? .say !! "".say for @a.minmax.flat;
3樓:Riseyoung
這個要看你對「連續」是怎麼定義的,像「1.2.3.
4.5.6.
7.9」這樣的,看差值就可以。其實所謂的兩個數之間的差值,就是微分,你可以設定乙個閾值判斷微分大小,超過一定值可以認為是乙個「跳變」。
這是最簡單的做法。
4樓:
a=[1,2,3,4,5,6,7,9,10]b=(x for x in range(a[0],a[-1]+1))for i in b:
if i not in a:
print()
continue
print(i)
怎樣用python,讀取excel中的一列資料?
pandas.read excel pandas 1.1.4 documentation excel資料示例 import pandas aspddf pd.read excel 學生成績.xlsx usecols 數學 物理 計算成績和等級的皮爾遜係數df 數學 corr df 物理 Kittyh...
matlab有沒有返回一列數的大小排名的函式?
靜待花開 tiedrank 函式。但如果其中有相同數,則這幾個數的秩都一樣。且是秩和的平均。如這個數在其中排第3,4,5。那麼返回的秩是 3 4 5 3。再例如 tiedrank 10 20 30 40 20 ans 1.0000 2.5000 4.0000 5.0000 2.5000 如果沒有相同...
Excel函式如何根據某列內容將另一列相關聯的多行資料轉成一行多列形式(VBA做也行,含問題檔案鏈)?
Option Explicit Subtest Dim dict AsObject Setdict CreateObject Scripting.dictionary Dim RowCount,i j,Arr FamilyNo Brr,ub ubm RowCount Sheets 源資料 UsedR...