Timeline for Find the unique twins
Current License: CC BY-SA 3.0
24 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 17, 2020 at 9:04 | history | edited | CommunityBot |
Commonmark migration
|
|
Nov 3, 2017 at 17:42 | comment | added | Arnauld |
x-=y==e is actually one byte shorter.
|
|
Nov 3, 2017 at 15:03 | history | edited | Nate | CC BY-SA 3.0 |
added 63 characters in body
|
Nov 3, 2017 at 14:46 | comment | added | Arnauld | I think this one is also passing all edge cases (71 bytes). | |
Nov 3, 2017 at 14:42 | comment | added | Arnauld |
It's 73 bytes, but Stack Exchange inserted two ghost characters after length==1 .
|
|
Nov 3, 2017 at 14:37 | comment | added | Nate | @Arnauld Since the rules indicate there will be one such unique integer, this case is ok.(But it's same number of bytes as above) | |
Nov 3, 2017 at 14:25 | comment | added | Arnauld |
a=>b=>Math.max(...a.map(e=>(g=x=>x.filter(y=>y==e).length==1)(a)*g(b)*e)) should work. (There's an edge case with 0, but if the resulting array contains only zeros, then zero must be the correct answer.)
|
|
Nov 3, 2017 at 1:41 | history | edited | Nate | CC BY-SA 3.0 |
added 35 characters in body
|
Nov 3, 2017 at 1:34 | comment | added | tsh |
It seems that using (g=x=>x.filter(y=>y==e).length==1) is shorter.
|
|
Nov 3, 2017 at 0:44 | history | edited | Nate | CC BY-SA 3.0 |
added 436 characters in body
|
Nov 3, 2017 at 0:03 | comment | added | Justin Mariner |
I never thought of using lastIndexOf like that, that's pretty clever. You can get this down to 86 bytes: Try it online!. Check out the JS tips for more.
|
|
Nov 2, 2017 at 23:26 | comment | added | Nate | @MartinEnder Thanks for the help. This passes all the test cases including one you added | |
Nov 2, 2017 at 23:23 | history | edited | Nate | CC BY-SA 3.0 |
For real this time.
|
Nov 2, 2017 at 23:16 | history | edited | Nate | CC BY-SA 3.0 |
fix solution
|
Nov 2, 2017 at 22:59 | comment | added | Nate | Yeah, you're right. I would propose a test case for that. | |
Nov 2, 2017 at 22:57 | comment | added | Martin Ender |
Hm, wouldn't this now return 3 for f([1,2,3,3], [2,4]) ? It seems you only check that the value appears exactly twice in the concatenation of a and b , but not that those two occurrences weren't from the same original array.
|
|
Nov 2, 2017 at 22:48 | comment | added | Nate | @MartinEnder Thanks! Edited the answer to reflect the details I missed! | |
Nov 2, 2017 at 22:47 | history | edited | Nate | CC BY-SA 3.0 |
Missed a requirement
|
Nov 2, 2017 at 22:47 | history | undeleted | Nate | ||
Nov 2, 2017 at 22:23 | history | deleted | Nate | via Vote | |
Nov 2, 2017 at 22:21 | comment | added | Martin Ender |
Welcome to PPCG! As far as I can tell this doesn't make sure that e shows up only once in a and b .
|
|
Nov 2, 2017 at 22:11 | history | edited | Nate | CC BY-SA 3.0 |
remove function assignment as i've seen in other challenges
|
Nov 2, 2017 at 22:08 | review | First posts | |||
Nov 2, 2017 at 22:21 | |||||
Nov 2, 2017 at 22:06 | history | answered | Nate | CC BY-SA 3.0 |