My Coding Quiz #62

Words
501
Reading
3 min
Listen
Play
8M

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

My Coding Quiz #62 | Ecency