Timeline for Hilbert's Grand Hotel
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 26, 2017 at 15:14 | history | edited | Luke | CC BY-SA 3.0 |
Saved 11B
|
Jan 26, 2017 at 15:12 | comment | added | Luke | You're right! Learned another trick today... | |
Jan 25, 2017 at 21:01 | comment | added | Neil |
[...c].map(n=>n|0) should work.
|
|
Jan 25, 2017 at 20:55 | comment | added | Luke | You're right, added. Thanks! | |
Jan 25, 2017 at 20:55 | history | edited | Luke | CC BY-SA 3.0 |
Saved 11B
|
Jan 25, 2017 at 20:18 | comment | added | Arnauld |
Do you really need a for ? a=>a.map((d,c)=>b[d]?(b.splice(d,0,d),b.splice([...b,0].findIndex((e,g)=>g&&!e),1)):b[d]=d,b=[])&&(b+'').split`,`.map(Number) should work.
|
|
Jan 25, 2017 at 19:58 | history | edited | Luke | CC BY-SA 3.0 |
Fixed bug.. cost a lot of bytes : (
|
Jan 25, 2017 at 19:45 | history | edited | Luke | CC BY-SA 3.0 |
Added example input and output
|
Jan 25, 2017 at 19:45 | comment | added | Luke | Took some effort, but the bug is now fixed. Please let me know if you have any improvements... | |
Jan 25, 2017 at 18:32 | comment | added | Arnauld |
@ETHproductions The problem is that map() doesn't iterate at all on undefined values in the array. (That said, I'm pretty sure there's a shorter way than the one I suggested.)
|
|
Jan 25, 2017 at 17:47 | comment | added | ETHproductions |
I believe you could do c.map(n=>n|0) rather than (c+'').split`,`.map(Number) .
|
|
Jan 25, 2017 at 15:41 | comment | added | Luke | Oops, I forgot to test testcase 2, and it turns out my function doesn't support adding things to the front of the array... | |
Jan 25, 2017 at 15:31 | history | edited | Luke | CC BY-SA 3.0 |
Saved 9B
|
Jan 25, 2017 at 15:29 | comment | added | Luke | Clever trick, and yes, it does work. Thanks. | |
Jan 25, 2017 at 15:26 | comment | added | Arnauld |
I didn't really test that, but could (c+'').split`,`.map(Number) do the job?
|
|
Jan 25, 2017 at 14:52 | history | answered | Luke | CC BY-SA 3.0 |