<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C0cHQXg8fip7ImA9WhVTFEs.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529</id><updated>2012-02-28T12:30:30.676-08:00</updated><category term="Autómatas" /><category term="Simulación" /><category term="Redes probabilisticas" /><category term="Inteligencia Artificial" /><category term="Clasificación" /><category term="Grafos" /><category term="Algoritmos genéticos" /><category term="Criptografía" /><category term="Fractales" /><category term="Vida artificial" /><title>Divertimentos Informáticos</title><subtitle type="html">Informática recreativa para programadores inquietos</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://divertimentosinformaticos.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default?start-index=6&amp;max-results=5&amp;redirect=false&amp;v=2" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>5</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/DivertimentosInformticos" /><feedburner:info uri="divertimentosinformticos" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>DivertimentosInformticos</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;C0cHQXk7eyp7ImA9WhVTFEs.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529.post-1285160486564533078</id><published>2012-02-28T12:30:00.000-08:00</published><updated>2012-02-28T12:30:30.703-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-28T12:30:30.703-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Criptografía" /><title>¿Cuántas palabras caben en una imagen?</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_GHHAUoQUO-osy3zS4HG3Bqz3qQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_GHHAUoQUO-osy3zS4HG3Bqz3qQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_GHHAUoQUO-osy3zS4HG3Bqz3qQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_GHHAUoQUO-osy3zS4HG3Bqz3qQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-hJrciEwxvbY/T00jIvDC2XI/AAAAAAAAALY/MyEs6z4khDs/s1600/cena.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="163" width="320" src="http://4.bp.blogspot.com/-hJrciEwxvbY/T00jIvDC2XI/AAAAAAAAALY/MyEs6z4khDs/s320/cena.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sofía no suele ser una persona muy expresiva, y difícilmente uno penetra su coraza para poder siquiera atisbar qué es lo que está pensando en cada momento. Ya sé que llegar al trabajo por la mañana temprano no infunde la mayor de las alegrías, pero Sofía parecía tener su propio rito de autoresignación consistente en sentarse tratando de no llamar demasiado la atención, colocarse sus cascos, abrir sus herramientas de trabajo que organizaba siempre de la misma manera en la pantalla de la derecha (era de las pocas programadoras que tenía dos monitores) y en la de la izquierda comenzaba a leer algún artículo o alguna web de noticias hasta que, cuando lo consideraba oportuno, volvía la cabeza al otro monitor y comenzaba a escribir código. El rito debe ser poderoso porque, probablemente es la programadora más brillante de la empresa.&lt;br /&gt;
El caso es que aquella precisa mañana, su rito cambió. En vez de colocarse los cascos y abrir una web, abrió un ejemplar del "Código de Da Vinci" de Dan Brown y se puso a leer. A mí, la verdad, es que ese libro no me entusiasmaba especialmente y puestos a elegir prefiero al Holmes de Conan Doyle o al Hércules Poirot de Agatha Christie. El caso es que no es el tipo de libro que esperaba ver leyendo a Sofía, así que me atreví a preguntar.&lt;br /&gt;
&lt;br /&gt;
¿Qué tal el libro? ¿Te gusta? -pregunté.&lt;br /&gt;
No mucho, pero habla de criptografía y tenía curiosidad. Me ha llamado la atención la parte en la que el protagonista interpreta supuestos mensajes secretos de Da Vinci en su obra de La Última Cena. ¿No es curioso pensar que el pintor podría estar comunicándose con alguien que vive cientos de años después de su muerte?&lt;br /&gt;
Visto así sí que impresiona -dije- pero supongo que es lo que buscan todos los pintores al pintar un cuadro ¿no?&lt;br /&gt;
Si, pero imagina poder esconder información oculta en la obra y que pase desapercibida para el público general, pero no para el receptor del mensaje.&lt;br /&gt;
Pues sería muy interesante, pero sería más fácil enviarle una carta con algún código cifrado.&lt;br /&gt;
Si, pero si alguien la intercepta tiene ya una información valiosa: El emisor quiere enviar un mensaje secreto al receptor. Eso de por sí es ya una información útil para el enemigo. Se trata, pues, de enviar el mensaje sin levantar sospechas. Hoy en día lo tenemos bastante fácil con las imágenes digitales, ya no hay que pintar un cuadro. Hay una técnica detrás de este tipo de ocultación de la información llamada Esteganografía.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Te refieres a que se pueden almacenar datos en las cabeceras de los archivos de imágenes ¿no? en fin, eso no parece muy seguro -traté de parecer inteligente haciendo mis propias deducciones.&lt;br /&gt;
Para nada Alberto, te equivocas. Hablo de guardar información en la propia información de la imagen, en los píxeles que la componen.&lt;br /&gt;
Sofía me observó unos segundo como esperando a que cayera en la cuenta de cómo podía hacerse tal cosa, como si fuera evidente, pero por enésima vez vio defraudadas sus expectativas sobre mis capacidades.&lt;br /&gt;
Verás -prosiguió- una imagen digital de ordenador está compuesta por una cabecera, como tú bien dices, en la que se almacena información específica del formato en la que se almacena. La cabecera de una imagen JPG es diferente a la cabecera de una imagen PNG o GIF, por ejemplo. Tras la cabecera están los datos de la imagen propiamente dichos. Una imagen está compuesta por muchos píxeles, y cada pixel tiene un color. Pues bien, la clave está en cómo se almacena el color de cada pixel. El formato más común (aunque no el único) es codificar el color usando tres bytes (24 bits) en el que cada byte representa el nivel de cada componente de color (a saber: rojo, verde y azul).&lt;br /&gt;
Por ejemplo, un componente alto de rojo y verde, y un componente bajo de azul daría lugar al color amarillo. Podríamos codificarlo como Rojo:255, Verde:255, Azul:0. Recordemos que un byte (8 bits) pueden representar un rango de valores que va del 0 al 255 (sin signo).&lt;br /&gt;
En un archivo gráfico, generalmente los pixeles se almacenan como secuencias de tres bytes en formato RRVVAA (o RRGGBB de red, Green y Blue).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-gwoOORcx3po/T00SrUkRsRI/AAAAAAAAAKo/pGdFpwVfpjA/s1600/pixelrgb.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="197" width="199" src="http://2.bp.blogspot.com/-gwoOORcx3po/T00SrUkRsRI/AAAAAAAAAKo/pGdFpwVfpjA/s320/pixelrgb.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Vale, esto más o menos lo entiendo, pero no llego a comprender cómo puedo almacenar algo en un pixel. Para el color se usan los 24 bits y no queda ninguno sin usar donde almacenar nada sin que se vea modificado el color en sí.&lt;br /&gt;
&lt;br /&gt;
Touché querido Watson, de eso precisamente se trata: de cambiar el color del pixel, pero tan ligeramente que el ojo humano sea incapaz de notar la diferencia. De hecho Alberto, ¿eres capaz de notar alguna diferencia de color entre los dos siguientes rectángulos de color rojo? (Sofía me mostró los cuadros en su pantalla).&lt;br /&gt;
&lt;br /&gt;
&lt;table border="0" align="center"&gt;&lt;td width="50px" bgcolor="#FF0000"&gt;&lt;/td&gt;&lt;td width="50px" bgcolor="#FE0000"&gt;&lt;br /&gt;
&lt;/br&gt;&lt;br /&gt;
&lt;/table&gt;&lt;br /&gt;
Por más que me esforcé no fui capaz de ver diferencia alguna, así que me aventuré a decir: Son iguales.&lt;br /&gt;
&lt;br /&gt;
Para nada -rió sofía. El primero tienen una componente roja de 255 (en binario 11111111) y la segunda de 254 (en binario 11111110). Fíjate que sólo hay una diferencia de un bit entre uno y otro color. &lt;br /&gt;
Entonces, si cambio un sólo bit en una componente de color, ¿no notaré la diferencia? -de nuevo traté de parecerme más a Holmes que a Watson. &lt;br /&gt;
No, si cambio el primer bit (01111111), por ejemplo, mira lo que pasa:&lt;br /&gt;
&lt;br /&gt;
&lt;table border="0" align="center"&gt;&lt;td width="50px" bgcolor="#FF0000"&gt;&lt;/td&gt;&lt;td width="50px" bgcolor="#7F0000"&gt;&lt;br /&gt;
&lt;/br&gt;&lt;br /&gt;
&lt;/table&gt;&lt;br /&gt;
Ahora, la componente roja pasa a ser 127, que dista bastante del 255 original. Por lo tanto, si queremos que el color se mantenga visualmente igual, sólo podemos tocar el bit de más a la derecha, también llamado bit menos significativo.&lt;br /&gt;
&lt;br /&gt;
Ya entiendo -dije. Se trata entonces de codificar la información que queremos ocultar alterando los últimos bits de cada componente de color ¿es así?&lt;br /&gt;
Elemental querido Alberto. Así es. Te pongo un ejemplo. Imagina que quieres esconder un mensaje que empieza por la letra A en una imagen. La letra A tiene el código ASCII 65 (10000001 en binario). Pues bien, necesitamos modificar el último bit de la componente roja del primer bit para que acabe en 1, el de la componente verde para que acabe en 0, y así sucesivamente. Como tenemos 8 bits, cada carácter necesitará tres píxeles (3 pixeles * 3 componentes de color = 9 componentes de color) Es decir, nos sobra un bit que, por mantener las cosas simples, no vamos a modificar.&lt;br /&gt;
El proceso sería pues el siguiente (Sofía garabateó sobre un papel):&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-7LatYHVl3-o/T00bYgCiASI/AAAAAAAAAK0/CEYXVnUBjv4/s1600/transf.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="310" width="320" src="http://4.bp.blogspot.com/-7LatYHVl3-o/T00bYgCiASI/AAAAAAAAAK0/CEYXVnUBjv4/s320/transf.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Sofía rodeó de color rojo los bits que era necesario cambiar y me hizo notar como la componente azul del último pixel no la estábamos usando en el ejemplo, pero que podía usarse sin problema aunque complicaba un poco la programación. También me explicó que debían usarse formatos de archivos con compresión sin pérdidas, ya que formatos como el JPG pueden alterar las componentes de color originales.&lt;br /&gt;
&lt;br /&gt;
Por cierto -continuó Sofía- puede almacenarse información "secreta" en otros tipos de archivos digitales, como vídeo o sonido. De hecho, en el caso del sonido el proceso es muy similar.&lt;br /&gt;
&lt;br /&gt;
Lo cierto es que todo lo que me estaba contando Sofía empezaba a sonarme a buen argumento para una novela, pero como se me da mejor la programación que la literatura, decidí escribir un programa para poner todo en práctica en vez de tratar de hacerle sombra a Dan Brown. Tecleé dos programas, una llamado Encode.java que almacena un texto en una imagen y otro llamado Decode.java que realiza el proceso contrario. Reproduzco aquí los dos programas.&lt;br /&gt;
&lt;br /&gt;
Encode.java&lt;br /&gt;
&lt;br /&gt;
&lt;div class="java5" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0; height:250px; overflow:auto"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.awt.Color&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.awt.image.BufferedImage&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.io.File&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;javax.imageio.ImageIO&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; Encode &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; main&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; args&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;args.&lt;span style="color: #006633;"&gt;length&lt;/span&gt;&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;out&lt;/span&gt;.&lt;span style="color: #006633;"&gt;println&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;Formato: Encode imagen &lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;texto&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;exit&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt; img_in=args&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt; message=args&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; message=message+&lt;span style="color: #0000ff;"&gt;&amp;quot;#&amp;quot;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cargar imagen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/image/BufferedImage.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;BufferedImage&lt;/span&gt;&lt;/a&gt; img = &lt;span style="color: #006600; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img = &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/javax/imageio/ImageIO.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ImageIO&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;read&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/io/File.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;File&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;img_in&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Exception.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Exception&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;message.&lt;span style="color: #006633;"&gt;length&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getHeight&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;/&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;out&lt;/span&gt;.&lt;span style="color: #006633;"&gt;println&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;El mensaje es demasiado grande para la imagen.&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;exit&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// almacenar mensaje&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cada tres pixels un caracter&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; pix_index=&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; chars=&lt;span style="color: #006600; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chars=message.&lt;span style="color: #006633;"&gt;getBytes&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;ASCII&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Exception.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Exception&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i=&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;chars.&lt;span style="color: #006633;"&gt;length&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; j=&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; j&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; j++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; ycoord=&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;pix_index/img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; xcoord=pix_index-&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;ycoord&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; c = img.&lt;span style="color: #006633;"&gt;getRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;xcoord,ycoord&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; red = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x00ff0000&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;16&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; green = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x0000ff00&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; blue = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x000000ff&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;, &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;j&lt;span style="color: #339933;"&gt;*&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;+&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; red |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; red &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;, &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;j&lt;span style="color: #339933;"&gt;*&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;+&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; green |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; green &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;j&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// el ultimo byte no lo usamos&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;, &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;j&lt;span style="color: #339933;"&gt;*&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;+&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; blue |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; blue &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt; color=&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;red, green, blue&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img.&lt;span style="color: #006633;"&gt;setRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;xcoord, ycoord, color.&lt;span style="color: #006633;"&gt;getRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pix_index++&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// guardar imagen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/io/File.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;File&lt;/span&gt;&lt;/a&gt; outputfile = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/io/File.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;File&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;encodedimage.png&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/javax/imageio/ImageIO.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ImageIO&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;write&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;img, &lt;span style="color: #0000ff;"&gt;&amp;quot;png&amp;quot;&lt;/span&gt;, outputfile&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Exception.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Exception&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;static&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Boolean.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Boolean&lt;/span&gt;&lt;/a&gt; isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt; b, &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; bit&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;b &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; bit&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;!&lt;/span&gt;= &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Decode.java&lt;br /&gt;
&lt;br /&gt;
&lt;div class="java5" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0; height:250px; overflow:auto"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.awt.Color&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.awt.image.BufferedImage&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.io.File&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;javax.imageio.ImageIO&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; Decode &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; main&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; args&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;args.&lt;span style="color: #006633;"&gt;length&lt;/span&gt;&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;out&lt;/span&gt;.&lt;span style="color: #006633;"&gt;println&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;Formato: Decode imagen&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;exit&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt; img_in=args&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cargar imagen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/image/BufferedImage.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;BufferedImage&lt;/span&gt;&lt;/a&gt; img = &lt;span style="color: #006600; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img = &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/javax/imageio/ImageIO.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ImageIO&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;read&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/io/File.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;File&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;img_in&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Exception.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Exception&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// obtener mensaje&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i=&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getHeight&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;-&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i=i+&lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;char&lt;/span&gt; car=&lt;span style="color: #0000ff;"&gt;' '&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// primer pixel&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; ycoord=&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;i/img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; xcoord=i-&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;ycoord&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; c = img.&lt;span style="color: #006633;"&gt;getRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;xcoord,ycoord&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; red = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x00ff0000&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;16&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; green = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x0000ff00&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; blue = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x000000ff&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;red,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;green,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;blue,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// segundo pixel&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ycoord=&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;i+&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;/img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xcoord=i+&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;-&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;ycoord&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c = img.&lt;span style="color: #006633;"&gt;getRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;xcoord,ycoord&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; red = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x00ff0000&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;16&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; green = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x0000ff00&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; blue = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x000000ff&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;red,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;green,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;blue,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// tercer pixel&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ycoord=&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;i+&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;/img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xcoord=i+&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;-&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;ycoord&lt;span style="color: #339933;"&gt;*&lt;/span&gt;img.&lt;span style="color: #006633;"&gt;getWidth&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c = img.&lt;span style="color: #006633;"&gt;getRGB&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;xcoord,ycoord&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; red = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x00ff0000&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;16&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; green = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x0000ff00&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; blue = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;c &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; 0x000000ff&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;red,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;green,&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car |= &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; car &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt;= ~&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;car==&lt;span style="color: #0000ff;"&gt;'#'&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;break&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/System.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;out&lt;/span&gt;.&lt;span style="color: #006633;"&gt;print&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;car&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;static&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Boolean.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Boolean&lt;/span&gt;&lt;/a&gt; isBitSet&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;byte&lt;/span&gt; b, &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; bit&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;b &lt;span style="color: #339933;"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt; &lt;span style="color: #339933;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; bit&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;!&lt;/span&gt;= &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Bueno, el código no es especialmente elegante, pero parece que funcionará -dijo Sofía machacando de nuevo mi autoestima. &lt;br /&gt;
Para probar el programa usamos la siguiente imagen de una fotografía de un viaje a Dinamarca que había realizado Sofía.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-vsXecbp49qo/T00gRVCXyMI/AAAAAAAAALA/0qWO9lEU3kE/s1600/dinamarca.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="200" width="320" src="http://4.bp.blogspot.com/-vsXecbp49qo/T00gRVCXyMI/AAAAAAAAALA/0qWO9lEU3kE/s320/dinamarca.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Tras compilar los programas ejecutamos el comando: java Encode dinamarca.jpg "mensaje oculto"&lt;br /&gt;
Obtuvimos la siguiente imagen:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-jKYOiBlKIAQ/T00hYyV9AwI/AAAAAAAAALM/IDidr7q2tTw/s1600/encodedimage.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="200" width="320" src="http://4.bp.blogspot.com/-jKYOiBlKIAQ/T00hYyV9AwI/AAAAAAAAALM/IDidr7q2tTw/s320/encodedimage.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Como ves -dijo Sofía- son indistinguibles la una de la otra.&lt;br /&gt;
Tras ejecutar: java Decode encodedimage.png obtuvimos de nuevo el texto "mensaje oculto".&lt;br /&gt;
&lt;br /&gt;
Bien, se me ocurren algunas utilidades para este programa -dije.&lt;br /&gt;
Si estas pensando en pasar mensajes ocultos dentro de imágenes a otra empresa para ganarte un sobresueldo, tendrás que refinar un poco el método, ya que, aunque codificada en la imagen, el texto no está encriptado y si alguien sospecha que hay un mensaje oculto será fácil obtenerlo. Aunque si lo que quieres es que Gaznápiro no los intercepte, creo que ni en mil años sería capaz.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5373432823372546529-1285160486564533078?l=divertimentosinformaticos.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DivertimentosInformticos/~4/5hSaA6Z1W_U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/1285160486564533078/comments/default" title="Enviar comentarios" /><link rel="replies" type="text/html" href="http://divertimentosinformaticos.blogspot.com/2012/02/cuantas-palabras-caben-en-una-imagen.html#comment-form" title="0 comentarios" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/1285160486564533078?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/1285160486564533078?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DivertimentosInformticos/~3/5hSaA6Z1W_U/cuantas-palabras-caben-en-una-imagen.html" title="¿Cuántas palabras caben en una imagen?" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-hJrciEwxvbY/T00jIvDC2XI/AAAAAAAAALY/MyEs6z4khDs/s72-c/cena.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://divertimentosinformaticos.blogspot.com/2012/02/cuantas-palabras-caben-en-una-imagen.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YHQHkycCp7ImA9WhRUFkQ.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529.post-57599570500456770</id><published>2012-01-22T12:04:00.000-08:00</published><updated>2012-01-27T11:05:31.798-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-27T11:05:31.798-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Simulación" /><title>De la cola del cine a la danza estelar</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/U0A9g3w6UflkJRxnwNfx2GM56_E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U0A9g3w6UflkJRxnwNfx2GM56_E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/U0A9g3w6UflkJRxnwNfx2GM56_E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/U0A9g3w6UflkJRxnwNfx2GM56_E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-6v2jS9QVPYw/TxxKSdWWvfI/AAAAAAAAAJM/xmCNweGoqOQ/s1600/dinamico.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="320" width="320" src="http://2.bp.blogspot.com/-6v2jS9QVPYw/TxxKSdWWvfI/AAAAAAAAAJM/xmCNweGoqOQ/s320/dinamico.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Llevabamos ya casi media hora en la cola y aquello parecía no avanzar, lo que para ser un jueves por la tarde era bastante poco corriente. Mi amigo Descollante y yo solemos ir al cine este día porque suele haber poca afluencia, sin embargo, hoy la cosa estaba imposible.&lt;br /&gt;
&lt;br /&gt;
Para la próxima sacamos la entrada por Internet -dije- aunque haya que pagar algo más. No entiendo como puede haber tanta gente hoy y el Jueves pasado estuvimos solos.&lt;br /&gt;
&lt;br /&gt;
Pues no hay ningún misterio -dijo Descollante sin ni siquiera volver su mirada- los grupos de personas se comportan como sistemas dinámicos. No hay más.&lt;br /&gt;
&lt;br /&gt;
Como era habitual, Descollante, que no distingue una pregunta retórica de otra real, se disponía a buscarle una explicación racional a un hecho que nadie más que él se atrevería a analizar seriamente, así que tenía dos opciones: callarme y seguir disfrutando de la cola, o hacer como si me interesara su comentario y enfrentarme a una disertación que no estaba seguro de querer escuchar. Por desgracia mi maldita manía de empatizar hasta con las piedras me hizo pronunciar dos fatídicas palabras: ¿sistemas dinámicos?&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Así que Descollante se animó: Sí, la dinámica de sistemas trata de explicar el comportamiento de sistemas complejos que evolucionan a través del tiempo. El comportamiento de las masas se asemeja a un sistema dinámico, ya que la forma de actuar de un grupo grande de personas a menudo no puede entenderse a partir del comportamiento de cada individuo por separado.&lt;br /&gt;
&lt;br /&gt;
¿No irás a decirme que esta cola podríamos haberla predecido? Porque si es así nos forramos prediciendo el comportamiento de las masas.&lt;br /&gt;
&lt;br /&gt;
Tú siempre pensando en el dinero -rió mi amigo. De hecho no creo, ya que hablamos de lo que los matemáticos llaman sistemas no lineales: sistemas cuyo comportamiento global no puede expresarse como la suma de los comportamientos individuales.&lt;br /&gt;
&lt;br /&gt;
Descollante, estoy seguro de que lo que me estás contando sería muy interesante si fuera capaz de comprender algo, pero no termino de entender a dónde quieres llegar.&lt;br /&gt;
&lt;br /&gt;
Está bien, Alberto, te pondré un ejemplo más simple. ¿Recuerdas del instituto cómo se calcula la fuerza gravitatoria ejercida entre dos cuerpos?&lt;br /&gt;
Si -respondí- era algo así como que la fuerza es directamente proporcional al producto de sus masas e inversamente proporcional al cuadrado de su distancia.&lt;br /&gt;
Exacto -dijo Descollante mientras dábamos el par de pasos que había avanzado la cola- y esa formulita te permite calcular fácilmente cosas como la órbita que describirá un cuerpo alrededor del otro. Sin embargo, si añadimos un tercer cuerpo, tenemos un problema ya que lo convertimos en un sistema no lineal y describir analíticamente sus órbitas es una tarea tremendamente compleja con las matemáticas de las que disponemos. De hecho, se transforma en un sistema caótico donde empiezan a mandar las leyes de la teoría del caos.&lt;br /&gt;
&lt;br /&gt;
Ahora sí que estaba desconcertado ya que aquello no tenía demasiado sentido para mí, así que no pude callarme: pero si no podemos calcular la trayectoria de sólo tres cuerpos, ¿cómo calculan los astrónomos la evolución de un cúmulo estelar o incluso de toda una galaxia?&lt;br /&gt;
&lt;br /&gt;
Descollante me miró casi perdonandome la vida: he dicho que no podemos calcularlo analíticamente, pero disponemos de una herramienta maravillosa, la simulación por ordenador.&lt;br /&gt;
&lt;br /&gt;
Aquello ya empezaba a gustarme más, habiendo un ordenador de por medio siempre me siento más cómodo. Así, entre teoría del caos por aquí y problemas no lineales por allá logramos entrar en el cine y ver la peli. Ya de regreso a casa de Descollante nos sentamos ante el ordenador porque quería mostrarme cómo hacer la simulación de un sistema complejo como un cúmulo estelar.&lt;br /&gt;
&lt;br /&gt;
Verás Alberto, para representar cada estrella en el ordenador almacenaremos su posición en el espacio como una coordenada tridimensional X,Y,Z. Necesitamos también almacenar su velocidad y su aceleración como vector tridimensional. La idea es que todas las estrellas ejercen una fuerza entre sí. Como hay muchas estrellas, la fuerza resultante ejercida sobre una estrella es la suma de todas las fuerzas que actúan sobre ella. Como sabes F=G(m1*m2)/d, siendo la distancia d=sqrt(x1-x2*y1-y2*z1-z2). En realidad, como bien me dijiste antes hay que utilizar el cuadrado de la distancia, pero para la simulación vamos a utilizar directamente la distancia ya que buscamos también un efecto estético en la animación del movimiento de las estrellas. Tampoco vamos a meter de por medio a la constante G, la dejaremos descansar hoy. Desde luego, si fuéramos astrofísicos tratando de hacer cálculos exactos sí que tendríamos que tener todo esto en cuenta.&lt;br /&gt;
Conocida la fuerza, podemos calcular la aceleración que sufre la estrella en cada eje de coordenadas:&lt;br /&gt;
&lt;br /&gt;
aceleración_x=F*(posición_x2-posición_x1)/d&lt;br /&gt;
&lt;br /&gt;
Es decir, la aceleración en el eje X es igual al producto de la fuerza por la diferencia entre la posición en el eje X de la otra estrella y la posición X de la estrella sobre la que estamos realizando el cálculo. Todo ello dividido por la distancia. La aceleración total que sufre la estrella es la suma de todas las aceleraciones (una por cada estrella que la rodea). El cálculo en el eje Y y Z es idéntico.&lt;br /&gt;
Ahora que tenemos calculado el resultado de todas las interacciones entre estrellas, sólo nos resta calcular su velocidad sumándole la aceleración calculada en el paso anterior.&lt;br /&gt;
&lt;br /&gt;
velocidad_x = velocidad_x + aceleración_x&lt;br /&gt;
&lt;br /&gt;
Y lo mismo para las otras dos componentes Y y Z.&lt;br /&gt;
Ya sólo tenemos que sumar la velocidad a la posición de la estrella y habremos calculado su movimiento.&lt;br /&gt;
&lt;br /&gt;
posición_x = posición_x + velocidad_x&lt;br /&gt;
&lt;br /&gt;
Y de nuevo repetimos el cálculo para los ejes Y y Z.&lt;br /&gt;
Repitiendo estos cálculos en un bucle y representando cada estrella gráficamente tendremos una simulación animada de un cúmulo estelar.   &lt;br /&gt;
&lt;br /&gt;
Mientras me lo explicaba, Descollante iba tecleando un pequeño programa en Java. Una vez terminó de teclear lo ejecutó y esto es lo que se vio en la pantalla:&lt;br /&gt;
&lt;br /&gt;
&lt;applet code="NewJApplet.class" codebase="http://sites.google.com/site/albgarse/home/files/" archive="SpaceApplet.jar" width="640" height="480"&gt;&lt;/applet&gt;&lt;br /&gt;
&lt;br /&gt;
He creado un campo aleatorio de 25 estrellas -dijo Descollante- pero si quieres más sólo tienes que cambiar el valor de la variable NUM_STARS. Tampoco he simulado la colisión entre estrellas ni nada parecido, ya que simplemente queremos ver visualmente como evoluciona un sistema dinámico.&lt;br /&gt;
Hoy en día, los gobiernos y grandes corporaciones utilizan herramientas de análisis de sistemas dinámicos para predecir comportamientos económicos o incluso sociales.&lt;br /&gt;
Pues no sabes cómo me tranquiliza eso -dije.&lt;br /&gt;
¿Te tranquiliza? dijo sorprendido Descollante.&lt;br /&gt;
Reí pero no dije nada más. Aunque se lo explicara, dudo que Descollante fuera capaz de entender lo que es una frase irónica. &lt;br /&gt;
&lt;br /&gt;
Aquí se reproduce el código que tecleó Descollante:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="java5" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0; height:250px; overflow:auto"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.util.Random&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;java.awt.*&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #006699;"&gt;javax.swing.*&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; SpaceDance &lt;span style="color: #000000; font-weight: bold;"&gt;extends&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/javax/swing/JFrame.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;JFrame&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; RES_X = &lt;span style="color: #cc66cc;"&gt;640&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; RES_Y = &lt;span style="color: #cc66cc;"&gt;480&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; SpaceDance&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;super&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;SpaceDance&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; setBounds&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, RES_X, RES_Y&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; setDefaultCloseOperation&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/javax/swing/JFrame.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;JFrame&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;EXIT_ON_CLOSE&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Container.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Container&lt;/span&gt;&lt;/a&gt; con = &lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;.&lt;span style="color: #006633;"&gt;getContentPane&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; con.&lt;span style="color: #006633;"&gt;setBackground&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;black&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; GCanvas canvas = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; GCanvas&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; con.&lt;span style="color: #006633;"&gt;add&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;canvas&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; setVisible&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; main&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/String.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; args&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; SpaceDance&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; Star &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; posx, posy, posz&lt;span style="color: #339933;"&gt;;&lt;/span&gt; &lt;span style="color: #666666; font-style: italic;"&gt;// posición&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;double&lt;/span&gt; spdx, spdy, spdz&lt;span style="color: #339933;"&gt;;&lt;/span&gt; &lt;span style="color: #666666; font-style: italic;"&gt;// velocidad&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;double&lt;/span&gt; accx, accy, accz&lt;span style="color: #339933;"&gt;;&lt;/span&gt; &lt;span style="color: #666666; font-style: italic;"&gt;// aceleración&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;double&lt;/span&gt; mass&lt;span style="color: #339933;"&gt;;&lt;/span&gt; &lt;span style="color: #666666; font-style: italic;"&gt;// masa&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; GCanvas &lt;span style="color: #000000; font-weight: bold;"&gt;extends&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Canvas.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Canvas&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;implements&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Runnable.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Runnable&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; RES_X = &lt;span style="color: #cc66cc;"&gt;640&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; RES_Y = &lt;span style="color: #cc66cc;"&gt;480&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; NUM_STARS = &lt;span style="color: #cc66cc;"&gt;25&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; tiempo_pausa = &lt;span style="color: #cc66cc;"&gt;100&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; Star&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; stars = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; Star&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;NUM_STARS&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Thread.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt; t&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; GCanvas&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; t = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Thread.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; t.&lt;span style="color: #006633;"&gt;start&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; @&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Override.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Override&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; paint&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Graphics.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Graphics&lt;/span&gt;&lt;/a&gt; g&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// dibujar las estrellas&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;setColor&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;black&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;fillRect&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, RES_X, RES_Y&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #339933;"&gt;!&lt;/span&gt;= &lt;span style="color: #006600; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; tam = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;mass&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;tam &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;setColor&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;white&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;tam &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;setColor&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;yellow&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;tam &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;setColor&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;blue&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;setColor&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/awt/Color.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Color&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;red&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g.&lt;span style="color: #006633;"&gt;fillOval&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt;, stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt;, tam, tam&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; initStars&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// inicializar estrellas aleatoriamente&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/util/Random.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Random&lt;/span&gt;&lt;/a&gt; rnd = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/util/Random.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Random&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; Star&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt; = rnd.&lt;span style="color: #006633;"&gt;nextInt&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;RES_X&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt; = rnd.&lt;span style="color: #006633;"&gt;nextInt&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;RES_Y&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt; = rnd.&lt;span style="color: #006633;"&gt;nextInt&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;RES_Y&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accx&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accy&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accz&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;mass&lt;/span&gt; = &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;rnd.&lt;span style="color: #006633;"&gt;nextFloat&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; + &lt;span style="color: #cc66cc;"&gt;0.1&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933;"&gt;*&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; @&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Override.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Override&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #006600; font-weight: bold;"&gt;void&lt;/span&gt; run&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; initStars&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;do&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cálculo de las aceleraciones&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accx&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accy&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accz&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; j = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; j &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; j++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;i &lt;span style="color: #339933;"&gt;!&lt;/span&gt;= j&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; dx = stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; dy = stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; dz = stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// distancia&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;double&lt;/span&gt; d = &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Math.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Math&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;sqrt&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;dx &lt;span style="color: #339933;"&gt;*&lt;/span&gt; dx + dy &lt;span style="color: #339933;"&gt;*&lt;/span&gt; dy + dz &lt;span style="color: #339933;"&gt;*&lt;/span&gt; dz&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;d &lt;span style="color: #339933;"&gt;!&lt;/span&gt;= &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// fuerza&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #006600; font-weight: bold;"&gt;double&lt;/span&gt; f = (stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;mass&lt;/span&gt;*stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;mass&lt;/span&gt;) / d&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// aceleraciÛn&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accx&lt;/span&gt; += f &lt;span style="color: #339933;"&gt;*&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; / d&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accy&lt;/span&gt; += f &lt;span style="color: #339933;"&gt;*&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; / d&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accz&lt;/span&gt; += f &lt;span style="color: #339933;"&gt;*&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;j&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt; - stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; / d&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cálculo de las velocidades&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdx&lt;/span&gt; += stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accx&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdy&lt;/span&gt; += stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accy&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdz&lt;/span&gt; += stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;accz&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #666666; font-style: italic;"&gt;// cálculo de las coordenadas&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i &lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt; NUM_STARS&lt;span style="color: #339933;"&gt;;&lt;/span&gt; i++&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posx&lt;/span&gt; += &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdx&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posy&lt;/span&gt; += &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdy&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;posz&lt;/span&gt; += &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; stars&lt;span style="color: #009900;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: #009900;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;spdz&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; repaint&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/Thread.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Thread&lt;/span&gt;&lt;/a&gt;.&lt;span style="color: #006633;"&gt;sleep&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;tiempo_pausa&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;a style="color: #000060;" href="http://java.sun.com/j2se/1%2E5%2E0/docs/api/java/lang/InterruptedException.html"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;InterruptedException&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; &amp;nbsp;font-weight: bold;"&gt;while&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #006600; font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5373432823372546529-57599570500456770?l=divertimentosinformaticos.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DivertimentosInformticos/~4/Fyvam4KBS8g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/57599570500456770/comments/default" title="Enviar comentarios" /><link rel="replies" type="text/html" href="http://divertimentosinformaticos.blogspot.com/2012/01/de-la-cola-del-cine-la-danza-estelar.html#comment-form" title="0 comentarios" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/57599570500456770?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/57599570500456770?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DivertimentosInformticos/~3/Fyvam4KBS8g/de-la-cola-del-cine-la-danza-estelar.html" title="De la cola del cine a la danza estelar" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-6v2jS9QVPYw/TxxKSdWWvfI/AAAAAAAAAJM/xmCNweGoqOQ/s72-c/dinamico.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://divertimentosinformaticos.blogspot.com/2012/01/de-la-cola-del-cine-la-danza-estelar.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMESH0_cCp7ImA9WhRTFEU.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529.post-5948426682039578385</id><published>2011-11-04T16:35:00.000-07:00</published><updated>2011-11-05T02:46:49.348-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-05T02:46:49.348-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Clasificación" /><title>La máquina predictora de estados de ánimo</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/fgACbD6A3ro-Mord9D_h6LfyhNo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fgACbD6A3ro-Mord9D_h6LfyhNo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/fgACbD6A3ro-Mord9D_h6LfyhNo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fgACbD6A3ro-Mord9D_h6LfyhNo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-gTAqjtcjVs8/Tq2se4SGIkI/AAAAAAAAAIo/t7zPfq_8cH4/s1600/bola-cristal.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="250" width="225" src="http://1.bp.blogspot.com/-gTAqjtcjVs8/Tq2se4SGIkI/AAAAAAAAAIo/t7zPfq_8cH4/s320/bola-cristal.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
No es ningún secreto que un tonto "leal" tiene más posibilidades de ascender en una empresa que un listo librepensador, pero si el tonto, además, disfruta gritando a los demás, sus posibilidades de ascender rozan el 100%. En eso andaba Gaznápiro, entrenando sus mejores gritos con el Sr. Lego dentro de su despacho (su faceta de tonto no necesitaba entrenarla más porque, probablemente, había llegado ya a lo más alto que nadie pueda llegar). Los gritos podían oírse en toda la oficina, entre nasales y con un tono agudo que daban más risa que miedo, y que agudizaban, aún más si cabía, la condición de tonto "leal" que le hace el trabajo sucio al gran jefe.&lt;br /&gt;
El Sr. Lego salió del despacho con la cabeza baja y maldiciendo hasta en arameo antiguo. Sofía, que se sentaba en la mesa contigua a la mía no paraba de anotar cosas en una libreta pequeña de color rojo, de esas de anillas en la parte de arriba. &lt;br /&gt;
¿Qué anotas con tanto interés? -pregunté a Sofía intentando esconder mi curiosidad.&lt;br /&gt;
Anoto el estado de ánimo que tiene Gaznápiro. Lo hago desde hace nueve días. -respondió.&lt;br /&gt;
Me quedé mirandola un rato esperando que me dijera que estaba de broma, pero no lo hizo. En vez de eso, prosiguió contándome detalles.&lt;br /&gt;
Intento encontrar un patrón de comportamento para ver si descubro qué es lo que hace que tenga un día de perros o un día de buen humor. Así sabré cuando pedir un ascenso o un día de vacaciones. Anoto lo que ha desayunado, el color de la corbata, si toma o no café… en fin todo lo que pueda observar lo anoto.&lt;br /&gt;
Lo peor de todo es que, conociendo a Sofía, lo estaba diciéndolo totalmente en serio.&lt;br /&gt;
El Sr. Lego, que andaba pegando el oído preguntó a Sofía si podía decirle qué tal día iba a tener mañana, ya que tocaba reunión de proyecto y andaba algo retrasado con la programación.&lt;br /&gt;
Bueno, -respondió Sofía- desgraciadamente aún no he encontrado ningún patrón.&lt;br /&gt;
Ambos me miraron como esperando que me sacara un as de la manga.&lt;br /&gt;
Venga Alberto, seguro que conoces algún truco para convertir todos estos datos en algo utilizable -dijo el Sr. Lego dándome palmaditas en la espalda y sonriendo como si me hubiera pillado en un renuncio.&lt;br /&gt;
Claro, si la información que ha anotado Sofía es la mitad de precisa de lo que esperaría de ella podemos utilizar un clasificador bayesiano para modelar el comportamiento de Gaznápiro e intentar predecir con qué estado de ánimo llegará mañana a la oficina.&lt;br /&gt;
Ahora eran Sofía y el Sr. Lego los que me miraban a mí como si fuera un bicho raro, lo que me hizo anotar mentalmente: "No volver a mirar a mis compañeros como si se hubieran escapado de un manicomio".&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Usando los datos que había tomado Sofía obtuvimos la siguiente tabla en la que anotamos el color de la corbata, lo que había comido en el desayuno y lo que había bebido. En la última columna anotamos si ese día había estado o no de buen humor.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center"&gt;&lt;tr&gt; &lt;td bgcolor="#CCCCCC"&gt;d&amp;iacute;a&lt;/td&gt;&lt;td bgcolor="#CCCCCC"&gt;Corbata&lt;/td&gt;&lt;td bgcolor="#CCCCCC"&gt;Desayuno&lt;/td&gt;&lt;td bgcolor="#CCCCCC"&gt;Bebida&lt;/td&gt;&lt;td bgcolor="#CCCCCC"&gt;Humor&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;1&lt;/td&gt;&lt;td&gt;Roja&lt;/td&gt;&lt;td&gt;Pan&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Malo&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;2&lt;/td&gt;&lt;td&gt;Roja&lt;/td&gt;&lt;td&gt;Pan&lt;/td&gt;&lt;td&gt;Zumo&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Malo&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;3&lt;/td&gt;&lt;td&gt;Roja&lt;/td&gt;&lt;td&gt;Fruta&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Bueno&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;4&lt;/td&gt;&lt;td&gt;Amarilla&lt;/td&gt;&lt;td&gt;Pan&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Malo&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;5&lt;/td&gt;&lt;td&gt;Amarilla&lt;/td&gt;&lt;td&gt;Fruta&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Bueno&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;6&lt;/td&gt;&lt;td&gt;Azul&lt;/td&gt;&lt;td&gt;Pan&lt;/td&gt;&lt;td&gt;Zumo&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Bueno&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;7&lt;/td&gt;&lt;td&gt;Azul&lt;/td&gt;&lt;td&gt;Fruta&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Malo&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;8&lt;/td&gt;&lt;td&gt;Azul&lt;/td&gt;&lt;td&gt;Fruta&lt;/td&gt;&lt;td&gt;Zumo&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Bueno&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;9&lt;/td&gt;&lt;td&gt;Azul&lt;/td&gt;&lt;td&gt;Pan&lt;/td&gt;&lt;td&gt;Café&lt;/td&gt;&lt;td bgcolor="#EEEEEE"&gt;Malo&lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
Un clasificador bayesiano -comencé a explicar- selecciona la mejor clasificación según los atributos de los que disponemos. En nuestro caso, las clasificaciones posibles son Bueno o Malo, que describen el estado de humor de Gaznápiro. Nuestros atributos son: Corbata, Desayuno y Bebida, que pueden tomar los siguientes valores:&lt;br /&gt;
&lt;br /&gt;
Corbata={Roja | Amarilla | Azul}&lt;br /&gt;
Desayuno={Pan | Fruta}&lt;br /&gt;
Bebida={Café | Zumo}&lt;br /&gt;
&lt;br /&gt;
Espero que recordéis bien el &lt;a href="http://es.wikipedia.org/wiki/Teorema_de_Bayes"&gt;teorema de Bayes&lt;/a&gt;, porque lo que sigue se basa en él. No es por casualidad que se llame clasificador bayesiano.&lt;br /&gt;
&lt;br /&gt;
Nuestro clasificador va a basarse en la siguiente expresión:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-IxEnk6-m_nA/Tq2OVWmHTPI/AAAAAAAAAIQ/QdfrU320l6U/s1600/form1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="56" width="225" src="http://4.bp.blogspot.com/-IxEnk6-m_nA/Tq2OVWmHTPI/AAAAAAAAAIQ/QdfrU320l6U/s320/form1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Como sabéis P(c) es la probabilidad de que ocurra la clasificación c, siendo c={Bueno | Malo}. Por otro lado, P(a&lt;sub&gt;i&lt;/sub&gt;|c) es lo que llamamos probabilidad condicionada de a sabiendo que ocurre c. Por ejemplo, P(Azul|Bueno) es la probabilidad de que Gaznápiro lleve corbata azul sabiendo que hoy tiene buen humor.&lt;br /&gt;
&lt;br /&gt;
Para calcular P(a&lt;sub&gt;i&lt;/sub&gt;|c) vamos a usar la siguiente fórmula:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-YoEPqRm93Nc/Tq2P00nFC_I/AAAAAAAAAIc/VR_l3pOKVGI/s1600/form2.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="51" width="148" src="http://4.bp.blogspot.com/-YoEPqRm93Nc/Tq2P00nFC_I/AAAAAAAAAIc/VR_l3pOKVGI/s320/form2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Donde:&lt;br /&gt;
n es el número total de ocurrencias de la clasificación c.&lt;br /&gt;
n&lt;sub&gt;c&lt;/sub&gt; es el número de ocurrencias de la clasificación c para el atributo a&lt;sub&gt;i&lt;/sub&gt;.&lt;br /&gt;
p es el valor a priori estimado para P(a&lt;sub&gt;i&lt;/sub&gt;|c).&lt;br /&gt;
m es el tamaño de muestra equivalente. &lt;br /&gt;
&lt;br /&gt;
Sofía no quitaba la vista del folio donde andaba garabateando las fórmulas, y el Sr. Lego no dejaba de mirarme tratando de seguir todo aquel maremagnum de formulitas y conceptos de Probabilidad. &lt;br /&gt;
&lt;br /&gt;
Está bien, veámoslo con un ejemplo concreto -concedí. Imaginad que mañana Gaznápiro llega a la oficina con una corbata amarilla, y desayuna pan y zumo. Fijaos en que ese caso concreto no está en nuestra tabla, sin embargo, vamos a tratar de inferir con los datos que tenemos cuál será su estado de ánimo. Necesitamos calcular las siguientes probabilidades:&lt;br /&gt;
P(Amarilla|Bueno); P(Pan|Bueno); P(Zumo|Bueno)&lt;br /&gt;
P(Amarilla|Malo); P(Pan|Malo); P(Zumo|Malo)&lt;br /&gt;
&lt;br /&gt;
Y también las probabilidades de:&lt;br /&gt;
P(Bueno) y P(Malo)&lt;br /&gt;
&lt;br /&gt;
Para luego poder aplicar la primera fórmula y obtener un valor que nos permita clasificar los atributos. Según la primera formula, el cálculo se realiza así:&lt;br /&gt;
&lt;br /&gt;
clasificar_dia_bueno = P(Bueno)*P(Amarilla|Bueno)*P(Pan|Bueno)*P(Zumo|Bueno)&lt;br /&gt;
&lt;br /&gt;
Y para el caso de que tenga un mal día será:&lt;br /&gt;
&lt;br /&gt;
clasificar_dia_malo = P(Malo)*P(Amarilla|Malo)*P(Pan|Malo)*P(Zumo|Malo)&lt;br /&gt;
&lt;br /&gt;
Vamos a ir calculando cada una de las probabilidades condicionadas usando la segunda fórmula. Empecemos con P(Amarilla|Bueno). Tenemos que n=4, ya que hay un total de 4 casos en la tabla en el que humor=Bueno. Para n&lt;sub&gt;c&lt;/sub&gt; tenemos que n&lt;sub&gt;c&lt;/sub&gt;=1, ya que sólo hay un caso en el que el día haya sido bueno cuando llevaba corbata amarilla. Para p tenemos que p=1/3, ya que tenemos 3 posibles valores del atributo Corbata (Rojo, Amarillo y Azul). Finalmente, m es un valor arbitrario, pero ha de ser consistente para todos los casos. Vamos a tomar un valor m=3.&lt;br /&gt;
Es decir:&lt;br /&gt;
n=4&lt;br /&gt;
n&lt;sub&gt;c&lt;/sub&gt;=1&lt;br /&gt;
p=1/3=0.333&lt;br /&gt;
m=3&lt;br /&gt;
&lt;br /&gt;
P(Amarilla|Bueno)=(1+(3*0.333))/(4+3)=0.285&lt;br /&gt;
&lt;br /&gt;
No vamos a desarrollar aquí el cálculo de todas las probabilidades, ya que se calcula siempre igual. Simplemente, calcularemos otra más correspondiente al caso humor=malo y después pondremos todos los resultados ya calculados.&lt;br /&gt;
Como ejemplo calcularemos la probabilidad P(Pan|Malo):&lt;br /&gt;
Ahora tenemos:&lt;br /&gt;
n=5 (hay 5 casos en la tabla en el que Humor=Malo)&lt;br /&gt;
n&lt;sub&gt;c&lt;/sub&gt;=4 (hay 4 casos en el que comió pan teniendo un día malo)&lt;br /&gt;
p=1/2=0.5 (hay dos posibilidades: Pan o Fruta, por lo que la probabilidad es del 50% para cada una).&lt;br /&gt;
m=3&lt;br /&gt;
&lt;br /&gt;
P(Pan|Malo)=(4+(3*0.5))/(5+3)=0.687&lt;br /&gt;
&lt;br /&gt;
Resumiendo, estos son los valores que hemos obtenido después de calcular todas las probabilidades condicionadas:&lt;br /&gt;
&lt;br /&gt;
P(Amarilla|Bueno)=0.285&lt;br /&gt;
P(Pan|Bueno)=0.357&lt;br /&gt;
P(Zumo|Bueno)=0.5&lt;br /&gt;
&lt;br /&gt;
P(Amarilla|Malo)=0.249&lt;br /&gt;
P(Pan|Malo)=0.687&lt;br /&gt;
P(Zumo|Malo)=0.312&lt;br /&gt;
&lt;br /&gt;
Nos resta calcular la probabilidad de P(Bueno) y P(Malo) que son:&lt;br /&gt;
P(Bueno)=4/9=0.444 (4 ocurrencias de Bueno sobre 9)&lt;br /&gt;
P(Malo)=5/9=0.555 (5 ocurrencias de Malo sobre 9)&lt;br /&gt;
Aunque aquí nos hemos limitado a dos, evidentemente podemos hacer una clasificación en más de dos categorías. &lt;br /&gt;
&lt;br /&gt;
Usando la primera fórmula obtenemos el siguiente resultado para el caso Humor=Bueno:&lt;br /&gt;
clasificar_dia_bueno = 0.444*0.285*0.357*0.5 = 0.0225&lt;br /&gt;
&lt;br /&gt;
y para el caso Humor=Malo:&lt;br /&gt;
clasificar_dia_malo = 0.555*0.249*0.687*0.312 = 0.0296&lt;br /&gt;
&lt;br /&gt;
Por lo que, en principio, podemos prever que, dados los condicionantes observados (corbata amarilla y desayuno de pan y zumo), lo más probable es que tenga un mal día.&lt;br /&gt;
&lt;br /&gt;
Sofía y el Sr. Lego levantaron la vista del papel donde estaba haciendo los cálculos y se me quedaron mirando sin saber qué decir, así que me adelanté a la pregunta que suponía que estaban a punto de hacerme:&lt;br /&gt;
Evidentemente, esto no es más que un modelo estadístico y no el oráculo de Delfos, esto no quiere decir que siempre que Gaznápiro pida pan y zumo para desayunar y traiga una corbata amarilla venga de mal humor. Además, el número de muestras (días) que hemos usado es bajo. En todo caso, este método, pese a su sencillez, es una poderosa herramienta para clasificar casi cualquier cosa. Los &lt;a href="http://es.wikipedia.org/wiki/Clasificador_bayesiano_ingenuo"&gt;clasificadores bayesianos&lt;/a&gt; son muy utilizados, por ejemplo, en la clasificación de documentos. Un buen ejemplo de ello son los programas anti-spam que utilizan los servidores de correo electrónico. Si os interesa, quizá otro día os explique como se utilizan para filtrar el spam. También se utiliza en minería de datos, traducción automática, correctores ortográficos, predicción (meteorológica, bursátil, etc…). Y en general tiene multitud de aplicaciones dentro del campo de la Inteligencia Artificial.&lt;br /&gt;
&lt;br /&gt;
Al día siguiente el Sr. Lego llegó con el siguiente programa en Python que había preparado para predecir el humor de Gaznápiro:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="python" style="height:250px; overflow:auto; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; classify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;attr, classif, data, ask&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# entrenar el clasificador&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; m=&lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; classes=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; attribs=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; attribs_count=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; attribs_count_per_class=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# obtener atributos&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;attr&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; attribs&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;attr&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; k,v &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; data.&lt;span style="color: black;"&gt;iteritems&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# obtener clases&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; v &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; classes:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; classes&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;v&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; classes&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;v&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=classes&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;v&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;+&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# contabilizar atributos&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; at &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; k:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; at &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; attribs&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;attr&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;k.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; attribs&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;attr&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;k.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# cuenta total&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; at &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; attribs_count:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; attribs_count&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; attribs_count&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=attribs_count&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;at&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;+&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# cuenta por clase&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at,v&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; attribs_count_per_class:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; attribs_count_per_class&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at,v&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; attribs_count_per_class&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at,v&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=attribs_count_per_class&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;at,v&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;+&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# calculo valor por cada clase&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; calc=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; classes:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; calc&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #008000;"&gt;float&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;classes&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;/&lt;span style="color: #008000;"&gt;float&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;data&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; j &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; ask:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; n=classes&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; nc=attribs_count_per_class&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;j,i&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; p=&lt;span style="color: #ff4500;"&gt;1.0&lt;/span&gt;/&lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;attribs&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;attr&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;ask.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;j&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; calc&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=calc&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;*&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;nc+m&lt;span style="color: #66cc66;"&gt;*&lt;/span&gt;p&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;/&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n+m&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; &lt;span style="color: #008000;"&gt;max&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;calc&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ == &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; attr=&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'corbata'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'desayuno'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'bebida'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; classif=&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'humor'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; data=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'roja'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'malo'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'roja'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'zumo'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'malo'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'roja'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'fruta'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'bueno'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'amarilla'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'malo'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'amarilla'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'fruta'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'bueno'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'azul'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'zumo'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'bueno'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'azul'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'fruta'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'malo'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'azul'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'fruta'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'zumo'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'bueno'&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'azul'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'cafe'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;span style="color: #483d8b;"&gt;'malo'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; ask=&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'amarilla'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'pan'&lt;/span&gt;,&lt;span style="color: #483d8b;"&gt;'zumo'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; theclass = classify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;attr, classif, data, ask&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;Clasificado como: &amp;quot;&lt;/span&gt; + theclass&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
De todas formas hoy no necesito ejecutarlo para saber cómo vendrá Gaznápiro a la oficina -dijo el Sr. Lego sonriendo- He visto su coche en el parking y alguien acaba de hacerle un buen bollo en la puerta. ¿Crees que deberíamos añadir un atributo al programa para eso?&lt;br /&gt;
&lt;br /&gt;
PD. Para los que tengan curiosidad, la ejecución del programa predijo que Gaznápiro tendría un mal día… y acertó.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5373432823372546529-5948426682039578385?l=divertimentosinformaticos.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DivertimentosInformticos/~4/44pVoh_IxeE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/5948426682039578385/comments/default" title="Enviar comentarios" /><link rel="replies" type="text/html" href="http://divertimentosinformaticos.blogspot.com/2011/11/la-maquina-predictora-de-estados-de.html#comment-form" title="2 comentarios" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/5948426682039578385?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/5948426682039578385?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DivertimentosInformticos/~3/44pVoh_IxeE/la-maquina-predictora-de-estados-de.html" title="La máquina predictora de estados de ánimo" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-gTAqjtcjVs8/Tq2se4SGIkI/AAAAAAAAAIo/t7zPfq_8cH4/s72-c/bola-cristal.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://divertimentosinformaticos.blogspot.com/2011/11/la-maquina-predictora-de-estados-de.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4MSXc6fCp7ImA9WhdVGUU.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529.post-8335874348988989164</id><published>2011-09-25T13:36:00.000-07:00</published><updated>2011-09-25T13:36:28.914-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-25T13:36:28.914-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Algoritmos genéticos" /><title>La leyenda de los "predictores" perfectos</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/NCxjeK6FreFxcY8NGhaL9okJIjw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NCxjeK6FreFxcY8NGhaL9okJIjw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/NCxjeK6FreFxcY8NGhaL9okJIjw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NCxjeK6FreFxcY8NGhaL9okJIjw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-K4cMWi6u2Lc/TneUAOGBYsI/AAAAAAAAAH0/xEFnFQ7g_xM/s1600/genoma.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="179" src="http://3.bp.blogspot.com/-K4cMWi6u2Lc/TneUAOGBYsI/AAAAAAAAAH0/xEFnFQ7g_xM/s320/genoma.jpg" width="238" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
En una mañana cualquiera, aún no habría podido ponerme a trabajar en serio, pero aquél día sólo llevaba media hora sentado en mi mesa y había podido leer todos los emails pendientes, contestarlos, planificarme la jornada e incluso había empezado a trabajar en el código del programa que tenía entre manos. Un día normal mi compañera Sofía me habría entretenido contándome alguna batallita nocturna tras haber derribado alguna web "enemiga" (defacement lo llama ella), pero esa mañana estaba especialmente silenciosa y, pese a ir de alternativa por la vida, ahí estaba con su ipod enchufado a sus orejas. Gaznápiro, mi jefe, había pasado por delante de nuestras mesas como una exhalación, con la cabeza gacha y con un montón de papeles bajo el brazo. Mal presagio sin duda. Es la calma que precede a la tempestad. Cuando Gaznápiro llega tan temprano al trabajo acompañado de tantos papeles (ya podría comprarse una carpeta el hombre) es señal de que tiene que preparar una reunión con la plana mayor, de la que suele salir bastante cabreado. Evidentemente, tiene que desfogar con alguien y parece que, además de informáticos, somos buenos esparrings, porque nada más salir de esas reuniones la emprende, metafóricamente hablando, con nosotros.  &lt;br /&gt;
Pero lo más extraño de todo era que el Sr. Lego aún no había aparecido por allí, y eso que suele ser el primero en llegar cada mañana. Puntual como un reloj suizo. Fue pensar en ello y aparecer por la puerta de la oficina. Traía el hombre mala cara esa mañana y unas ojeras bastante pronunciadas. &lt;br /&gt;
Buenos días Sr. Lego ¿mala noche? -dije.&lt;br /&gt;
Pues sí -respondió- he dormido regular. El crío, que anda con dolores de estómago y se pasa la noche llora que te llora, el pobre. Y encima escuchando la radio en el coche me entero de que han bajado las acciones de Microsol, justo ahora que acababa de comprar algunas por probar esto de la bolsa. Afortunadamente no invertí mucho, pero mira que tengo mala pata. Ojalá hubiera algún programa que te dijera en qué empresa hay que invertir para ganar dinero. &lt;br /&gt;
¡Ojalá! -dije. Pero me temo que todavía no lo han inventado. Aun así hay bastante gente investigando en ese campo, y por lo que sé, algunos programas no lo hacen mucho peor que brokers profesionales. &lt;br /&gt;
Evidentemente, acababa de captar la atención del Sr. Lego porque había dejado de mirar los valóres de bolsa para mirarme a mí.  &lt;br /&gt;
Bueno -continué- el otro día leí algo sobre que habían desarrollado un programa que usando &lt;a href="http://es.wikipedia.org/wiki/Algoritmo_genético"&gt;algoritmos genéticos&lt;/a&gt; era capaz de hacer mejor papel que la mayoría de los inversores humanos en el mercado de futuros.  &lt;br /&gt;
¿Algoritmos genéticos? -preguntó el Sr. Lego. &lt;br /&gt;
Sí, es una de las ramas de la Inteligencia Artificial que se está explorando con más interés en la actualidad, y además tiene un campo de aplicación bastante amplio. &lt;br /&gt;
Pues no tenía ni idea -reconoció el Sr. Lego. ¿Cómo funcionan los algoritmos genéticos? &lt;br /&gt;
Verá usted Sr. Lego, no es fácil explicar cómo funcionan en pocas palabras, pero le voy a contar la leyenda de los "predictores" perfectos y verá como lo entiende rápidamente.  &lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;   &lt;br /&gt;
Cuenta la leyenda que en un mundo paralelo al nuestro vivían unos seres llamados predictores. En ese mundo todo era digital y estaba formado por ceros y unos. Todo se comportaba de forma binaria. Encendido/apagado, activo/inactivo, abierto/cerrado, etc… Los predictores no eran una excepción, y se alimentaban de cifras binarias. La comida de los predictores llegaba en forma de impulsos desde no se sabe dónde, el caso es que cada segundo llegaba un impulso que los predictores debían asimilar y digerir. Esos impulsos podían corresponder a un cero o un uno y siempre llegaban formando el mismo patrón que se repetía una y otra vez: 1101001011.&lt;br /&gt;
El Sr. Lego me estaba mirando con cara de incredulidad como pensando "No puede estar contándome semejante tontería", así que me apresuré a continuar antes de que me cortara en seco.&lt;br /&gt;
El problema es que los predictores necesitaban emitir una señal idéntica a la que recibían para poder digerirla. Los predictores emitían cada segundo, de forma sincronizada con la llegada de comida, una señal. La señal que emitían los predictores estaba codificada en su ADN en forma de secuencia fija de 10 bits. Cada predictor tenía una secuencia diferente, por lo que algunos, dependiendo del grado de similitud entre la secuencia de su ADN y la del patrón de llegada de comida se alimentaban mejor que otros.&lt;br /&gt;
Es decir, si un predictor tenía la secuencia 1001011001 en su ADN (recordemos que el patrón de llegada de alimentos es 1101001011), este comerá 7 de cada 10 veces que recibe comida, ya que hay 3 cifras que son diferentes entre los dos patrones.&lt;br /&gt;
O sea, que habrá predictores que estén mejor alimentados que otros ¿no? -dijo el Sr. Lego.&lt;br /&gt;
Efectivamente, son predictores mejor adaptados al mundo y, por lo tanto, con mayor probabilidad de sobrevivir y procrear.&lt;br /&gt;
El Sr. Lego sonrió: Así que los predictores también tienen hijos.&lt;br /&gt;
Realmente, Sr. Lego, son seres hermafroditas y muy promiscuos. Cada pocos segundos sienten la necesidad de unirse a otro predictor. Cada vez que dos predictores tienen relaciones tienen exactamente dos hijos (uno cada uno). Afortunadamente, cada vez que nace un predictor otro se desintegra y de esta forma la población se mantiene estable.&lt;br /&gt;
Qué bonita historia de Amor… -se mofó el Sr. Lego.&lt;br /&gt;
&lt;br /&gt;
Verá Sr. Lego, lo más impresionante de esta historia es que tras algunas generaciones de predictores, el ADN de la mayoría de la población era capaz de predecir al 100% el patrón de llegada de alimento. Un hecho increíble. La población entera había evolucionado en su conjunto para adaptarse al medio. Es por ello que llamamos a esta historia la leyenda de los predictores perfectos.&lt;br /&gt;
Vaya, esto se parece bastante a la selección natural de la que hablaba Darwin -dijo el Sr. Lego. Sobreviven los más adaptados y con el tiempo los peor adaptados desaparecen.&lt;br /&gt;
Efectivamente, pero ¿sabe cuál es el mecanismo que consiguió que toda la población convergiera hacia un ADN perfecto? El secreto estaba en que los mejores adaptados también tenían más posibilidades de reproducirse y, por ende, de transmitir su ADN de mejor calidad.&lt;br /&gt;
Como la vida misma -bromeó el Sr. Lego. Lo que no entiendo es qué tiene que ver todo esto con un algoritmo capaz de predecir el comportamiento de la bolsa.&lt;br /&gt;
&lt;br /&gt;
Bueno Sr. Lego, una vez establecida la analogía con el mundo de los predictores vamos a entrar en materia y a ver como funciona un algoritmo genético o evolutivo, como prefiero llamarlo.&lt;br /&gt;
En una población completa, llamaremos individuo a cada uno de sus componentes. Al ADN de cada predictor lo llamaremos gen y a cada bit que lo compone lo llamaremos cromosoma. &lt;br /&gt;
La población inicial tiene que ser lo suficientemente grande como para tener cierta riqueza genética, así que lo primero que hay que hacer es generar una población grande y con ADNs aleatorios.&lt;br /&gt;
Todo algoritmo genético consta de cuatro fases: Selección, cruce, mutación y extinción.&lt;br /&gt;
&lt;br /&gt;
La selección consiste en escoger los mejores individuos para que procreen. Sin embargo, en pro de la diversidad genética no conviene quedarse estrictamente con los mejores. Es preferible asignar una probabilidad de ser seleccionado a cada individuo según su nivel de adaptación. Por ejemplo, un predictor que acierta 8 veces con su secuencia de ADN tiene que tener un 50% más de probabilidad de ser seleccionado para procrear que un predictor con 4 aciertos.&lt;br /&gt;
En cualquier caso, un predictor con mal ADN tiene que tener alguna probabilidad de procrear, aunque sea baja, ya que uno de sus hijos podría aportar una gran mejora a la población.&lt;br /&gt;
El nivel de adaptación al medio de cada predictor nos lo dará la llamada función de adaptación, que es una función que nos indica cómo de bien adaptado está el individuo. En el caso de los predictores, la función de adaptación nos devolvería el número de bits del ADN del predictor que coinciden con el patrón de llegada de comida.&lt;br /&gt;
&lt;br /&gt;
En la fase de cruce es donde procrean los individuos seleccionados dando lugar a dos hijos. Se llama fase de cruce porque se seleccionan dos individuos y se entrecruzan sus ADNs. El proceso consiste en seleccionar de forma aleatoria un punto de corte del ADN y recombinarlos según el siguiente esquema. Supongamos que el punto de corte ha sido el tercer cromosoma.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-qW3NcoDLHnU/Tn9hKXJoQVI/AAAAAAAAAH8/rHzrqK4hYZ4/s1600/cruce.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="142" width="320" src="http://3.bp.blogspot.com/-qW3NcoDLHnU/Tn9hKXJoQVI/AAAAAAAAAH8/rHzrqK4hYZ4/s320/cruce.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Es decir, que del cruce de los padres (arriba) obtenemos dos nuevos hijos (abajo). &lt;br /&gt;
&lt;br /&gt;
La tercera fase, llamada mutación, imita las mutaciones genéticas biológicas. Estas mutaciones no deben ser muy frecuentes (sobre un 1% de probabilidad de que se produzca, aunque se puede jugar con este valor). La mutación consiste en cambiar uno de los cromosomas de forma aleatoria en un gen, es decir, seleccionamos un cromosoma aleatoriamente y si es un cero lo cambiamos a un uno y si es un uno lo transformamos en un cero.&lt;br /&gt;
&lt;br /&gt;
Finalmente nos queda la fase de extinción, donde elegiremos a los dos individuos peor adaptados para eliminarlos.&lt;br /&gt;
Todo el proceso se repite hasta que, o bien la población converge (aproximadamente un 95% de la población tiene un valor similar en la función de adaptación) o bien se alcanza un número máximo de iteraciones. &lt;br /&gt;
Este sería, grosso modo, el pseudocódigo de un algoritmo genético:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="text" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;generar población inicial de forma aleatoria&lt;br /&gt;
&amp;nbsp; Mientras&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;no fin&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Para tamaño&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;población&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;/&lt;span style=""&gt;2&lt;/span&gt; hacer&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; seleccionar dos individuos&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; cruzar los dos individuos&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mutar con cierta probabilidad los nuevos individuos&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; añadir los dos nuevos individuos a la población&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; eliminar los dos peores individuos de la población&lt;br /&gt;
&amp;nbsp; &amp;nbsp; fin para&lt;br /&gt;
&amp;nbsp; fin mientras&lt;br /&gt;
quedarse con la mejor solución&lt;/div&gt;&lt;br /&gt;
El señor lego estaba entusiasmado. Parecía haberlo entendido y ya estaba pensando en construir su propio modelo del mundo de los predictores. No tardó más de un par de horas en enviarme el siguiente código.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="python" style="background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace; height: 250px; overflow: auto;"&gt;&lt;ol&gt;&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: crimson;"&gt;math&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: crimson;"&gt;random&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; initial_population&lt;span style="color: black;"&gt;(&lt;/span&gt;max_population, num_vars&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# crear población inicial aleatoria&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; population=&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;max_population&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; gene=&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; j &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;num_vars&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: crimson;"&gt;random&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: orangered;"&gt;0.5&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gene.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gene.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; population.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;gene&lt;span style="color: black;"&gt;[&lt;/span&gt;:&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; population&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; adaptation_function&lt;span style="color: black;"&gt;(&lt;/span&gt;gene, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# valor de adaptación del gen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; cont=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;gene&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;gene&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;==solution&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; cont=cont+&lt;span style="color: orangered;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; cont&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; evaluate_population&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# evalua todos los genes de la poblacion&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; adaptation=&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;population&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; adaptation.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation_function&lt;span style="color: black;"&gt;(&lt;/span&gt;population&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; adaptation&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; selection&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; adaptation=evaluate_population&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# suma de todas las puntuaciones&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; total=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; total=total+adaptation&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# escogemos dos elementos&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; val1=&lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;randint&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;,total&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; val2=&lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;randint&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;,total&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; sum_sel=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; sum_sel=sum_sel+adaptation&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; sum_sel&lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt;=val1:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gene1=population&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;break&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; sum_sel=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; sum_sel=sum_sel+adaptation&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; sum_sel&lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt;=val2:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gene2=population&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;break&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; gene1, gene2&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; crossover&lt;span style="color: black;"&gt;(&lt;/span&gt;gene1, gene2&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# cruza 2 genes y obtiene 2 descendientes&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene1=&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene2=&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; cutpoint=&lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;randint&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;, &lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;gene1&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene1&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;:cutpoint&lt;span style="color: black;"&gt;]&lt;/span&gt;=gene1&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;:cutpoint&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene1&lt;span style="color: black;"&gt;[&lt;/span&gt;cutpoint:&lt;span style="color: black;"&gt;]&lt;/span&gt;=gene2&lt;span style="color: black;"&gt;[&lt;/span&gt;cutpoint:&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene2&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;:cutpoint&lt;span style="color: black;"&gt;]&lt;/span&gt;=gene2&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;:cutpoint&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; new_gene2&lt;span style="color: black;"&gt;[&lt;/span&gt;cutpoint:&lt;span style="color: black;"&gt;]&lt;/span&gt;=gene1&lt;span style="color: black;"&gt;[&lt;/span&gt;cutpoint:&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; new_gene1, new_gene2&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; mutation&lt;span style="color: black;"&gt;(&lt;/span&gt;prob, gene&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# muta un gen con una probabilidad prob.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;random&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt;prob:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; chromosome=&lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;randint&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;, &lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;gene&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; gene&lt;span style="color: black;"&gt;[&lt;/span&gt;chromosome&lt;span style="color: black;"&gt;]&lt;/span&gt;==&lt;span style="color: orangered;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gene&lt;span style="color: black;"&gt;[&lt;/span&gt;chromosome&lt;span style="color: black;"&gt;]&lt;/span&gt;=&lt;span style="color: orangered;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gene&lt;span style="color: black;"&gt;[&lt;/span&gt;chromosome&lt;span style="color: black;"&gt;]&lt;/span&gt;=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; gene&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; drop_worse_genes&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# elimina los dos peores genes&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; adaptation=evaluate_population&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; i=adaptation.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;min&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;del&lt;/span&gt; population&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;del&lt;/span&gt; adaptation&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; i=adaptation.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;min&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;del&lt;/span&gt; population&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;del&lt;/span&gt; adaptation&lt;span style="color: black;"&gt;[&lt;/span&gt;i&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; best_gene&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: grey; font-style: italic;"&gt;# devuelve el mejor gen de la poblacion&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; adaptation=evaluate_population&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; population&lt;span style="color: black;"&gt;[&lt;/span&gt;adaptation.&lt;span style="color: black;"&gt;index&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;max&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;adaptation&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;def&lt;/span&gt; genetic_algorithm&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; max_iter=&lt;span style="color: orangered;"&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; max_population=&lt;span style="color: orangered;"&gt;50&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; num_vars=&lt;span style="color: orangered;"&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; done=&lt;span style="color: green;"&gt;False&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; solution = initial_population&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;1&lt;/span&gt;, num_vars&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; population = initial_population&lt;span style="color: black;"&gt;(&lt;/span&gt;max_population, num_vars&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; iterations=&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;while&lt;/span&gt; &lt;span style="color: #ff7700; font-weight: bold;"&gt;not&lt;/span&gt; done:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; iterations=iterations+&lt;span style="color: orangered;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: green;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: green;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;population&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;/&lt;span style="color: orangered;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gene1, gene2 = selection&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; new_gene1, new_gene2 = crossover&lt;span style="color: black;"&gt;(&lt;/span&gt;gene1, gene2&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; new_gene1 = mutation&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0.1&lt;/span&gt;, new_gene1&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; new_gene2 = mutation&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: orangered;"&gt;0.1&lt;/span&gt;, new_gene2&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; population.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;new_gene1&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; population.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;new_gene2&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; drop_worse_genes&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;max_iter&lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt;iterations&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; done=&lt;span style="color: green;"&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;print&lt;/span&gt; &lt;span style="color: darkslateblue;"&gt;"Solucion: "&lt;/span&gt;+&lt;span style="color: green;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; best = best_gene&lt;span style="color: black;"&gt;(&lt;/span&gt;population, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;return&lt;/span&gt; best, adaptation_function&lt;span style="color: black;"&gt;(&lt;/span&gt;best, solution&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&lt;span style="color: #ff7700; font-weight: bold;"&gt;if&lt;/span&gt; __name__ == &lt;span style="color: darkslateblue;"&gt;"__main__"&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: crimson;"&gt;random&lt;/span&gt;.&lt;span style="color: black;"&gt;seed&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; best_gene = genetic_algorithm&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;print&lt;/span&gt; &lt;span style="color: darkslateblue;"&gt;"Mejor gen encontrado: "&lt;/span&gt;+ &lt;span style="color: green;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;best_gene&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="color: #003030; font-weight: normal; font: normal normal 100% 'Courier New', Courier, monospace; vertical-align: top;"&gt;&lt;div style="background: none; color: #000020; font: normal normal 1em/1.2em monospace; margin: 0; padding: 0; vertical-align: top;"&gt;&amp;nbsp; &lt;span style="color: #ff7700; font-weight: bold;"&gt;print&lt;/span&gt; &lt;span style="color: darkslateblue;"&gt;"Funcion de adaptacion: "&lt;/span&gt;+&lt;span style="color: green;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;best_gene&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: orangered;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Excelente Sr. Lego, veo que ha captado perfectamente la idea. De hecho sus predictores se convierten en predictores perfectos tras muy pocas iteraciones. ¡Enhorabuena!&lt;br /&gt;
Sí, y me parece que los predictores están muy felices, pero ¿valen para algo más los algoritmos genéticos?&lt;br /&gt;
Pues valen para muchas cosas. Son de hecho una metaheurística usada en búsquedas locales.&lt;br /&gt;
¿cómo? ¿metaqué? -preguntó el Sr. Lego.&lt;br /&gt;
Metaheurística. Es una forma de búsqueda heurística que podemos adaptar a casi cualquier problema que no tenga un algoritmo propio que lo resuelva. Una especie de comodín. Si no sabemos cómo afrontar la solución de un problema podemos usar una metaheurística como pueda ser un algoritmo genético.&lt;br /&gt;
Nos vale para problemas de optimización, diseño automático, aprendizaje, predicción, etc… &lt;br /&gt;
De hecho, si podemos representar el problema como ristras de números binarios, podemos usar el programa que acaba de hacer para resolverlo. Por ejemplo, si quisiéramos encontrar un valor entero para x que maximice la función f(x)=x^2, sólo tendríamos que crear una población de números binarios, que representarían a sus contrapartidas enteras, y usar como función de adaptación el valor de la propia función X^2 al evaluar el número representado por el ADN. En pocas iteraciones obtendríamos una población que convergería hacia ese valor de X que maximiza la función.&lt;br /&gt;
Interesante -dijo el señor Lego. ¿Pero sólo podemos tener genes cuyos cromosomas son ceros y unos?&lt;br /&gt;
Para nada -contesté. En el campo de la investigación suelen representarse así ya que con números binarios podemos codificar casi cualquier valor. De hecho, los cromosomas podrían ser cualquier cosa: números, letras, etc… &lt;br /&gt;
Eso sí, teniendo en cuenta que hay que elegir una función de adaptación acorde a la representación que usemos para la información.&lt;br /&gt;
Bueno, dijo el Sr. Lego. Voy a darle algunas vueltas a todo esto que me has contado para ver como hago un predictor perfecto para los valores de la bolsa.&lt;br /&gt;
Desafortunadamente (o afortunadamente) la bolsa no sigue patrones fijos, al menos aparentemente, aunque quizás dé usted con un predictor bursatil que le saque de esta empresa.&lt;br /&gt;
Ojalá, contestó el Sr. Lego. Aunque echaría de menos nuestras conversaciones.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5373432823372546529-8335874348988989164?l=divertimentosinformaticos.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DivertimentosInformticos/~4/_TBejnef6Rw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/8335874348988989164/comments/default" title="Enviar comentarios" /><link rel="replies" type="text/html" href="http://divertimentosinformaticos.blogspot.com/2011/09/la-leyenda-de-los-predictores-perfectos.html#comment-form" title="1 comentarios" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/8335874348988989164?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/8335874348988989164?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DivertimentosInformticos/~3/_TBejnef6Rw/la-leyenda-de-los-predictores-perfectos.html" title="La leyenda de los &quot;predictores&quot; perfectos" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-K4cMWi6u2Lc/TneUAOGBYsI/AAAAAAAAAH0/xEFnFQ7g_xM/s72-c/genoma.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://divertimentosinformaticos.blogspot.com/2011/09/la-leyenda-de-los-predictores-perfectos.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MCRXk7cSp7ImA9WhdXEkQ.&quot;"><id>tag:blogger.com,1999:blog-5373432823372546529.post-5261155260636680574</id><published>2011-08-24T13:29:00.000-07:00</published><updated>2011-08-25T12:11:04.709-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-25T12:11:04.709-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Redes probabilisticas" /><title>¿Sueñan los ordenadores con imitar a Cervantes?</title><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3WNin_LgG1nyPRpeKDaeHbo_pdE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3WNin_LgG1nyPRpeKDaeHbo_pdE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3WNin_LgG1nyPRpeKDaeHbo_pdE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3WNin_LgG1nyPRpeKDaeHbo_pdE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-sHRYlO8dxsc/TlSht64RJhI/AAAAAAAAAHU/XDA2xggdlzs/s1600/escritura1.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="164" width="320" src="http://3.bp.blogspot.com/-sHRYlO8dxsc/TlSht64RJhI/AAAAAAAAAHU/XDA2xggdlzs/s320/escritura1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cualquier día es bueno, y más si la climatología acompaña, para dar un paseo por el parque. Aquel día coincidía con una feria del libro, y mi amigo Descollante y yo andábamos de caseta en caseta en busca de algún buen libro extranjero de informática (porque de los autóctonos mejor ni hablamos). En una de las casetas estaba Fulano sentado, firmando libros a troche y moche, el último fabricante de bestsellers en serie. A mí no me parece mal siempre que ayude a que algunos lean algo, aunque sea por poder decir que se han leído el último libro de moda, pero mi amigo Descollante suele ser algo más radical e intolerante con la literatura barata y de consumo, y más si mediocres escritores que aprovechan filón literario del último tema de moda, junto con un marketing estudiadísimo, acaban forrándose de la noche a la mañana. Quizás influya que Descollante lleva dentro un escritor frustrado y un montón de negativas de editoriales a sus espaldas. Y no es que sea Borges o Delibes, pero tampoco se le da mal eso de contar historias dándole a la tecla.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Para mí que Fulano tiene un grupo de monos escribiéndole las cosas esas que publica -comenzó a decir Descollante- Seguro que tiene un programa de ordenador que le escribe los libros.&lt;br /&gt;
Si fueras capaz de hacer un programa para escribir bestsellers seguro que te forrabas más que Fulano con sus libros -bromeé.&lt;br /&gt;
Descollante me miró con media sonrisa y me dijo que quizás no estábamos tan lejos de conseguir que los ordenadores fueran capaces de hacer literatura. No pude esconder mi sonrisa al pensar que ya estaba fanfarroneando de nuevo. Tuvo que captar mi pensamiento porque se paró en seco frente a una terraza-bar y se sentó en una silla sin ni siquiera avisar. Antes de que pudiera reaccionar había pedido dos Cocacolas.&lt;br /&gt;
No hace mucho estuve "jugando" con &lt;a href="http://es.wikipedia.org/wiki/Cadena_de_Markov"&gt;cadenas de Markov&lt;/a&gt; para tratar de generar texto con cierto sentido. Y no fue mal el experimento -comenzó a decirme Descollante.&lt;br /&gt;
¿Cadenas de Markov? me suena de la facultad -le contesté- pero no recuerdo muy bien en qué consistían.&lt;br /&gt;
Descollante sonrió y empezó a explicarme que las cadenas de Markov son una estructura matemática cuya definición formal es algo compleja, aburrida y además requiere sólidos conocimientos de Probabilidad. Así que, saltándose toda la parte aburrida, me explicó que una cadena de Markov es básicamente un grafo dirigido (un digrafo realmente) cuyos nodos están conectados por aristas, y a cada arista se le asocia un valor que es la probabilidad que hay de pasar de un nodo a otro.&lt;br /&gt;
La verdad es que me he quedado un poco a cuadros -le dije.&lt;br /&gt;
Es muy sencillo, Alberto. Imagina que le mostramos a un ordenador el siguiente texto: "Hola Lola". Y queremos construir una cadena de Markov que nos indique qué probabilidad hay, en esta frase, de pasar de una letra a otra. O mejor dicho de que a una letra le siga otra concreta. Por ejemplo, ¿qué probabilidad hay de que a la letra H le siga una O?&lt;br /&gt;
Teniendo en cuenta que las letras posibles son sólo H, O, L, A y espacio (SP), ya que no distinguimos aquí entre mayúsculas y minúsculas. Una cadena de Markov para esta frase tendría el siguiente aspecto.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-QYoW31Ulaq8/TlTACnXoitI/AAAAAAAAAHc/oT3-V5aFBOM/s1600/cadmarkov.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="320" width="285" src="http://1.bp.blogspot.com/-QYoW31Ulaq8/TlTACnXoitI/AAAAAAAAAHc/oT3-V5aFBOM/s320/cadmarkov.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Según el grafo, la probabilidad de que tras una L aparezca una A es del 50%. Aunque para trabajar con estos porcentajes mejor diremos que la probabilidad es de 0.5, es decir, la probabilidad será un valor real entre 0 y 1. La suma de las probabilidades de las aristas salientes de un nodo siempre tiene que valer 1.&lt;br /&gt;
Como ya habrás deducido -me dijo Descollante por sorpresa- el cambio de un estado a otro es una función de probabilidad que depende exclusivamente del estado anterior. Por lo tanto, aquello que haya ocurrido antes del estado anterior no tiene relevancia.&lt;br /&gt;
Vale, le dije. Y... ¿cómo se supone que esto va a escribir un libro?&lt;br /&gt;
Descollante empezó a reír mientras sacaba su portátil. Mira -me dijo- esto es una prueba que hice el otro día. &lt;br /&gt;
Me enseño el siguiente listado.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="python" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;height:250px; overflow:auto"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; create_char_map&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;filepath&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; chars=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; f = &lt;span style="color: #008000;"&gt;open&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;filepath, &lt;span style="color: #483d8b;"&gt;'r'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; done=&lt;span style="color: #008000;"&gt;False&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; lastchar=&lt;span style="color: #483d8b;"&gt;''&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;while&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; done:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; t=f.&lt;span style="color: #dc143c;"&gt;readline&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;t&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;==&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; done=&lt;span style="color: #008000;"&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; t:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;lastchar&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastchar&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastchar&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastchar&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;+&lt;span style="color: #ff4500;"&gt;1.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastchar&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #ff4500;"&gt;1.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lastchar=c&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; f.&lt;span style="color: black;"&gt;close&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; chars&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; markov_net&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; tot=&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; n &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; tot=tot+chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; n &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;/tot&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; chars&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; generate_text&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars, initial_char, num_chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; text=&lt;span style="color: #483d8b;"&gt;''&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; ch=initial_char&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;num_chars-&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; text += ch&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; ch=prob_choice&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;ch&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; text&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; prob_choice&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;prob_chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; probability = &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; char = &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; cur_prob = &lt;span style="color: #ff4500;"&gt;0.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c, p &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; prob_chars.&lt;span style="color: black;"&gt;iteritems&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; cur_prob = cur_prob + p&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; probability.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;cur_prob&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; char.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; rnd = &lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;*&lt;/span&gt; cur_prob&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i, total &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;enumerate&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;probability&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; rnd &lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt; total:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; char&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ == &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# cambiar alicia.txt por el nombre del&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #808080; font-style: italic;"&gt;# archivo que se quiera utilizar.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; chars = create_char_map&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'alicia.txt'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; chars = markov_net&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; text = generate_text&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars, &lt;span style="color: #483d8b;"&gt;'d'&lt;/span&gt;, &lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; text&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Este programita lee un texto (preferiblemente grande) y construye una malla de probabilidades como esta, pero evidentemente mucho más grande para albergar todas las letras del alfabeto y los signos de puntuación.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-G6xs54tA05A/TlTE5naZb6I/AAAAAAAAAHk/YwDwESPm0Ac/s1600/Pantallazo.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="114" width="161" src="http://2.bp.blogspot.com/-G6xs54tA05A/TlTE5naZb6I/AAAAAAAAAHk/YwDwESPm0Ac/s320/Pantallazo.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
La idea es que a partir de esta malla de probabilidades podemos hacer que el ordenador genere un texto sin sentido, pero con silabas habituales del idioma. Algo así como un lenguaje inventado.&lt;br /&gt;
Tras ejecutarlo usando el texto del libro Alicia en el país de las maravillas obtuvimos el siguiente texto:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="text" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;de domal ajaterébobasta sesude co taditegabocudes a ni Ala y desuiñose os e itadonco ladezaden mo do paribl dace senanoca ca lie e mel M, diciontando renastuefa seloren coso llomara br Fun sero pre ire do-. atis Resties tun magunande la e sapu sa gils dedonco do acaren dontiga ventrtijo ta e padele aitoja vor dicancora-Nos y qur a puema dicienchadante deca la m!&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Pues no creo que esto se venda más que los libros de Fulanito -dije riendo. Aunque la verdad es que parecen palabras inventadas de un idioma de Tolkien. Descollante ejecutó el programa varias veces más obteniendo diferentes resultados.&lt;br /&gt;
Bueno, todavía podemos mejorarlo un poco -dijo. En vez de construir una malla de probabilidades con las letras del alfabeto podemos hacerlo directamente con palabras completas.&lt;br /&gt;
¿Quieres decir que habría que construir una malla en la que, dada un palabra, contenga la probabilidad con la que aparecerá la siguiente palabra?&lt;br /&gt;
Efectivamente -respondió. Por cada palabra del texto analizado incluiremos todas las palabras que en algún momento del texto la sigan y con qué frecuencia, por ejemplo, en la frase "Soy grande porque no soy pequeño" vemos que tras la palabra "soy" aparecen las palabras "grande" y "pequeño", por lo tanto tras la palabra "soy" hay una probabilidad de 0.5 de que aparezca "grande" y 0.5 de que aparezca la palabra "pequeño".&lt;br /&gt;
Descollante se puso a teclear y cambió el programa que acabó teniendo el siguiente aspecto:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="python" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;height:250px; overflow:auto"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; create_word_map&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;filepath&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; words=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; f = &lt;span style="color: #008000;"&gt;open&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;filepath, &lt;span style="color: #483d8b;"&gt;'r'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; done=&lt;span style="color: #008000;"&gt;False&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; lastword=&lt;span style="color: #483d8b;"&gt;''&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;while&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; done:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; t=f.&lt;span style="color: #dc143c;"&gt;readline&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;t&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;==&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; done=&lt;span style="color: #008000;"&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; t.&lt;span style="color: black;"&gt;split&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;' '&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;not&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; words:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; words&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;lastword&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; words&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastword&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; words&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastword&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=words&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastword&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;+&lt;span style="color: #ff4500;"&gt;1.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; words&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;lastword&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=&lt;span style="color: #ff4500;"&gt;1.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lastword=c&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; f.&lt;span style="color: black;"&gt;close&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; words&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; markov_net&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; tot=&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; n &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; tot=tot+chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; n &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;=chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;/tot&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; chars&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; generate_text&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars, initial_char, num_chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; text=&lt;span style="color: #483d8b;"&gt;''&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; ch=initial_char&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;range&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;num_chars-&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; text += &lt;span style="color: #483d8b;"&gt;' '&lt;/span&gt;+ch&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; ch=prob_choice&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;ch&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; text&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; prob_choice&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;prob_chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; probability = &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; char = &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; cur_prob = &lt;span style="color: #ff4500;"&gt;0.0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; c, p &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; prob_chars.&lt;span style="color: black;"&gt;iteritems&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; cur_prob = cur_prob + p&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; probability.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;cur_prob&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; char.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;c&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; rnd = &lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;random&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;*&lt;/span&gt; cur_prob&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i, total &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;enumerate&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;probability&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; rnd &lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt; total:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; char&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ == &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; chars = create_word_map&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'alicia.txt'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; chars = markov_net&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; text = generate_text&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;chars, &lt;span style="color: #483d8b;"&gt;'La'&lt;/span&gt;, &lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp; &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; text&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Descollante ejecutó el programa de nuevo usando el texto de Alicia en el país de las maravillas y este fue el texto obtenido.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="text" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;ol&gt;&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;El Lirón se llevó a la boca, mamá! -protestó Alicia quedó muy soliviantadas.&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;-¡Ratoncito querido! ¡vuelve atrás, que los pájaros se me suene de estas palabras, su libro de las palabras:&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;Cuando volvió hacia arriba, pero no es muy cómodo, y después una de debajo de extrañar que vio al cuerpo, y a suceder en que comer y seguía achicándose rápidamente. Se está del jardín, y Morcaro, duques de haber muchas ganas de manzanas, con el suelo su alrededor hacia el aire. Incluso la dirección en esto, pero no lo que no se interrumpió, y tan terrible entre los pececillos&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;Para esto no hacer esta mañana -dijo Alicia.&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;-¡Yo no quiere decir! -refunfuñó el Grifo.&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;Alicia empezaba a oír esto no había largado al principio -dijo Alicia-, qué tipo de que ir a&lt;/div&gt;&lt;/li&gt;
&lt;li style="font-weight: normal; vertical-align:top;font: normal normal 100% 'Courier New', Courier, monospace; color: #003030;"&gt;&lt;div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Curioso -dije- parece un texto escrito por un paranoico, pero algunas frases tienen sentido y todo. Parece interesante esto de las cadenas de Markov.&lt;br /&gt;
Pues sí -dijo Descollante. Las cadenas de Markov se aplican en gran cantidad de campos: en problemas de termodinámica y física estadística, para crear modelos meteorológicos, en simulación, juegos de azar, economía y predicción de valores de bolsa, incluso el algoritmo page rank de google hace uso de él. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5373432823372546529-5261155260636680574?l=divertimentosinformaticos.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DivertimentosInformticos/~4/A4Z25H34dG4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://divertimentosinformaticos.blogspot.com/feeds/5261155260636680574/comments/default" title="Enviar comentarios" /><link rel="replies" type="text/html" href="http://divertimentosinformaticos.blogspot.com/2011/08/suenan-los-ordenadores-con-imitar.html#comment-form" title="9 comentarios" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/5261155260636680574?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5373432823372546529/posts/default/5261155260636680574?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DivertimentosInformticos/~3/A4Z25H34dG4/suenan-los-ordenadores-con-imitar.html" title="¿Sueñan los ordenadores con imitar a Cervantes?" /><author><name>Alberto García</name><uri>http://www.blogger.com/profile/12343900062610779413</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="28" height="32" src="http://1.bp.blogspot.com/-PzP60ySWgqc/Tz6iuqqePAI/AAAAAAAAAJg/BPUOQ_r3Apk/s220/di.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-sHRYlO8dxsc/TlSht64RJhI/AAAAAAAAAHU/XDA2xggdlzs/s72-c/escritura1.jpg" height="72" width="72" /><thr:total>9</thr:total><feedburner:origLink>http://divertimentosinformaticos.blogspot.com/2011/08/suenan-los-ordenadores-con-imitar.html</feedburner:origLink></entry></feed>

