R.¥.Γ¥}¨ζнR
港@JonathanAllan的果冻答案,虽然我的果冻约在这种情况下果冻的更方便的内置命令。;)-
1个字节,感谢@Emigna。
在线尝试或验证所有测试用例。
说明:
R # Reverse the (implicit) input-list
# i.e. [16,7,4,3] → [3,4,7,16]
.¥ # Undelta it (with leading 0)
# → [0,3,7,14,30]
.Γ } # Continue until the result no longer changes, and collect all steps:
¥ # Get the deltas / forward differences of the current list
# → [[3,4,7,16],[1,3,9],[2,6],[4],[]]
¨ # Remove the trailing empty list
# → [[3,4,7,16],[1,3,9],[2,6],[4]]
ζ # Zip/transpose; swapping rows/column (with space as default filler)
# → [[3,1,2,4],[4,3,6," "],[7,9," "," "],[16," "," "," "]]
н # Only leave the first inner list
# → [3,1,2,4]
R # Revert it back
# → [4,2,1,3]
# (after which it's output implicitly as result)