R, (削除) 31 (削除ここまで) 29 bytes
function(a,b)pmax(a,b)+a*!a-b
pmax takes the parallel maximum of the two (or more) arrays (recycling the shorter as needed).
I was looking at Luis Mendo's comment and obviously I realized the approach could work for R as well. That got me to 30 bytes, but then I started playing around with different ways of getting indices instead to improve my original answer, and stumbled upon !a-b as TRUE where a==b and FALSE otherwise, equivalent to a==b. However, for whatever reason, R doesn't require parentheses around !a-b as it does for a==b, which saved me two bytes.
- 29.4k
- 3
- 33
- 106