My Coding Quiz #62

My Coding Quiz #62 👨‍💻🛠️🧩

Welcome to the new installment of my series of Coding Quizzes, in which you will be able to test your knowledge and skills about programming and software development in a simple and fun way. If you want to learn more about it visit my blog here on Hive and the first post where I introduced it.

Without further ado, here's the riddle...




Quiz
By @eniolw


What's your choice?

Solution to the previous quiz: None of the above The original script has a syntax error: match is undefined; we should use the m object instead. If we fix line 6 to a, b, c = m(f1), m(f2), m(f3), you will notice that all variables return None.

Why? These strings use the FEN format to represent chess positions. The expression re.compile(r'([KQBNRPkqbnrp ]{8}/){8}$').match attempts to validate a piece layout, but it fails for two reasons:

f1 and f3 include metadata at the end (such as w - - 2 60), while the $ symbol in the RegExp prohibits any additional text.

f2 fails because the RegExp looks for literal spaces and does not recognize the number 8, which represents an empty rank in FEN. Additionally, it lacks the trailing forward slash that the pattern requires.

Do you dare to fix it? You will need to master both RegExp and the specifics of FEN notation.


If you want to blog about computer science and programming content, I invite you to join Hive and participate in its communities, such as STEM-social, Develop Spanish, Programming & Dev and others.


Mi Quiz de Programación #62 👨‍💻🛠️🧩

Bienvenido a mi nueva serie de Quizzes de Programación, en la cual podrás poner a prueba tus conocimientos y habilidades sobre programación y desarrollo de software de una manera sencilla y divertida. Si quieres aprender más sobre ella visita mi blog aquí en Hive y el primer post donde la presenté.

Sin más preámbulos, he aquí el acertijo...




Quiz
Por @eniolw


¿Cuál es tu elección?

Solución al quiz anterior: Ninguna de las anteriores El script original tiene un error de sintaxis: match no está definido, deberíamos usar el objeto m. Si corregimos la línea 6 a a, b, c = m(f1), m(f2), m(f3), notarás que todas las variables devuelven None.

¿Por qué? Estas cadenas usan el formato FEN para representar posiciones de ajedrez. La expresión re.compile(r'([KQBNRPkqbnrp ]{8}/){8}$').match intenta validar una disposición de piezas, pero falla por dos razones:

f1 y f3 incluyen metadatos al final (como w - - 2 60), mientras que el símbolo $ de la RegExp prohíbe cualquier texto extra.

f2 falla porque la RegExp busca espacios literales y no reconoce el número 8, que en FEN representa una fila vacía. Además, falta la barra diagonal final que el patrón exige.

¿Te atreves a arreglarlo? Necesitarás dominar tanto RegExp como los detalles de la notación FEN.


Si quieres bloguear sobre contenido informático y de programación, te invito a unirte a Hive y participar en sus comunidades, tales como STEM-social, Develop Spanish, Programming & Dev y otras.



0
0
0.000
1 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

Consider setting @stemsocial as a beneficiary of this post's rewards if you would like to support the community and contribute to its mission of promoting science and education on Hive. 
 

0
0
0.000