g | x | w | all
Bytes Lang Time Link
104Scala231119T025041Z138 Aspe
027k4201024T232424Zcoltim
010Japt h200524T135457ZShaggy
048Wolfram Language Mathematica200523T173936ZGreg Mar
103C gcc zexecstack200522T094201ZNoodle9
nanJ200522T001403ZJonah
066Io200522T092451Zuser9206
054R200521T230545ZDominic
00505AB1E200522T085208Zuser9206
016APL Dyalog Extended200522T023353ZBubbler
057Python 2200521T222522ZSurculos
061JavaScript ES6200521T222859ZArnauld
041Charcoal200521T224643ZNeil
005Jelly200521T220742ZUnrelate

Scala, 104 bytes

Golfed version. Attempt this online!

(a,b)=>{val A=a.sorted;var B=b.sorted.toSeq;var s=0;for(x<-A){if(B.nonEmpty&&x>B(0)){s+=1;B=B.tail;}};s}

Ungolfed version. Attempt this online!

// Function f: Calculate how many matches can be won
def f(a: Array[Int], b: Array[Int]): Int = {
  val sortedA = a.sorted // Sort my team strengths
  var sortedB =
    b.sorted.toList // Sort opponent strengths (toList so we can drop elements easily)
  var s = 0 // Number of matches that can be won

  for (x <- sortedA) {
    // If current member x can beat the weakest remaining opponent
    if (sortedB.nonEmpty && x > sortedB.head) {
      s += 1
      sortedB = sortedB.tail
    }
  }
  s
}

k4, 27 bytes

