It uses xor.

:Ans→X

:1+max(abs(Ans→X

:∟X+Ans

:While max(Ans

:Ans→X

:SortD(∟X

:∟Xaugment({0},not(ΔList(∟X

:End

:sum(∟X xor 0→dim(∟X

:∟X-X

` ``:SortA(L₁ :Repeat min(0≠ΔList(L₂ :{0→L₂ :ΔList(L₁→L₃ :For(θ,1,dim(L₃ :If not(L₃(θ:L₁(θ→L₂(1+dim(L₂ :End :L₂→L₁ :End :ΔList(cumSum(L₂`

` ``SortA(L₁ Repeat min(DeltaList(L₂)≠0 {0→L₂ DeltaList(L₁→L₃ For(θ,1,dim(L₃ If not(L₃(θ):L₁(θ)→L₂(1+dim(L₂) End L₂→L₁ End DeltaList(cumSum(L₂`

RandInt(1,10,X | Time |
---|---|

10 | >1 - 2 Secs |

50 | 3-5 Secs |

100 | 10-12 Secs |

Edit: Basically how it works is it checks if the current element is the same as the one before it. If it is, it adds the value once to a new list. It then stores the new list back to the original and repeats until there are no duplicate values. This means that if there is a number that is not a duplicate, and a number that is it will not transfer the non-duplicate to the next list thereby eliminating it from the answer.

]]>` ``:ClrList L₂,L₃ :iL₁(1)+sum(L₁=L₁(1→L₂(1 :For(L,2,dim(L₁ :If not(max(L₁(L)=imag(L₂ :iL₁(L)+sum(L₁=L₁(L→L₂(1+dim(L₂ :End :For(L,1,dim(L₂ :If real(L₂(L))=max(real(L₂ :imag(L₂(L→L₃(1+dim(L₃ :End`

Put simply, this code puts each entry in L₁ along with the number of times it occurs into L₂ as a complex number (once per unique entry). It then finds the number(s) that occur the most and transfers it/them to L₃. I haven't run any speed tests yet, but I don't see anything that would slow it significantly (especially compared to the current alternative).

]]>