Skip to main content
2 of 3
deleted 302 characters in body
qwr
  • 12.3k
  • 6
  • 48
  • 80

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".

qwr
  • 12.3k
  • 6
  • 48
  • 80