{{x+y>x}/binr/{x@<x}'(y;x)}

Another port of Jonah's J answer, this time to k4.

If the input can be taken as a single list of two vectors, e.g. (3 10 6 7 7;2 4 6 2 6) (with the opposing team as the first list item, and our team as the second), the code can be simplified to 22 bytes as:

{{x+y>x}/binr/x@'<:'x}

Japt -h, 10 bytes

á Ëí>V xÃn

Try it

Wolfram Language (Mathematica), 48 bytes

Max[t=#2;Tr@Boole@Thread[#>t]&/@Permutations@#]&

Try it online!

Unnamed function taking two arguments as input (first our team, then their team), each as comma-separated lists such as {2,4,6,2,6}. Brute-force check over all Permutations of the input, taking the Max. Mathematica doesn't automatically compare lists elementwise, but Thread[#>t] forces it to; Boole converts Trues and Falses to 0s and 1s, respectively, so that Tr counts the number of wins. Mathematica is bad with currying when it's not programmed into the builtins, so I couldn't see a better way to handle the arguments than t=#2;.

C (gcc) -zexecstack, 124 \$\cdots\$ 105 103 bytes

Saved a whopping 2 17 19 21 bytes thanks to ceilingcat!!!

#define q(x)qsort(x,i=n,4,L"\x62b078bǃ");
i;j;f(a,b,n)int*a,*b;{q(a)q(b)for(j=0;i--;j+=*a++>b[j]);i=j;}

Try it online!

How

Sorts the two teams from weakest to strongest. Then goes through our side, starting from weakest, comparing it to the \$j^{\text{th}}\$ member of the opponent's team starting at \$j=0\$, their weakest wrestler. If we are ever stronger than the \$j^{\text{th}}\$ member we increment \$j\$. After we go through all our wrestlers, \$j\$ will be the maximum number we can beat.

J, 25 22 20 bytes

0(]+>)/@|.@,I.&(/:~)

Try it online!

-3 bytes thanks to Bubbler

Thanks to Dominic van Essen for spotting a subtle bug (now fixed)


This could be shorter using brute force, but I wanted to see how short I could make an efficient solution.

Our team = right arg, their team = left arg.

Using 2nd test case an example:

6 10 2 8 2 3 5 6 10 10 f 1 9 5 5 1 6 2 8 3 6 

Io, 66 bytes

Algorithm based on Noodle9's solution.

method(x,y,F :=0;x sort map(i,F=F+if(i>y sort at(F+1),1,0))last+1)

Try it online!

Explanation

method(x, y,      // Take 2 arguments.
    F := 0        // Initialize the counter to 0.
    x sort map(i, // For every item in sorted x:
        F = F + if( // Add the counter by:
            i>y sort at(F+1), // if the current item is larger than sorted y at the same position
            1,0)    // converted to an integer
    ) last + 1)     // Add the last item of the map by 1

R, 58 54 bytes

function(a,b){for(i in sort(a))F=F+(i>sort(b)[F+1]);F}

Try it online!

Algorithm based on Noodle9's solution; this could be made shorter than my own original recursive solution 76 bytes or than one based on the elegant algorithm of Surculose Sputum 73 bytes in R

05AB1E, 5 bytes

Coincidental port of Unrelated String's Jelly answer.

œ€‹Oà

Try it online!

Explanation

œ     All permutations to your team's combination
 €‹   Does your team win at this position?
   O  Sum the resulting lists to get all wins
    à Return the largest item of the list

APL (Dyalog Extended), 16 bytes

(+/⊢≥⍋)0~⍨1⊥<\⍥∧

Try it online!

An almost direct port of Jonah's J answer. But unfortunately, I found that, despite having the same name "interval index", J's I. and APL's don't have the identical behavior; J finds the indices before identical elements, but APL does after them.

That makes hard to use for this problem, so I had to fall back to outer product (which is used in the previous version of Jonah's answer).

How it works

(+/⊢≥⍋)0~⍨1⊥<\⍥∧  ⍝ Left: opponent strengths, Right: ours
              ⍥∧  ⍝ Ascending sort both args
          1⊥<\    ⍝ Outer product by < and then sum;
                  ⍝ count the opponents who each of ours can win against
       0~⍨  ⍝ Remove zeros
(    ⍋)     ⍝ Grade up; this is identical to ⍳∘≢ here since the arg is sorted
   ⊢≥       ⍝ Check if each number is at least its index
 +/         ⍝ Sum; count ones

Python 2, 59 57 bytes

-2 bytes thanks to @dingledooper!

lambda a,b:sum(b.sort()<b<[x]>b.pop(0)for x in sorted(a))

Try it online!

A function that takes 2 lists as arguments, and returns the maximum number of matches that can be won.

Approach

For each opponent (from weakest to strongest), match that opponent with the weakest available member of my team that can win.

For example, let's say the strength of 2 teams (sorted) are as follow:

No.       1  2  3  4  5
Me       [2, 2, 4, 5, 8]
Opponent [3, 6, 7, 7, 9]

We cannot win any more match. So in total we can win at most 2 matches.

Ungolfed code

a,b=map(sorted,input())  # sorted strength of my team and opponent team
s = 0                    # number of matches that can be won
for x in a:              # loop through my team, in order of increasing strength
  if x > b[0]:             # if current member can beat the weakest opponent left
    s += 1                   # then match those two
    b.pop(0)                 # and remove the weakest opponent
                           # (otherwise, current member is useless)
print s

JavaScript (ES6), 61 bytes

A shorter version inspired by @SurculoseSputum's answer.

a=>b=>(g=a=>a.sort((a,b)=>a-b))(a).map(x=>k+=x>g(b)[k],k=0)|k

Try it online!

That would be 31 bytes if the arrays were already sorted in ascending order:

a=>b=>a.map(x=>k+=x>b[k],k=0)|k

JavaScript (ES6),  85  75 bytes

Takes input as two lists of integers (team, opponents).

a=>b=>a.map(x=>(b[i=b.sort((a,b)=>b-a).findIndex(y=>x>y)]=a,~i&&++k),k=0)|k

Try it online!

Charcoal, 41 bytes

≔I⪪η η≔I⪪ζ ζWΦη›κ⌊ζ«§≔η⌕η⌊ι⁰§≔ζ⌕ζ⌊ζχ»I№η⁰

Try it online! Link is to verbose version of code. Explanation:

≔I⪪η η

Input the ratings of your wrestlers.

≔I⪪ζ ζ

Input the ratings of your opponents.

WΦη›κ⌊ζ«

Repeat while at least one of your wrestlers can beat one of your opponents.

§≔η⌕η⌊ι⁰

Set the strength of the weakest such wrestler to 0, so it will no longer be considered.

§≔ζ⌕ζ⌊ζχ

Similarly set the strength of its opponent to 10, so it will also no longer be considered.

»I№η⁰

Count and output the number of wins.

If the input was sorted, the calculation could be done in 19 bytes. Unfortunately it takes me 30 bytes to sort the input...

Jelly, 5 bytes

Œ!>§Ṁ

Try it online!

The second test case times out on TIO, but I have verified it locally. Takes your lineup as the left argument and theirs as the right.

Œ!       Find every permutation of your lineups' strengths,
  >      compare each matchup for each permutation,
   §     sum your wins for each permutation,
    Ṁ    and return the maximum number of wins.