{"id":10854,"date":"2014-11-08T16:25:29","date_gmt":"2014-11-08T21:25:29","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/ccpg1001\/?p=10854"},"modified":"2026-04-05T18:19:42","modified_gmt":"2026-04-05T23:19:42","slug":"s3eva2010ti_t2-funciones-ocupados-y-ubica-libre-en-matriz","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s3eva10\/s3eva2010ti_t2-funciones-ocupados-y-ubica-libre-en-matriz\/","title":{"rendered":"s3Eva2010TI_T2 Funciones ocupados y ubica libre en matriz"},"content":{"rendered":"\n<p><strong>Ejercicio<\/strong>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-3eva10\/3eva2010ti_t2-funciones-ocupados-y-ubica-libre-en-matriz\/\" data-type=\"post\" data-id=\"2603\">3Eva2010TI_T2 Funciones ocupados y ubica libre en matriz<\/a><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>&nbsp;<\/td><td>ventana<\/td><td>pasillo<\/td><td>&nbsp;<\/td><td>pasillo<\/td><td>ventana<\/td><\/tr><tr><th>&nbsp;<\/th><th>1<\/th><th>2<\/th><th>...<\/th><th>3<\/th><th>m=4<\/th><\/tr><tr><th>Fila 1<\/th><td>0<\/td><td>0<\/td><td>&nbsp;<\/td><td>0<\/td><td>0<\/td><\/tr><tr><th>2<\/th><td>0<\/td><td>0<\/td><td>&nbsp;<\/td><td>0<\/td><td>0<\/td><\/tr><tr><th>3<\/th><td>0<\/td><td>0<\/td><td>&nbsp;<\/td><td>0<\/td><td>1<\/td><\/tr><tr><th>4<\/th><td>0<\/td><td>1<\/td><td>&nbsp;<\/td><td>0<\/td><td>0<\/td><\/tr><tr><th>...<\/th><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><td>&nbsp;<\/td><\/tr><tr><th>19<\/th><td>0<\/td><td>0<\/td><td>&nbsp;<\/td><td>0<\/td><td>0<\/td><\/tr><tr><th>n=20<\/th><td>0<\/td><td>0<\/td><td>&nbsp;<\/td><td>0<\/td><td>0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>resultado obtenido:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>matriz = &#091;&#091;1,1,1,1],\n          &#091;1,0,0,0],\n          &#091;0,1,0,1]]\n\nocupados:  7\nprimer encontrado:  &#091;1, 1]\n&gt;&gt;&gt; <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Algoritmo en Python<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# 3Eva_IT2010_T2 Funciones ocupados y ubica libre en matriz\n# resolver sin usar numpy\nimport numpy as np\n\ndef ocupados(matriz):\n    suma = np.sum(matriz)\n    return(suma)\n\ndef ubicalibre(matriz):\n    matriz = np.array(matriz)\n    tamano = np.shape(matriz)\n    n = tamano&#x5B;0]\n    m = tamano&#x5B;1]\n    encontre = 0\n    a = np.NaN\n    b = np.NaN\n    i = 0\n    while i&lt;n and encontre==0:\n        j = 0\n        while j&lt;m and encontre ==0:\n            if matriz&#x5B;i,j] == 0:\n                encontre = 1\n                a = i\n                b = j\n            j = j+1\n        i = i + 1\n    return(&#x5B;a,b])\n\n# PROGRAMA\nmatriz = &#x5B;&#x5B;1,1,1,1],\n          &#x5B;1,0,0,0],\n          &#x5B;0,1,0,1]]\n\n# PROCEDIMIENTO\naforo = ocupados(matriz)\nlibre = ubicalibre(matriz)\n\n# SALIDA\nprint(&quot;ocupados: &quot;, aforo)\nprint('primer encontrado: ',libre)\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 3Eva2010TI_T2 Funciones ocupados y ubica libre en matriz &nbsp; ventana pasillo &nbsp; pasillo ventana &nbsp; 1 2 ... 3 m=4 Fila 1 0 0 &nbsp; 0 0 2 0 0 &nbsp; 0 0 3 0 0 &nbsp; 0 1 4 0 1 &nbsp; 0 0 ... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 19 0 0 [&hellip;]<\/p>\n","protected":false},"author":8043,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"wp-custom-template-entrada-fp-ejemplos","format":"standard","meta":{"footnotes":""},"categories":[138],"tags":[58,157],"class_list":["post-10854","post","type-post","status-publish","format-standard","hentry","category-fp-s3eva10","tag-ejemplos-python","tag-fundamentos-programacion"],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/10854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/users\/8043"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/comments?post=10854"}],"version-history":[{"count":5,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/10854\/revisions"}],"predecessor-version":[{"id":23717,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/10854\/revisions\/23717"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=10854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=10854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=10854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}