Quantcast
Channel: Double-reduce a sequence of integers - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 6

Answer by Kevin Cruijssen for Double-reduce a sequence of integers

$
0
0

05AB1E, 10 bytes

Î¥vDyα‚˜}¦

Inspired by @Neil's Charcoal answer.

Try it online or verify all test cases.

Explanation:

Î         # Push 0 and the input-list¥        # Get the deltas/forward-differences of the input-list  v       # Loop over each of its integers `y`:   D      #  Duplicate the current list,          #  which is the 0 in the first iteration    yα    #  Get the absolute difference of each value with integer `y`‚   #  Pair this list together with the duplicated list (or the 0)˜  #  Flatten it to a single list  }¦      # After the loop: remove the leading 0          # (after which the list is output implicitly as result)

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images