(defn- ->count-map [v]
(->> (group-by identity v)
(map (fn [[k v]] {k (count v)}))
(into {})))
(defn check [n v1 v2]
(= n (->> (map ->count-map [v1 v2])
(apply merge-with (comp #(Math/abs %) -))
vals (apply +))))
;; test
(def data [[[1,2,3],[5,6,7]]
[[1,1,1],[1,1,2]]
[[1,1,2],[2,2,1]]
[[9,8,9],[8,6,4]]
[[9,7,2],[2,2,9]]])
(dorun
(for [[v1 v2] data]
(println [v1 v2 '-> (check 2 v1 v2)])))
KGRlZm4tIC0+Y291bnQtbWFwIFt2XQogICgtPj4gKGdyb3VwLWJ5IGlkZW50aXR5IHYpCiAgICAgICAobWFwIChmbiBbW2sgdl1dIHtrIChjb3VudCB2KX0pKQogICAgICAgKGludG8ge30pKSkKCihkZWZuIGNoZWNrIFtuIHYxIHYyXQogICg9IG4gKC0+PiAobWFwIC0+Y291bnQtbWFwIFt2MSB2Ml0pCiAgICAgICAgICAgIChhcHBseSBtZXJnZS13aXRoIChjb21wICMoTWF0aC9hYnMgJSkgLSkpCiAgICAgICAgICAgIHZhbHMgKGFwcGx5ICspKSkpCgo7OyB0ZXN0CihkZWYgZGF0YSBbW1sxLDIsM10sWzUsNiw3XV0KICAgICAgICAgICBbWzEsMSwxXSxbMSwxLDJdXQogICAgICAgICAgIFtbMSwxLDJdLFsyLDIsMV1dCiAgICAgICAgICAgW1s5LDgsOV0sWzgsNiw0XV0KICAgICAgICAgICBbWzksNywyXSxbMiwyLDldXV0pCihkb3J1bgogKGZvciBbW3YxIHYyXSBkYXRhXQogICAocHJpbnRsbiBbdjEgdjIgJy0+IChjaGVjayAyIHYxIHYyKV0pKSkK