Skip to main content
deleted 36 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
lambda p,q:  # f(): Given two words, construct an integer... all(  # - adding 1 if all the following inequalities hold: o:=  # (inequalities, stored as "o": [p.replace("?",a)  # left word with its "?"s filled is <q.replace("?",b)  # less than right word with its "?"s filled, for a,b in["AZ","ZA"]])  # the fillings being A and Z first,   # then Z and A) +[  # - then adding either p==q,  # (A) 1 point (conditional on words being equal) 2  # (B) 2 (unconditional) points ][any(o)]  # - with the criterion that (A) is chosen iff   # none of the "o" inequalities held. # - left wins = 3 = 1 (all ineqs hold) + 2 (some ineqs hold) # - right wins = 0 = 0 (not all ineqs hold) + 0 (words differ and no ineq holds) # - undecided = 2 = 0 (not all ineqs hold) + 2 (some ineqs hold) # - equal = 1 = 0 (not all ineqs hold) + 1 (words equal and no ineq holds) 
lambda p,q:  # f(): Given two words, construct an integer... all(  # - adding 1 if all the following inequalities hold: o:=  # (inequalities, stored as "o": [p.replace("?",a)  # left word with its "?"s filled is <q.replace("?",b)  # less than right word with its "?"s filled, for a,b in["AZ","ZA"]])  # the fillings being A and Z first,   # then Z and A) +[  # - then adding either p==q,  # (A) 1 point (conditional on words being equal) 2  # (B) 2 (unconditional) points ][any(o)]  # - with the criterion that (A) is chosen iff   # none of the "o" inequalities held. # - left wins = 3 = 1 (all ineqs hold) + 2 (some ineqs hold) # - right wins = 0 = 0 (not all ineqs hold) + 0 (words differ and no ineq holds) # - undecided = 2 = 0 (not all ineqs hold) + 2 (some ineqs hold) # - equal = 1 = 0 (not all ineqs hold) + 1 (words equal and no ineq holds) 
lambda p,q: # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) 1 point (conditional on words being equal) 2 # (B) 2 (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. # - left wins = 3 = 1 (all ineqs hold) + 2 (some ineqs hold) # - right wins = 0 = 0 (not all ineqs hold) + 0 (words differ and no ineq holds) # - undecided = 2 = 0 (not all ineqs hold) + 2 (some ineqs hold) # - equal = 1 = 0 (not all ineqs hold) + 1 (words equal and no ineq holds) 
added 298 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23

Python, 9492 bytes

f=lambdalambda p,q:all(o:=[p.replace("?",a)<q.replace("?",b)for a,b in["AZ","ZA"]])+[p==q,2][any(o)] 

Attempt This Online!Attempt This Online!

Anonymous lambda. Returns 3 for left, 0 for right, 2 for undecidable, 1 for equal.

f=lambdalambda p,q:  # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) one1 point (conditional on leftwords ==being rightequal) 2 # (B) two2 (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. # - left wins = 3 = 1 (all ineqs hold) + 2 (some ineqs hold) # - right wins = 0 = 0 (not all ineqs hold) + 0 (words differ and no ineq holds) # - undecided = 2 = 0 (not all ineqs hold) + 2 (some ineqs hold) # - equal = 1 = 0 (not all ineqs hold) + 1 (words equal and no ineq holds) 

Python, 94 bytes

f=lambda p,q:all(o:=[p.replace("?",a)<q.replace("?",b)for a,b in["AZ","ZA"]])+[p==q,2][any(o)] 

Attempt This Online!

Returns 3 for left, 0 for right, 2 for undecidable, 1 for equal.

f=lambda p,q: # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) one point (conditional on left == right) 2 # (B) two (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. 

Python, 92 bytes

lambda p,q:all(o:=[p.replace("?",a)<q.replace("?",b)for a,b in["AZ","ZA"]])+[p==q,2][any(o)] 

Attempt This Online!

Anonymous lambda. Returns 3 for left, 0 for right, 2 for undecidable, 1 for equal.

lambda p,q:  # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) 1 point (conditional on words being equal) 2 # (B) 2 (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. # - left wins = 3 = 1 (all ineqs hold) + 2 (some ineqs hold) # - right wins = 0 = 0 (not all ineqs hold) + 0 (words differ and no ineq holds) # - undecided = 2 = 0 (not all ineqs hold) + 2 (some ineqs hold) # - equal = 1 = 0 (not all ineqs hold) + 1 (words equal and no ineq holds) 
added 1094 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23

This is a community effort: Jonathan Allan's and Mukundan314's significant (37 bytes) improvements on my original idea below.

[🧍‍♂️👫🧍🧑‍🤝‍🧑🧍‍♂️]

This is a community effort: Jonathan Allan's and Mukundan314's significant (-37 bytes) improvements on my original idea.


 

My original submissionReturns (with 1 byte from Neil):3 for left, 0 for right, 2 for undecidable, 1 for equal.

f=lambda p,q: # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) one point (conditional on left == right) 2 # (B) two (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. 

[🧍‍♂️]

My original submission (with 1 byte from Neil)

This is a community effort: Jonathan Allan's and Mukundan314's significant (37 bytes) improvements on my original idea below.


 

My original submission (with 1 byte from Neil):

[🧍‍♂️👫🧍🧑‍🤝‍🧑🧍‍♂️]

This is a community effort: Jonathan Allan's and Mukundan314's significant (-37 bytes) improvements on my original idea.

Returns 3 for left, 0 for right, 2 for undecidable, 1 for equal.

f=lambda p,q: # f(): Given two words, construct an integer... all( # - adding 1 if all the following inequalities hold: o:= # (inequalities, stored as "o": [p.replace("?",a) # left word with its "?"s filled is <q.replace("?",b) # less than right word with its "?"s filled, for a,b in["AZ","ZA"]]) # the fillings being A and Z first, # then Z and A) +[ # - then adding either p==q, # (A) one point (conditional on left == right) 2 # (B) two (unconditional) points ][any(o)] # - with the criterion that (A) is chosen iff # none of the "o" inequalities held. 

[🧍‍♂️]

My original submission (with 1 byte from Neil)

added 1094 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 38 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 66 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 22 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
nicer explanation
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 1 character in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
added 144 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 31 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 31 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 31 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 88 characters in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 1 character in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
deleted 1 character in body
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading
Source Link
Nicola Sap
  • 3.8k
  • 2
  • 11
  • 23
Loading