Timeline for Find the percentage
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 1, 2019 at 15:43 | comment | added | Ismael Miguel | @OlivierGrégoire Thank you. That makes sense. | |
Oct 1, 2019 at 15:39 | comment | added | Avi | Do things in the JDK count as built-ins or external libraries? Edit: nevermind, I think I understand now. | |
Oct 1, 2019 at 15:37 | comment | added | Olivier Grégoire | @Avi Yes, they are required, and it's usually shorter to write the full class name instead of the import, so that's what I do here | |
Oct 1, 2019 at 15:35 | comment | added | Avi | Is the import required? That's weird, I thought it wouldn't be | |
Oct 1, 2019 at 15:34 | comment | added | Olivier Grégoire |
@Avi The import is still required, so I'd have to write: (a,i)->1e2*a[i]/java.util.stream.IntStream.of(a).sum() , which is 54 bytes long. My current answer is only 47 bytes long. Also, a->i-> is one byte shorter than (a,i)-> .
|
|
Oct 1, 2019 at 15:31 | comment | added | Avi |
Change it to a BiFunction<int[], Integer, Double> and you can save 10 bytes with this: (a,i)->1e2*a[i]/IntStream.of(a).sum() . Edit: >:( my poor lambda arrow
|
|
Oct 1, 2019 at 15:16 | comment | added | Olivier Grégoire |
@IsmaelMiguel Yes: 1e2 carries the double type, which a[i] and the sum don't. Since the challenge requires to return floating point numbers, that's where I can use it.
|
|
Oct 1, 2019 at 15:09 | comment | added | Ismael Miguel |
Why did you wrote 1e2 instead of 100 ? Is it because 100 is integer and 1e2 is considered as a floating point number?
|
|
Sep 30, 2019 at 9:23 | history | answered | Olivier Grégoire | CC BY-SA 4.0 |