My Coding Quiz #41 馃懆鈥嶐煉火煕狅笍馃З
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...

By @eniolw
What's your choice?
Solution to the previous quiz: True False. Line 1 imports the standard requests
module and for simplicity assigns it the alias re
. The fact that there is a re
module to work with regular expressions is irrelevant as long as we don't import both in the same file.
Then lines 2-5 define four strings: user
, ap
, cat
and dom
. Programmers familiar with the Hive blogging blockchain will recognise these variables as the author, permlink and category of a post, and also the domain name hive.blog.
In lines 6-9, these variables are concatenated to form four distinct URLs:
https://hive.blog/hive-133987/@arcange/hive-finance-20240117-en
(post path with category defined).https://hive.blog/@arcange/hive-finance-20240117-en
(post path without category)'https://hive.blog/hive-133987/@arcange/hive-finance-20240117-en.json
(post path with category defined, but in JSON format).https://hive.blog/@arcange/hive-finance-20240117-en.json
(post path without category, but in JSON format).
In the same lines we use requests.get
functions to make HTTP requests to these URLs and store the responses in variables p1
, p2
, p3
and p4
.
In lines 10 and 11, the status codes of the responses are checked, indicating whether the requests were successful or not. You would expect all responses to have the code 200, which means "OK". However, at the time of this exercise, the value of s1
was [True, True] and s2
was [True, False]. This means that the URL https://hive.blog/@arcange/hive-finance-20240117-en.json
returned the code 404, which means "Not Found".
This suggests that the application that manages Hive routes, called Condenser, is not processing this URL correctly, probably because this route is not defined. The curious thing is that this URL is similar to that of p2
, which does return the 200 code. In other words, the page of the uncategorized post can be accessed, but not its JSON version. It would be interesting to know if the Condenser developers have a reason for this.
As for the output of the script, it is True False, because the all
function returns False if any of the elements in the list is False, as is the case with the s2
list.
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 #41 馃懆鈥嶐煉火煕狅笍馃З
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...

Por @eniolw
驴Cu谩l es tu elecci贸n?
Soluci贸n al quiz anterior: True False. La l铆nea 1 importa el m贸dulo est谩ndar requests y para simplificar le asigna el alias "re". El que exista un m贸dulo re para trabajar con Expresiones regulares es irrelevante siempre que no importemos los dos en el mismo archivo.
Luego las lineas 2-5 definen cuatro strings: user, ap, cat y dom. Los programadores familiarizados con la blockchain de blogging Hive reconocer谩n que estas variables se tratan del autor, permlink y categor铆a de un post, y tambi茅n el nombre de dominio hive.blog.
En las l铆neas 6-9, se concatenan estas variables para formar cuatro URL distintas:
'https://hive.blog/hive-133987/@arcange/hive-finance-20240117-en' (ruta de post con categor铆a definida).
'https://hive.blog/@arcange/hive-finance-20240117-en' (ruta de post sin categor铆a)
'https://hive.blog/hive-133987/@arcange/hive-finance-20240117-en.json' (ruta de post con categor铆a definida, pero en formato JSON).
'https://hive.blog/@arcange/hive-finance-20240117-en.json' (ruta de post sin categor铆a, pero en formato JSON).
En las mismas lineas se usan las funciones requests.get para hacer peticiones HTTP a estas URL y se guardan las respuestas en las variables p1, p2, p3 y p4.
En las l铆neas 10 y 11, se comprueban los c贸digos de estado de las respuestas, que indican si las peticiones fueron exitosas o no. Se esperar铆a que todas las respuestas tuvieran el c贸digo 200, que significa "OK". Sin embargo, al momento de hacer este ejercicio, el valor de s1 era [True, True] y el de s2 era [True, False]. Esto significa que la URL https://hive.blog/@arcange/hive-finance-20240117-en.json devolvi贸 el c贸digo 404, que significa "No encontrado".
Esto sugiere que la aplicaci贸n que gestiona las rutas de Hive, llamada Condenser, no est谩 procesando correctamente esta URL, probablemente porque esa ruta no est茅 definida. Lo curioso es que esta URL es similar a la de p2, que s铆 devuelve el c贸digo 200, es decir, se puede acceder a la p谩gina de del post sin categor铆a, pero no a su versi贸n JSON. Ser铆a interesante saber si los desarrolladores de Condenser tienen alguna raz贸n para esto.
En cuanto a la salida del script, es True False, porque la funci贸n all devuelve False si alguno de los elementos de la lista es Falso, como ocurre con la lista s2.
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.