Skip to main content
added 553 characters in body
Source Link
Zgarb
  • 42.8k
  • 4
  • 79
  • 259

Husk, 7 bytes

→►≠OfEΠ

Takes input as a list of two lists, works for any number of lists as well (returning the highest number that occurs exactly once in each, if possible). Try it online!

Explanation

This is the first Husk answer to (ab)use the new "maximum by" function .

→►≠OfEΠ  Implicit input, say [[3,2,1,3],[1,2,3,4]]
      Π  Cartesian product: [[3,1],[2,1],[3,2],[2,2],[1,1],[3,3],[1,2],[3,1],[3,4],[2,3],[1,3],[3,2],[2,4],[3,3],[1,4],[3,4]]
    fE   Keep those that have equal elements: [[2,2],[1,1],[3,3],[3,3]]
   O     Sort: [[1,1],[2,2],[3,3],[3,3]]
 ►≠      Find rightmost element that maximizes number of other elements that are not equal to it: [2,2]
→        Take last element: 2

Husk, 7 bytes

→►≠OfEΠ

Takes input as a list of two lists, works for any number of lists as well (returning the highest number that occurs exactly once in each, if possible). Try it online!

Husk, 7 bytes

→►≠OfEΠ

Takes input as a list of two lists, works for any number of lists as well (returning the highest number that occurs exactly once in each, if possible). Try it online!

Explanation

This is the first Husk answer to (ab)use the new "maximum by" function .

→►≠OfEΠ  Implicit input, say [[3,2,1,3],[1,2,3,4]]
      Π  Cartesian product: [[3,1],[2,1],[3,2],[2,2],[1,1],[3,3],[1,2],[3,1],[3,4],[2,3],[1,3],[3,2],[2,4],[3,3],[1,4],[3,4]]
    fE   Keep those that have equal elements: [[2,2],[1,1],[3,3],[3,3]]
   O     Sort: [[1,1],[2,2],[3,3],[3,3]]
 ►≠      Find rightmost element that maximizes number of other elements that are not equal to it: [2,2]
→        Take last element: 2
Source Link
Zgarb
  • 42.8k
  • 4
  • 79
  • 259

Husk, 7 bytes

→►≠OfEΠ

Takes input as a list of two lists, works for any number of lists as well (returning the highest number that occurs exactly once in each, if possible). Try it online!