Skip to main content
added 727 characters in body
Source Link
Nahuel Fouilleul
  • 8.6k
  • 1
  • 10
  • 18

Perl 5 -p -Minteger, 7777, 73 bytes

/ (.*) (.*) /;$_=($`-$2)*($1-$')>=(($`+$1)/5%2^5+($2+$')/5%2?($`-$')*($1-$25):%2*($`-$2$1)*($1$2-$'))>=0

Try it online!Try it online!

2 bytes saved using xnor approach, and 2 other bytes using integer division, explanation is (renaming: $` -> a, $1 -> b, $2 -> c, $' -> d), first answer was:

  • (a-B)(b-A)>=0 if scores are in reversed order ((a+b)/5%2^(A+B)/5%2==1)
  • (a-A)(b-B)>=0 otherwise

as (a-B)(b-A)>=0 is equivalent to (a-A)(b-B)>=(a-b)(A-B)

  • (a-B)*(b-A)>=0 <=> ab+AB-aA-bB>=0 <=> ab+AB-aB-Ab>=aA+bB-aB-bA <=> (a-A)(b-B)>=(a-b)(A-B)

answer can be

  • (a-A)(b-B)>=0 if (a+b)/5%2^(A+B)/5%2==1
  • (a-A)(b-B)>=(a-b)(A-B) if (a+b)/5%2^(A+B)/5%2==0

or

  • (a-A)(b-B)>=(a-b)(A-B)*((a+b)/5%2^(A+B)/5%2)

or with integer division

  • (a-A)(b-B)>=(a-b)(A-B)*((a+b)/5+(A+B)/5)%2

Perl 5 -p, 77 bytes

/ (.*) (.*) /;$_=(($`+$1)/5%2^($2+$')/5%2?($`-$')*($1-$2):($`-$2)*($1-$'))>=0

Try it online!

Perl 5 -p -Minteger, 77, 73 bytes

/ (.*) (.*) /;$_=($`-$2)*($1-$')>=(($`+$1)/5+($2+$')/5)%2*($`-$1)*($2-$')

Try it online!

2 bytes saved using xnor approach, and 2 other bytes using integer division, explanation is (renaming: $` -> a, $1 -> b, $2 -> c, $' -> d), first answer was:

  • (a-B)(b-A)>=0 if scores are in reversed order ((a+b)/5%2^(A+B)/5%2==1)
  • (a-A)(b-B)>=0 otherwise

as (a-B)(b-A)>=0 is equivalent to (a-A)(b-B)>=(a-b)(A-B)

  • (a-B)*(b-A)>=0 <=> ab+AB-aA-bB>=0 <=> ab+AB-aB-Ab>=aA+bB-aB-bA <=> (a-A)(b-B)>=(a-b)(A-B)

answer can be

  • (a-A)(b-B)>=0 if (a+b)/5%2^(A+B)/5%2==1
  • (a-A)(b-B)>=(a-b)(A-B) if (a+b)/5%2^(A+B)/5%2==0

or

  • (a-A)(b-B)>=(a-b)(A-B)*((a+b)/5%2^(A+B)/5%2)

or with integer division

  • (a-A)(b-B)>=(a-b)(A-B)*((a+b)/5+(A+B)/5)%2
Source Link
Nahuel Fouilleul
  • 8.6k
  • 1
  • 10
  • 18

Perl 5 -p, 77 bytes

/ (.*) (.*) /;$_=(($`+$1)/5%2^($2+$')/5%2?($`-$')*($1-$2):($`-$2)*($1-$'))>=0

Try it online!