Aksioma, 439 byte
c:=0;s(x,y)==(free c;if x.1=%i and y.2=%i then(x.2<y.1=>return true;x.2>y.1=>return false;c:=1;return false);if x.2=%i and y.1=%i then(x.1<y.2=>return true;x.1>y.2=>return false;c:=1;return false);if x.1=%i and y.1=%i then(x.2<y.2=>return true;x.2>=y.2=>return false);if x.2=%i and y.2=%i then(x.1<y.1=>return true;x.1>=y.1=>return false);false);r(a,b)==(free c;c:=0;m:=[[%i,j] for j in a];n:=[[i,%i] for i in b];r:=merge(m,n);sort(s,r);c)
ini mengonversi daftar pertama dalam daftar sebagai [[i, 1], [i, 2] ...] daftar kedua dalam daftar sebagai [[1, i], [0, i] ...] di mana saya adalah variabel imajiner daripada menggabungkan daftar 2, dan membuat satu jenis yang akan menemukan jika ada satu elemen dari daftar 1 dalam daftar 2 sehingga akhirnya O (N log N) di mana N = daftar panjang 1 + daftar panjang 2
ungolfed
-- i get [0,0,1,2,3] and [0,4,6,7] and build [[%i,0],[%i,0],[%i,1],[%i,2] [%i,3],[0,%i],..[7,%i]]
c:=0
s(x:List Complex INT,y:List Complex INT):Boolean==
free c -- [%i,n]<[n,%i]
if x.1=%i and y.2=%i then
x.2<y.1=> return true
x.2>y.1=> return false
c:=1
return false
if x.2=%i and y.1=%i then
x.1<y.2=>return true
x.1>y.2=>return false
c:=1
return false
if x.1=%i and y.1=%i then
x.2< y.2=>return true
x.2>=y.2=>return false
if x.2=%i and y.2=%i then
x.1< y.1=>return true
x.1>=y.1=>return false
false
r(a,b)==
free c
c:=0
m:=[[%i, j] for j in a]
n:=[[ i,%i] for i in b]
r:=merge(m,n)
sort(s, r)
c
hasil
(12) -> r([1,2,3,4,-5], [5,7,6,8]), r([],[0]), r([],[]), r([1,2],[3,3]), r([3,2,1],[-4,3,5,6]), r([2,3],[2,2])
Compiling function r with type (List PositiveInteger,List Integer)
-> NonNegativeInteger
Compiled code for r has been cleared.
Compiled code for s has been cleared.
Compiling function r with type (List PositiveInteger,List
PositiveInteger) -> NonNegativeInteger
Compiled code for r has been cleared.
Compiling function s with type (List Complex Integer,List Complex
Integer) -> Boolean
Compiled code for s has been cleared.
(12) [0,0,0,0,1,1]
Type: Tuple NonNegativeInteger
saya tidak mengerti mengapa itu "membersihkan" kode untuk r dan ...