Skip to main content

Timeline for answer to Print the N-bonacci sequence by gabrielperales

Current License: CC BY-SA 3.0

Post Revisions

16 events
when toggle format what by license comment
Feb 1, 2016 at 8:52 history edited gabrielperales CC BY-SA 3.0
added 23 characters in body; added 1 character in body
Jan 30, 2016 at 0:52 comment added ETHproductions l.slice(-i).reduce((a,b)=>a+b) => eval(l.slice(-i).join`+`)
Jan 30, 2016 at 0:23 comment added Neil @user81655 Sorry I must have miscounted.
Jan 30, 2016 at 0:21 comment added user81655 @Neil Looks like 86 bytes to me...
Jan 30, 2016 at 0:19 history edited gabrielperales CC BY-SA 3.0
added 3 characters in body
Jan 30, 2016 at 0:17 comment added Neil @user81655 I don't get the eval saving; (i,n)=>{for(l=Array(i).fill(1);n-->i;)l.push(l.slice(-i).reduce((a,b)=>a+b));return l} is still 85 bytes.
Jan 30, 2016 at 0:16 history edited gabrielperales CC BY-SA 3.0
added 2 characters in body
Jan 30, 2016 at 0:13 comment added user81655 This is what it looks like with my tips (85 bytes): (i,n)=>eval("for(l=Array(i).fill(1);n-->i;)l.push(l.slice(-i).reduce((a,b)=>a+b));l"). I changed the order of statements, combined the n-- into n-i and removed l from the arguments to save a few extra bytes.
Jan 30, 2016 at 0:09 history edited gabrielperales CC BY-SA 3.0
deleted 3 characters in body
Jan 29, 2016 at 23:51 comment added user81655 Nice. A couple of golfing tips: for is always better than while, x.split('') -> [...x], ~~a -> +a, n-=1 -> n--, if you enclose the entire function body in an eval you don't need to write return. Also, even shorter than [...'1'.repeat(i)] is Array(i).fill(1) and you can remove the ~~ from a and b. And you're allowed to remove the f=.
Jan 29, 2016 at 23:26 history edited gabrielperales CC BY-SA 3.0
added 212 characters in body
Jan 29, 2016 at 23:19 history edited gabrielperales CC BY-SA 3.0
added 51 characters in body
Jan 29, 2016 at 23:13 history edited gabrielperales CC BY-SA 3.0
added 8 characters in body
Jan 29, 2016 at 23:11 review First posts
Jan 29, 2016 at 23:28
Jan 29, 2016 at 23:06 history edited Alex A. CC BY-SA 3.0
Converted to a code block and added syntax highlighting using SE Markdown (Stack Exchange doesn't support all GitHub Markdown)
Jan 29, 2016 at 23:04 history answered gabrielperales CC BY-SA 3.0