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.
Solution to the previous quiz: {'Sicilian', 'Caro Kann'} These are names of chess openings. We see that in the script we define two variables that are really sets: Karpov and Kasparov. Both sets have two string elements each, with the name of chess openings as we said.
The fun fact is revealed by obtaining the variable what with what = Karpov ^ Kasparov. What value will take what? Well, the operator ^ applied to sets represents the asymmetric difference operation, that is, the set of elements that are in one of the sets, but not in both. These would be the unique elements.
In our example, both Karpov and Kasparov have in common the Queen's Gambit opening, but not so with the Caro Kann and the Sicilian, so the latter integrate the new set obtained. Did you know this set operation? It is incredibly useful and any trained computer scientist should know it.
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.
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茅.
Soluci贸n al quiz anterior: {'Sicilian', 'Caro Kann'}. Estos son nombres de aperturas de ajedrez. Vemos que en el script definimos dos variables que realmente son conjuntos: Karpov y Kasparov. Ambos conjuntos tienen dos elementos string cada uno, con el nombre de aperturas de ajedrez como dec铆amos.
El dato curioso se revela al obtener la variable what con what = Karpov ^ Kasparov. 驴Qu茅 valor tomar谩 what? Bueno, el operador ^ aplicado a conjuntos representa la operaci贸n de diferencia asim茅trica, es decir, el conjunto de elementos que est谩n en uno de los conjuntos, pero no en ambos. Estos ser铆an los elementos 煤nicos.
En nuestro ejemplo, tanto Karpov como Kasparov tienen en com煤n la apertura del Gambito de Dama (Queen's Gambit), pero no as铆 con la Caro Kann y la Siciliana (Sicilian), por lo que estas 煤ltimas integran el nuevo conjunto obtenido. 驴Conoc铆as esta operaci贸n sobre conjuntos? Es incre铆blemente 煤til y cualquier inform谩tico capacitado deber铆a saberlo.
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.