Timeline for Turn an integer n into a list containing it n times
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 24, 2017 at 10:05 | comment | added | Olivier Grégoire | @Jean-BaptisteYunès Here are a few links to allow you to start getting around here: codegolf.stackexchange.com/tags/code-golf/info codegolf.stackexchange.com/questions/6671/… codegolf.meta.stackexchange.com/questions/tagged/code-golf And specifically about imports: codegolf.meta.stackexchange.com/questions/8287/… | |
| Aug 24, 2017 at 6:40 | comment | added | Jean-Baptiste Yunès | Ok I was not aware about full name qualification. I tried to find the rules but wasn't able? Any hint please? | |
| Aug 23, 2017 at 17:51 | comment | added | Olivier Grégoire | @Jean-BaptisteYunès If you want to try that, compare the two following: i=n;for(;i-->0;)a[i]=n; and java.util.Arrays.fill(a); (yes, the full name is required). 23 bytes vs. 25 bytes. I think I'll keep the loop. But thanks anyways ;-) | |
| Aug 23, 2017 at 17:22 | comment | added | Jean-Baptiste Yunès | Isn't using Arrays.fill(a,n)wouldn't be shorter than looping? (I'm new to PPCG, don't know if java.util can be used). | |
| Aug 21, 2017 at 13:03 | comment | added | JollyJoker | Yeah, but it's also flat out the canonical correct way of doing that in Java 8 so it's a pretty boring answer | |
| Aug 21, 2017 at 12:57 | comment | added | Olivier Grégoire | @JollyJoker You could do it! It's indeed two bytes shorter and would easily beat my answer ;-) | |
| Aug 21, 2017 at 12:42 | comment | added | JollyJoker | I thought about an answer like IntStream.generate(() -> n).limit(n) but decided it wasn't worth typing up and upvoted this instead :) | |
| Aug 21, 2017 at 12:01 | comment | added | Kevin Cruijssen | Happens to the best of us. ;) If you look in my answer history you'll probably also find some answers where I add something along the lines of "bytes saved thanks to ... due to a stupid mistake by myself / something obvious I forgot.." :) | |
| Aug 21, 2017 at 11:59 | history | edited | Olivier Grégoire | CC BY-SA 3.0 | added 4 characters in body |
| Aug 21, 2017 at 11:58 | comment | added | Olivier Grégoire | @KevinCruijssen Ouch, it hurts I didn't think about that... Thanks! | |
| Aug 21, 2017 at 11:15 | comment | added | Kevin Cruijssen | Two bytes shorter: n->{int a[]=new int[n],i=n;for(;i-->0;)a[i]=n;return a;} | |
| Aug 21, 2017 at 10:55 | history | answered | Olivier Grégoire | CC BY-SA 3.0 |