Skip to main content
added 500 characters in body
Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

Python 3.10, 8682 bytes

C="dQeKaQRbQNcQBfKBgKNhKR"
lambda b,s:C[C.index(s[:-1])-1]+str((r:=int(s[-1]),9-r)[b])
lambda b,s:C[C.find(s[:-1])-1]+str(abs(9*b-int(s[-1])))
C="dQeKaQRbQNcQBfKBgKNhKR"

Attempt This Online!

Testing out dictionary interleaving idea which is a little shorter than converting to ascii codes with chr. "Q" and "K" have to come first, otherwise they will match for at "QR".

-4 bytes using find instead of index and a better rank calculation for white/black.

Python 3.10, 86 bytes

C="dQeKaQRbQNcQBfKBgKNhKR"
lambda b,s:C[C.index(s[:-1])-1]+str((r:=int(s[-1]),9-r)[b])

Testing out dictionary interleaving idea which is a little shorter than converting to ascii codes with chr. "Q" and "K" have to come first, otherwise they will match for at "QR".

Python 3.10, 82 bytes

lambda b,s:C[C.find(s[:-1])-1]+str(abs(9*b-int(s[-1])))
C="dQeKaQRbQNcQBfKBgKNhKR"

Attempt This Online!

Testing out dictionary interleaving idea which is a little shorter than converting to ascii codes with chr. "Q" and "K" have to come first, otherwise they will match for at "QR".

-4 bytes using find instead of index and a better rank calculation for white/black.

deleted 302 characters in body
Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

Python 3.10Python 3.10, 9286 bytes

lambda b,s:chr(97+"QR QN QB Q K KB KN KR".split().index(s[:-1]))+str((r:=int(s[-1]),9-r)[b])C="dQeKaQRbQNcQBfKBgKNhKR"
lambda b,s:C[C.index(s[:-1])-1]+str((r:=int(s[-1]),9-r)[b])

Attempt This Online!

Sample answer Testing out dictionary interleaving idea which is a little shorter than converting to ascii codes with chr. "Q" and "K" have to come first, otherwise they will match for testingat "QR".

Python 3.10, 92 bytes

lambda b,s:chr(97+"QR QN QB Q K KB KN KR".split().index(s[:-1]))+str((r:=int(s[-1]),9-r)[b])

Attempt This Online!

Sample answer for testing

Python 3.10, 86 bytes

C="dQeKaQRbQNcQBfKBgKNhKR"
lambda b,s:C[C.index(s[:-1])-1]+str((r:=int(s[-1]),9-r)[b])

Testing out dictionary interleaving idea which is a little shorter than converting to ascii codes with chr. "Q" and "K" have to come first, otherwise they will match for at "QR".

Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

Python 3.10, 92 bytes

lambda b,s:chr(97+"QR QN QB Q K KB KN KR".split().index(s[:-1]))+str((r:=int(s[-1]),9-r)[b])

Attempt This Online!

Sample answer for testing