Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
Alternate version with more of a reducer implementation (89 bytes):
lambda x:(m:=sum(x)/(l:=len(x)),[x:=[sum(x[0:2])/2]+x[2:]for n in range(l-1)][-1],x[0]-m)
Although this is longer, I suspect this reducer implementation may be useful for future python 3.8 code golfing.
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
Alternate version with more of a reducer implementation (89 bytes):
lambda x:(m:=sum(x)/(l:=len(x)),[x:=[sum(x[0:2])/2]+x[2:]for n in range(l-1)][-1],x[0]-m)
Although this is longer, I suspect this reducer implementation may be useful for future python 3.8 code golfing.
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), 70(削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),([p:=x[0]]+[p=x[0],*[p:=(p+n)/2for n in x])[x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), 70 bytes
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),([p:=x[0]]+[p:=(p+n)/2for n in x])[-1],p-m)
I know there has to be some more clever tricks to golf this further...
Python 3.8 (pre-release), (削除) 70 (削除ここまで) 69 bytes
-1 byte thanks to Kyle Gullion
returns (mean, p_mean, trend)
lambda x:(m:=sum(x)/len(x),[p:=x[0],*[p:=(p+n)/2for n in x]][-1],p-m)
I know there has to be some more clever tricks to golf this further...