Post History
Python 3, 101, 98, 94 bytes First answer! lambda s:f"{(('FCGDAEB'.index(s[0])-~-ord(s[5])*('-'in s)-3*('i'in s)-6)%12)+1}"+'BA'['i'in s] Try it online! Readable version: def f(s): n="FCG...
Answer
#4: Post edited
# [Python 3], 98 bytes- First answer!
- <!-- language-all: lang-python -->
lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12)+1}"+'BA'['i'in s][Try it online!][TIO-kjgsm0bj]- [Python 3]: https://docs.python.org/3/
[TIO-kjgsm0bj]: https://tio.run/##hZJNb4IwGIDv/IqmyUI7wQgofiQeioqnnXZ0HliQyJBigMMW429nFdzbVzyMU/s8NHmfpuef@lhIr0mWH80pyj/jiFSLhF4YM8PVdi02gTlMZXz4ZtVutOc2K8pYLSdq6fBXZtpmKkmluKc2abfhts9fHJcPnCsdmIEwd3ezb/LoqygrsiQXg6iPBuTtRihZEOoE1OpoaL8fo/KMnAtubYenqEbKAyX6agxq01cTUEFf@XoORKdAV4jOgG4Rnetpcd9IT4qx7t5g3CZfDSNP5cOV/VXecPen6FeCckW/EpQnUCXQsUCVQCcCVQL1BaoEOhUoEuhMoEagcz0e7hmJp4egpa5dP11Em6uuzEiKkmSWJOrRdS9umNaHvGJ80R49l6msWWYRaZGEZZwbRoco5Y@H27v/93DzCw "Python 3 – Try It Online"- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
# Python 3.9, 95 bytes:lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*(m:='i'in s))-6)%12)+1}"+'BA'[m]- Isn't the walrus operator great?
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsevaf]: https://tio.run/##hZI9b4MwEIZ3foVlqbLdQAQhkA8pg8nX1KljmoEqQaEJJgKGVlF@O3UgPV/IUOTBfl5Ouud055/qkCu/TmYf9SnOPncxKacJvXDOVvP1Qi4j1k/Vbv/Ny427FQ7Pi52@BvrqiVfOHJYqUmru60faPoQTihdvoI/oeVfaY5Fkm3u4rbP4Ky9KMiMXi@iPRuTtRiiZEupF1G7pynk/xMUZZQPIFs7qFFco8iGS3WgI0bIbBRBF3Sg0fSA6AjpHdAx0jejEdIv9XNMpxsZ7iXGjfLWsLFUPI/uzvOH2T9m1hGggu5YQ@RJZAh1KZAk0kMgSaCiRJdCRRJJAxxI5Ap2Y9rCPK58WwYTGdvE0iEZXj8xK8oIcbUX00rUb10@rfVZyMW1Kz0WqKn60ibJJwo9CWFaLKBWPxc3s/y2ufwE "Python 3 – Try It Online"
- # [Python 3], ~~101, 98~~, 94 bytes
- First answer!
- <!-- language-all: lang-python -->
- lambda s:f"{(('FCGDAEB'.index(s[0])-~-ord(s[5])*('-'in s)-3*('i'in s)-6)%12)+1}"+'BA'['i'in s]
- [Try it online!][TIO-kjgsycg0]
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsycg0]: https://tio.run/##hZJBb4IwFIDv/IqmyUI7wSgIKomHIujJ047OA4sSmVIIcNhi3F9nCO71iYdxar6PJu97af5dHTNp1/HivT5H6cc@IqUX0wtj@mq5DkTo68NE7g9frNyOdtz8MbNi35ydHX9luqknkpTctJtzcj@7/GVs8cH4Sge6L/TtXezqNPrMipIsyEUjzUd9srkRSjxCxz41Oroy345RkSNngQvM1TmqkLJBib6agAr7ygHl95Wr5kB0CnSJ6AzoGtG5mhb3jdSkGKvuEOM2@appaSIfVvZXecPdn6JfCcoS/UpQtkCVQCcCVQJ1BKoE6gpUCXQqUCTQmUCNQOdqPNwzEk8PQUlVGzwtos1tVqbFWUFOhiTNo@te3DCpDmnJuNdezYtEVuxkEGmQmJ0417QOUcofL7e7//dy/Qs "Python 3 – Try It Online"
- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
- # Python 3.9, ~~95~~, 91 bytes:
- lambda s:f"{(('FCGDAEB'.index(s[0])-~-ord(s[5])*('-'in s)-3*(m:='i'in s)-6)%12)+1}"+'BA'[m]
- Isn't the walrus operator great?
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsevaf]: https://tio.run/##hZI9b4MwEIZ3foVlqbLdQAQhkA8pg8nX1KljmoEqQaEJJgKGVlF@O3UgPV/IUOTBfl5Ouud055/qkCu/TmYf9SnOPncxKacJvXDOVvP1Qi4j1k/Vbv/Ny427FQ7Pi52@BvrqiVfOHJYqUmru60faPoQTihdvoI/oeVfaY5Fkm3u4rbP4Ky9KMiMXi@iPRuTtRiiZEupF1G7pynk/xMUZZQPIFs7qFFco8iGS3WgI0bIbBRBF3Sg0fSA6AjpHdAx0jejEdIv9XNMpxsZ7iXGjfLWsLFUPI/uzvOH2T9m1hGggu5YQ@RJZAh1KZAk0kMgSaCiRJdCRRJJAxxI5Ap2Y9rCPK58WwYTGdvE0iEZXj8xK8oIcbUX00rUb10@rfVZyMW1Kz0WqKn60ibJJwo9CWFaLKBWPxc3s/y2ufwE "Python 3 – Try It Online"
#3: Post edited
# [Python 3], 101 bytes- First answer!
- <!-- language-all: lang-python -->
lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12%12)+1}"+'BA'['i'in s][Try it online!][TIO-kjgsevaf]- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsevaf]: https://tio.run/##hZI9b4MwEIZ3foVlqbLdQAQhkA8pg8nX1KljmoEqQaEJJgKGVlF@O3UgPV/IUOTBfl5Ouud055/qkCu/TmYf9SnOPncxKacJvXDOVvP1Qi4j1k/Vbv/Ny427FQ7Pi52@BvrqiVfOHJYqUmru60faPoQTihdvoI/oeVfaY5Fkm3u4rbP4Ky9KMiMXi@iPRuTtRiiZEupF1G7pynk/xMUZZQPIFs7qFFco8iGS3WgI0bIbBRBF3Sg0fSA6AjpHdAx0jejEdIv9XNMpxsZ7iXGjfLWsLFUPI/uzvOH2T9m1hGggu5YQ@RJZAh1KZAk0kMgSaCiRJdCRRJJAxxI5Ap2Y9rCPK58WwYTGdvE0iEZXj8xK8oIcbUX00rUb10@rfVZyMW1Kz0WqKn60ibJJwo9CWFaLKBWPxc3s/y2ufwE "Python 3 – Try It Online"
- # [Python 3], 98 bytes
- First answer!
- <!-- language-all: lang-python -->
- lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12)+1}"+'BA'['i'in s]
- [Try it online!][TIO-kjgsm0bj]
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsm0bj]: https://tio.run/##hZJNb4IwGIDv/IqmyUI7wQgofiQeioqnnXZ0HliQyJBigMMW429nFdzbVzyMU/s8NHmfpuef@lhIr0mWH80pyj/jiFSLhF4YM8PVdi02gTlMZXz4ZtVutOc2K8pYLSdq6fBXZtpmKkmluKc2abfhts9fHJcPnCsdmIEwd3ezb/LoqygrsiQXg6iPBuTtRihZEOoE1OpoaL8fo/KMnAtubYenqEbKAyX6agxq01cTUEFf@XoORKdAV4jOgG4Rnetpcd9IT4qx7t5g3CZfDSNP5cOV/VXecPen6FeCckW/EpQnUCXQsUCVQCcCVQL1BaoEOhUoEuhMoEagcz0e7hmJp4egpa5dP11Em6uuzEiKkmSWJOrRdS9umNaHvGJ80R49l6msWWYRaZGEZZwbRoco5Y@H27v/93DzCw "Python 3 – Try It Online"
- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
- # Python 3.9, 95 bytes:
- lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*(m:='i'in s))-6)%12)+1}"+'BA'[m]
- Isn't the walrus operator great?
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsevaf]: https://tio.run/##hZI9b4MwEIZ3foVlqbLdQAQhkA8pg8nX1KljmoEqQaEJJgKGVlF@O3UgPV/IUOTBfl5Ouud055/qkCu/TmYf9SnOPncxKacJvXDOVvP1Qi4j1k/Vbv/Ny427FQ7Pi52@BvrqiVfOHJYqUmru60faPoQTihdvoI/oeVfaY5Fkm3u4rbP4Ky9KMiMXi@iPRuTtRiiZEupF1G7pynk/xMUZZQPIFs7qFFco8iGS3WgI0bIbBRBF3Sg0fSA6AjpHdAx0jejEdIv9XNMpxsZ7iXGjfLWsLFUPI/uzvOH2T9m1hGggu5YQ@RJZAh1KZAk0kMgSaCiRJdCRRJJAxxI5Ap2Y9rCPK58WwYTGdvE0iEZXj8xK8oIcbUX00rUb10@rfVZyMW1Kz0WqKn60ibJJwo9CWFaLKBWPxc3s/y2ufwE "Python 3 – Try It Online"
#2: Post edited
# Python, 101 bytes- First answer!
- lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12%12)+1}"+'BA'['i'in s]
- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
- # [Python 3], 101 bytes
- First answer!
- <!-- language-all: lang-python -->
- lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12%12)+1}"+'BA'['i'in s]
- [Try it online!][TIO-kjgsevaf]
- Readable version:
- ```
- def f(s):
- n="FCGDAEB".index(s[0])-6
- if '-' in s:
- n -= ord(s[5]-1)
- if 'i' in s:
- n -= 3
- return f"{(n%12)+1}"+'BA'['i'in s]
- ```
- [Python 3]: https://docs.python.org/3/
- [TIO-kjgsevaf]: https://tio.run/##hZI9b4MwEIZ3foVlqbLdQAQhkA8pg8nX1KljmoEqQaEJJgKGVlF@O3UgPV/IUOTBfl5Ouud055/qkCu/TmYf9SnOPncxKacJvXDOVvP1Qi4j1k/Vbv/Ny427FQ7Pi52@BvrqiVfOHJYqUmru60faPoQTihdvoI/oeVfaY5Fkm3u4rbP4Ky9KMiMXi@iPRuTtRiiZEupF1G7pynk/xMUZZQPIFs7qFFco8iGS3WgI0bIbBRBF3Sg0fSA6AjpHdAx0jejEdIv9XNMpxsZ7iXGjfLWsLFUPI/uzvOH2T9m1hGggu5YQ@RJZAh1KZAk0kMgSaCiRJdCRRJJAxxI5Ap2Y9rCPK58WwYTGdvE0iEZXj8xK8oIcbUX00rUb10@rfVZyMW1Kz0WqKn60ibJJwo9CWFaLKBWPxc3s/y2ufwE "Python 3 – Try It Online"
#1: Initial revision
# Python, 101 bytes First answer! lambda s:f"{(('FCGDAEB'.index(s[0])-(ord(s[5])-1)*('-'in s)-(3*('i'in s))-6)%12%12)+1}"+'BA'['i'in s] Readable version: ``` def f(s): n="FCGDAEB".index(s[0])-6 if '-' in s: n -= ord(s[5]-1) if 'i' in s: n -= 3 return f"{(n%12)+1}"+'BA'['i'in s] ```