Quantcast
Channel: Double-reduce a sequence of integers - Code Golf Stack Exchange
Browsing latest articles
Browse All 6 View Live

Answer by Victor for Double-reduce a sequence of integers

Haskell, 48 bytesr a[_]=ar a(x:y:l)=r(a++[y-x-z|z<-0:a])$y:lr[]

View Article


Answer by Neil for Double-reduce a sequence of integers

Charcoal, 24 bytes⊞υ⁰FEΦθκ⁻ι§θκ≔⁺υ⁻ιυυIΦυκTry it online! Link is to verbose version of code. Explanation: Adapted from both @Arnauld's and @loopywalt's answers.⊞υ⁰Start with a list of just...

View Article


Answer by loopy walt for Double-reduce a sequence of integers

Python, 63 bytesf=lambda l,*L,a=[]:L and f(*L,a=a+[L[0]-l-b for b in[0]+a])or aAttempt This Online!Takes splatted input. Returns the entire double-reduction.How?Once one all but ignores the confusing...

View Article

Answer by Arnauld for Double-reduce a sequence of integers

JavaScript (ES6), 61 bytesa=>a.map(v=>a=[0,...b].map(k=>1/a&&b.push(v-a-k))&&v,b=[])&&bTry it online!Commenteda => // a[] = inputa.map(v => // for each value v in...

View Article

Double-reduce a sequence of integers

Consider a function \$r\$ where$$r(i,k)= \begin{cases}L_{i+1}-L_i, & \text{if}\ k =0\ \text{ (1st reduction)} \\r(i,0)-r(\lfloor \log_2{k} \rfloor,k-2^{\lfloor \log_2{k} \rfloor}) & \text{if}\...

View Article


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

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...

View Article
Browsing latest articles
Browse All 6 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>