fork download
  1. (defn- ->count-map [v]
  2. (->> (group-by identity v)
  3. (map (fn [[k v]] {k (count v)}))
  4. (into {})))
  5.  
  6. (defn check [n v1 v2]
  7. (= n (->> (map ->count-map [v1 v2])
  8. (apply merge-with (comp #(Math/abs %) -))
  9. vals (apply +))))
  10.  
  11. ;; test
  12. (def data [[[1,2,3],[5,6,7]]
  13. [[1,1,1],[1,1,2]]
  14. [[1,1,2],[2,2,1]]
  15. [[9,8,9],[8,6,4]]
  16. [[9,7,2],[2,2,9]]])
  17. (dorun
  18. (for [[v1 v2] data]
  19. (println [v1 v2 '-> (check 2 v1 v2)])))
  20.  
Success #stdin #stdout 1.6s 390144KB
stdin
Standard input is empty
stdout
[[1 2 3] [5 6 7] -> false]
[[1 1 1] [1 1 2] -> true]
[[1 1 2] [2 2 1] -> true]
[[9 8 9] [8 6 4] -> false]
[[9 7 2] [2 2 9] -> true]