Skip to main content
added 1 character in body
Source Link

JavaScritJavaScript, 112 bytes

k=>x=>(r=Array(k).fill(''),[...`${x<0?2*~x+1:2*x}`].map((c,i,s)=>r[(s.length-i)%k]+=c),r.map(v=>v&1?~(v/2):v/2))
  1. convert to non-negative
  2. (n*k+i)th digit to i-th number
  3. convert back

JavaScrit, 112 bytes

k=>x=>(r=Array(k).fill(''),[...`${x<0?2*~x+1:2*x}`].map((c,i,s)=>r[(s.length-i)%k]+=c),r.map(v=>v&1?~(v/2):v/2))
  1. convert to non-negative
  2. (n*k+i)th digit to i-th number
  3. convert back

JavaScript, 112 bytes

k=>x=>(r=Array(k).fill(''),[...`${x<0?2*~x+1:2*x}`].map((c,i,s)=>r[(s.length-i)%k]+=c),r.map(v=>v&1?~(v/2):v/2))
  1. convert to non-negative
  2. (n*k+i)th digit to i-th number
  3. convert back
Source Link
tsh
  • 35.6k
  • 2
  • 34
  • 129

JavaScrit, 112 bytes

k=>x=>(r=Array(k).fill(''),[...`${x<0?2*~x+1:2*x}`].map((c,i,s)=>r[(s.length-i)%k]+=c),r.map(v=>v&1?~(v/2):v/2))
  1. convert to non-negative
  2. (n*k+i)th digit to i-th number
  3. convert back