<?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:blogger="http://schemas.google.com/blogger/2008" 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;DEACRXk8fyp7ImA9WhFTGUo.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410</id><updated>2013-06-11T20:52:44.777+02:00</updated><category term="Python" /><category term="Network" /><category term="Matematica" /><category term="Grafica" /><category term="Thread" /><category term="C" /><category term="Fondamenti" /><category term="Curiosità" /><category term="ADT" /><category term="Java" /><category term="Algoritmi" /><category term="Sicurezza" /><category term="Pattern" /><category term="Multimediale" /><category term="HTTP" /><category term="Octave" /><category term="Haskell" /><category term="Competizioni" /><category term="MATLAB" /><category term="ISA" /><category term="Virus" /><category term="POV-Ray" /><category term="Mac OS X" /><category term="Giochi" /><category term="LPT" /><category term="Albero" /><category term="Multicasting" /><category term="MIPS32" /><category term="Memoria" /><category term="OpenGL" /><title>Sic-Oding</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://sic-oding.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/blogspot/TmCJR" /><feedburner:info uri="blogspot/tmcjr" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;A0QGQ3s9eCp7ImA9WhNXEUQ.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-6639223847309002997</id><published>2012-11-29T15:28:00.001+01:00</published><updated>2012-11-29T15:28:42.560+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-29T15:28:42.560+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><title>Cos'è un dottorato e la ricerca in generale?</title><content type="html">&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Ogni autunno, spiego ad un nuovo gruppo di studenti dottorandi cosa il dottorato sia.&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;È difficile descriverlo a parole.&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Perciò, io uso le immagini.&lt;/span&gt;&lt;br /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Immagina un cerchio che contenga tutta la conoscenza umana:&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_jirf_lIaB2M/TGuc4cW1twI/AAAAAAAAAFA/66wN3q6vseI/s1600/PhDKnowledge.001.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/_jirf_lIaB2M/TGuc4cW1twI/AAAAAAAAAFA/66wN3q6vseI/s320/PhDKnowledge.001.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Nel momento in cui finisci la scuola elementare, tu ne conosci un po':&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/_jirf_lIaB2M/TGudJayUoPI/AAAAAAAAAFE/oJ6gZSCwiTI/s1600/PhDKnowledge.002.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/_jirf_lIaB2M/TGudJayUoPI/AAAAAAAAAFE/oJ6gZSCwiTI/s320/PhDKnowledge.002.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Quando finisci la scuola superiore, ne sai un po' di più:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/_jirf_lIaB2M/TGudXwh640I/AAAAAAAAAFI/oHFZh4o9HsQ/s1600/PhDKnowledge.003.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/_jirf_lIaB2M/TGudXwh640I/AAAAAAAAAFI/oHFZh4o9HsQ/s320/PhDKnowledge.003.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Con una Laurea Triennale acquisisci una specialità:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_jirf_lIaB2M/TGudxN2bpGI/AAAAAAAAAFM/nyZcHm0hP2g/s1600/PhDKnowledge.004.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/_jirf_lIaB2M/TGudxN2bpGI/AAAAAAAAAFM/nyZcHm0hP2g/s320/PhDKnowledge.004.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Una Laurea Specialistica (o Master) approfondisce questa specialità:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_jirf_lIaB2M/TGud6pRshhI/AAAAAAAAAFQ/-rFfMwUl2nI/s1600/PhDKnowledge.005.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_jirf_lIaB2M/TGud6pRshhI/AAAAAAAAAFQ/-rFfMwUl2nI/s320/PhDKnowledge.005.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Leggere pubblicazioni scientifiche ti porta al bordo della conoscenza umana:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_jirf_lIaB2M/TGueQehUzdI/AAAAAAAAAFU/SDWiNH2G92s/s1600/PhDKnowledge.006.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_jirf_lIaB2M/TGueQehUzdI/AAAAAAAAAFU/SDWiNH2G92s/s320/PhDKnowledge.006.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Una volta arrivato al limite, metti a fuoco:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_jirf_lIaB2M/TGueiZHKymI/AAAAAAAAAFY/nX579GcTcp4/s1600/PhDKnowledge.007.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_jirf_lIaB2M/TGueiZHKymI/AAAAAAAAAFY/nX579GcTcp4/s320/PhDKnowledge.007.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Spingi al limite per alcuni anni:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_jirf_lIaB2M/TGufHsqe5-I/AAAAAAAAAFc/0m_HQLw2Q58/s1600/PhDKnowledge.008.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_jirf_lIaB2M/TGufHsqe5-I/AAAAAAAAAFc/0m_HQLw2Q58/s320/PhDKnowledge.008.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Finché un giorno il confine cede:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_jirf_lIaB2M/TGufUpQ3rJI/AAAAAAAAAFg/ss50MHf6_-c/s1600/PhDKnowledge.009.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/_jirf_lIaB2M/TGufUpQ3rJI/AAAAAAAAAFg/ss50MHf6_-c/s320/PhDKnowledge.009.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;E, quell'ammaccatura che avete prodotto si chiama dottorato di ricerca (PhD):&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/_jirf_lIaB2M/TGufnchCPnI/AAAAAAAAAFk/6Z-dlyf7aUc/s1600/PhDKnowledge.010.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/_jirf_lIaB2M/TGufnchCPnI/AAAAAAAAAFk/6Z-dlyf7aUc/s320/PhDKnowledge.010.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Naturalmente, il mondo vi sembrerà diverso ora:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/_jirf_lIaB2M/TGufxuqZahI/AAAAAAAAAFo/7xPsmh0WDTY/s1600/PhDKnowledge.011.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/_jirf_lIaB2M/TGufxuqZahI/AAAAAAAAAFo/7xPsmh0WDTY/s320/PhDKnowledge.011.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Perciò, non dimenticate l'immagine più grande:&lt;/span&gt;&lt;br style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;" /&gt;&lt;div class="separator" style="clear: both; color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_jirf_lIaB2M/TGugA8l15YI/AAAAAAAAAFs/sey0-k7ER9s/s1600/PhDKnowledge.012.jpg" imageanchor="1" style="color: #004b91; margin-left: 1em; margin-right: 1em; text-decoration: initial;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_jirf_lIaB2M/TGugA8l15YI/AAAAAAAAAFs/sey0-k7ER9s/s320/PhDKnowledge.012.jpg" style="border: 3px solid rgb(238, 238, 238);" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;Continuate a spingere e a creare ammaccature.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #333333; font-family: arial, helvetica, tahoma; font-size: 14px; line-height: 22.399999618530273px;"&gt;&lt;b&gt;Fonte&lt;/b&gt;:&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #333333; font-family: Georgia;"&gt;&lt;a href="http://matt.might.net/" target="_blank"&gt;Matt Might&lt;/a&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #333333;"&gt;http://matt.might.net/articles/phd-school-in-pictures/&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/E4XHpKLkzzA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/6639223847309002997/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/11/cose-un-dottorato-e-la-ricerca-in.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6639223847309002997?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6639223847309002997?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/E4XHpKLkzzA/cose-un-dottorato-e-la-ricerca-in.html" title="Cos'è un dottorato e la ricerca in generale?" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_jirf_lIaB2M/TGuc4cW1twI/AAAAAAAAAFA/66wN3q6vseI/s72-c/PhDKnowledge.001.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/11/cose-un-dottorato-e-la-ricerca-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIFQXs5eyp7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-983445740671138331</id><published>2012-06-30T23:23:00.000+02:00</published><updated>2012-07-01T11:21:50.523+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T11:21:50.523+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MATLAB" /><category scheme="http://www.blogger.com/atom/ns#" term="Grafica" /><category scheme="http://www.blogger.com/atom/ns#" term="POV-Ray" /><title>POV-Ray / MATLAB - Metodo alternativo per creare una mappa di profondità (non-omogenea) di una scena</title><content type="html">Nel &lt;a href="http://sic-oding.blogspot.co.uk/2012/06/pov-ray-creare-una-mappa-di-profondita.html" target="_blank"&gt;precedente articolo&lt;/a&gt;&amp;nbsp;abbiamo creato delle sub-mappe in POV-Ray, per poi creare una mappa di profondità non-omogenea &lt;a href="http://sic-oding.blogspot.co.uk/2012/06/matlab-creare-una-mappa-di-profondita.html" target="_blank"&gt;utilizzando&lt;/a&gt; MATLAB.&lt;br /&gt;
&lt;br /&gt;
Tuttavia, il procedimento di disabilitare tutte le textures in POV-Ray può risultare lungo e delle volte anche complicato. Nel seguente articolo illustrerò brevemente come riuscire ad ottenere lo stesso risultato combinando POV-Ray e MATLAB.&lt;br /&gt;
&lt;br /&gt;
Per prima cosa bisogna creare una &lt;i&gt;union&lt;/i&gt; di tutti gli oggetti della vostra scena. A quel punto basta "tagliare" la scena intersecandola con un&amp;nbsp;parallelepipedo.&lt;br /&gt;
Fin qui tutto bene, tranne per il semplice fatto che non è possibile assegnare un valore di grigio direttamente da POV-Ray. Cosa che, invece, era possibile ottenere con il metodo precedente.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;POV-Ray
&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;div class="p1"&gt;
&lt;span style="font-size: 12px;"&gt;#declare enableSlicing = 1;
&lt;span style="font-size: 12px;"&gt;#if (enableSlicing = 1)
background {color rgbt 1}
&lt;span style="font-size: 12px;"&gt;#end


&lt;span style="font-size: 12px;"&gt;#declare allObjects = union {
&lt;span style="font-size: 12px;"&gt;      Oggetto 1
&lt;span style="font-size: 12px;"&gt;      Oggetto 2
&lt;span style="font-size: 12px;"&gt;      ...
&lt;span style="font-size: 12px;"&gt;      Oggetto n
&lt;span style="font-size: 12px;"&gt;} // Fine Union
&lt;span style="font-size: 12px;"&gt;
&lt;/span&gt;

&lt;span style="font-size: 12px;"&gt;#if (enableSlicing = 1)
intersection {
object {allObjects}
box { 
 &amp;lt; -1000, -1000, startCut&amp;gt;,
 &amp;lt;1000, 1000, endCut&amp;gt;
}
finish {ambient 1 diffuse 0}
}
#else
object {allObjects}
#end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Il codice sottostante è uno script per MATLAB (o Octave) che colora la parte interessata di una sub-mappa utilizzando il grigio appropriato. La formula per calcolare il valore del grigio di una specifica scena è la stessa utilizzata negli articoli precedenti.&lt;br /&gt;
&lt;pre class="brush:java"&gt; 
function Graying(nameFile, totalNumberSubMaps)

rgbCoeff = 255;

offsetLevels = rgbCoeff / (totalNumberSubMaps - 1);

for index = 0:totalNumberSubMaps - 1

    rgbColor = floor(abs(((index) * offsetLevels) - rgbCoeff));

    rgbColor = rgbColor / 255;

    nameMapFile = nameFile; 


    % TODO: Script per aggiungere un suffisso a nameMapFile.

    [A, map, Alpha] = imread(strcat(nameMapFile, '.png'));

    [h, w] = size(Alpha);

    subMap = zeros(h, w, 0);

    modified = 0;

    for i=1:h

        for j=1:w

            if Alpha(i, j) ~= 0

                modified = 1;

                subMap(i, j, 1) = rgbColor;

                subMap(i, j, 2) = rgbColor;

                subMap(i, j, 3) = rgbColor;

            end

        end

    end

    % Salva la nuova sub-mappa.

    if modified == 1

        imwrite(subMap, strcat(nameMapFile, 'MAP', '.png'));

    end

end
&lt;/pre&gt;
&lt;script src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlightLoader.js"&gt;
&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/3nQ3d-mphn0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/983445740671138331/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/06/pov-ray-matlab-metodo-alternativo-per.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/983445740671138331?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/983445740671138331?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/3nQ3d-mphn0/pov-ray-matlab-metodo-alternativo-per.html" title="POV-Ray / MATLAB - Metodo alternativo per creare una mappa di profondità (non-omogenea) di una scena" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/06/pov-ray-matlab-metodo-alternativo-per.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YHQHw7fip7ImA9WhJTF0U.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-1704349980083460503</id><published>2012-06-27T10:18:00.001+02:00</published><updated>2012-06-27T10:18:51.206+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-27T10:18:51.206+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Sicurezza" /><category scheme="http://www.blogger.com/atom/ns#" term="Network" /><category scheme="http://www.blogger.com/atom/ns#" term="HTTP" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><title>Facebook / Sicurezza - Ritrovare la propria password</title><content type="html">&lt;div style="text-align: justify;"&gt;
Facebook ormai è utilizzato quotidianamente da milioni e milioni di persone. Il Social Network è così utilizzato che molti utenti vi accedono permettendo al proprio browser di ricordarne la password.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&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; &lt;a href="http://1.bp.blogspot.com/-ry0C-Ncdr48/T-q-002UVtI/AAAAAAAAAMc/V3dRL7MWFnU/s1600/Schermata+2012-06-27+a+09.05.19.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-ry0C-Ncdr48/T-q-002UVtI/AAAAAAAAAMc/V3dRL7MWFnU/s1600/Schermata+2012-06-27+a+09.05.19.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Eppure quante volte vi sarà capitato di domandarvi quale password oscura si nasconda lì dietro? Dopotutto capita spesso di dimenticarsi la propria password.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Oggi vi mostrerò come recuperarla utilizzando Chrome (funziona anche su Safari).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Step1&lt;/b&gt;: Prima di accedere a Facebook, aprite gli &lt;i&gt;Strumenti per Sviluppatori&lt;/i&gt; di Chrome (Visualizza-&amp;gt;Opzioni Per Sviluppatori-&amp;gt;&amp;nbsp;&lt;span style="background-color: white;"&gt;Strumenti per Sviluppatori). E selezionate la linguetta &lt;i&gt;Network&lt;/i&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;a href="http://2.bp.blogspot.com/-vedvSHLVPUw/T-rAVih-WRI/AAAAAAAAAMk/IMW-bOh7ET4/s1600/Schermata+2012-06-27+a+09.10.58.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-vedvSHLVPUw/T-rAVih-WRI/AAAAAAAAAMk/IMW-bOh7ET4/s1600/Schermata+2012-06-27+a+09.10.58.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Step2&lt;/b&gt;: Fare il login e ritrovarsi nella seguente situazione:&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Eo-soKQDS1c/T-rBCGrhB_I/AAAAAAAAAMs/fmJPDSOWIOQ/s1600/Schermata+2012-06-27+a+09.14.27.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-Eo-soKQDS1c/T-rBCGrhB_I/AAAAAAAAAMs/fmJPDSOWIOQ/s1600/Schermata+2012-06-27+a+09.14.27.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Step3&lt;/b&gt;: Recuperate la vostra password. Selezionare login.php dalla colonna all'estrema sinistra. Alla vostra destra comparirà la richiesta &lt;i&gt;POST&lt;/i&gt; da parte vostra a Facebook.com . Nella sezione &lt;b&gt;Form Data&lt;/b&gt; troverete e-mail e password.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-tUBDH4OxDp0/T-rBq_hdVpI/AAAAAAAAAM0/qiHIeXYcmq4/s1600/Schermata+2012-06-27+a+09.17.32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="241" src="http://3.bp.blogspot.com/-tUBDH4OxDp0/T-rBq_hdVpI/AAAAAAAAAM0/qiHIeXYcmq4/s320/Schermata+2012-06-27+a+09.17.32.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Facile vero? Ci si legge!&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/a32itHdGD5o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/1704349980083460503/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/06/facebook-sicurezza-ritrovare-la-propria.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/1704349980083460503?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/1704349980083460503?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/a32itHdGD5o/facebook-sicurezza-ritrovare-la-propria.html" title="Facebook / Sicurezza - Ritrovare la propria password" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ry0C-Ncdr48/T-q-002UVtI/AAAAAAAAAMc/V3dRL7MWFnU/s72-c/Schermata+2012-06-27+a+09.05.19.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/06/facebook-sicurezza-ritrovare-la-propria.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4ERnY8fSp7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-8193846891078665593</id><published>2012-06-24T12:18:00.001+02:00</published><updated>2012-07-01T12:18:27.875+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T12:18:27.875+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><title>JavaZone 2012 - Che Spot!</title><content type="html">JavaZone è un "meeting" per sviluppatori Java ed è il più importante dei paesi Scandinavi e fra i più importanti in Europa.&lt;br /&gt;
Il JavaZone consiste in interviste ai massimi esperti del settore, workshops, e presentazioni per un totale di 200mila ore di divulgazione in soli due giorni!&lt;br /&gt;
&lt;br /&gt;
Il JavaZone 2012 si terrà il 12-13 Settembre 2012 nell'Oslo Spektrum (Oslo, Norvegia) e se siete abbastanza fortunati potreste trovare ancora dei ticket disponibili (vedi &lt;b&gt;Fonti&lt;/b&gt; a fine pagina).&lt;br /&gt;
&lt;br /&gt;
Negli ultimi anni il JavaZone ha sfruttato l'onda Youtube per pubblicizzarsi in modo alquanto bizzarro:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JavaZone 2012&lt;/b&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://0.gvt0.com/vi/HXvm76e2X1Q/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/HXvm76e2X1Q&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;param name="allowFullScreen" value="true" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/HXvm76e2X1Q&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JavaZone 2011&lt;/b&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://2.gvt0.com/vi/5U1_KW6ww7Y/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/5U1_KW6ww7Y&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;param name="allowFullScreen" value="true" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/5U1_KW6ww7Y&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;JavaZone 2012&lt;/b&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://3.gvt0.com/vi/AjxWeZg-_F8/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/AjxWeZg-_F8&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;param name="allowFullScreen" value="true" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/AjxWeZg-_F8&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://3.gvt0.com/vi/Mt7zsortIXs/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Mt7zsortIXs&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;param name="allowFullScreen" value="true" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/Mt7zsortIXs&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;a href="http://jz12.java.no/about" target="_blank"&gt;JavaZone&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/yItb9CV76X4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/8193846891078665593/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/06/javazone-2012-che-spot.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8193846891078665593?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8193846891078665593?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/yItb9CV76X4/javazone-2012-che-spot.html" title="JavaZone 2012 - Che Spot!" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/06/javazone-2012-che-spot.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UNQn45fyp7ImA9WhJTFU8.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-3515829964101487584</id><published>2012-06-24T11:13:00.003+02:00</published><updated>2012-06-24T11:14:53.027+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-24T11:14:53.027+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MATLAB" /><category scheme="http://www.blogger.com/atom/ns#" term="Algoritmi" /><category scheme="http://www.blogger.com/atom/ns#" term="Octave" /><category scheme="http://www.blogger.com/atom/ns#" term="Grafica" /><category scheme="http://www.blogger.com/atom/ns#" term="POV-Ray" /><title>MATLAB - Creare una mappa di profondità (non-omogenea) di una scena</title><content type="html">Salve!&lt;br /&gt;
&lt;br /&gt;
Nel precedente &lt;a href="http://sic-oding.blogspot.co.uk/2012/06/pov-ray-creare-una-mappa-di-profondita.html" target="_blank"&gt;articolo&lt;/a&gt;&amp;nbsp;ho illustrato come creare delle "sub-mappe" utilizzando POV-Ray ed eravamo arrivati ad un punto cruciale in cui ci ritrovavamo con tanti tasselli da mettere insieme.&lt;br /&gt;
&lt;br /&gt;
L'obiettivo di oggi è riuscire a sovra-imporre le nostre sub-mappe per creare una mappa di profondità come quella qui sotto.&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/-fLQ47vVq8OM/T9KDEIU-JMI/AAAAAAAAAMQ/NgBJEBh-0-4/s1600/finalMap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://3.bp.blogspot.com/-fLQ47vVq8OM/T9KDEIU-JMI/AAAAAAAAAMQ/NgBJEBh-0-4/s400/finalMap.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Per fare ciò utilizzeremmo MATLAB (potete anche usare Octave che è gratuito).&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Per prima cosa apriamo un nuovo scrip vuoto (File-&amp;gt;New-&amp;gt;Script) e utilizziamo il codice sottostante per caricare le sub-mappe da sovra-imporre.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;div class="p2"&gt;
numeroSubMappe = 100;&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;span class="s1"&gt;mappaEsempio = &lt;/span&gt;'TEST.png'&lt;span class="s1"&gt;; // usiamo questa mappa per ottenere le dimensioni (h,w) da usare&lt;/span&gt;&lt;/div&gt;
&lt;div class="p2"&gt;
[A, mappa, Alpha] =&amp;nbsp; imread(mappaEsempio);&lt;/div&gt;
&lt;div class="p2"&gt;
[h, w] = size(Alpha); // Otteniamo altezza e larghezza dalla matrice contenente informazioni sul canale Alpha dell'immagine. &lt;/div&gt;
&lt;div class="p2"&gt;
listaSubMappe = {}; // Inizializziamo la lista delle sub-mappe da caricare.&lt;/div&gt;
&lt;div class="p2"&gt;
listaSubMappeAlpha = zeros(h, w, 0); // Inizializziamo il primo elemento di questa lista con degli zero.&lt;/div&gt;
&lt;div class="p3"&gt;

&lt;/div&gt;
// Carichiamo le sub-mappe.
&lt;div class="p2"&gt;
&lt;span class="s2"&gt;for&lt;/span&gt; i = 1: numeroSubMappe &lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; nomeSubMappa = &lt;span class="s3"&gt;'sub-mappa'&lt;/span&gt;;&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; nomeSubMappa = strcat(nomeSubMappa, num2str(i), &lt;span class="s3"&gt;'.png'&lt;/span&gt;);&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; [A, sub-mappa, Alpha] =&amp;nbsp; imread(nomeSubMappa);&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; listaSubMappeAlpha(:, :, i) = Alpha;&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; listaSubMappe{i} = A; // A è l'immagine in se stessa. &lt;/div&gt;
&lt;div class="p4"&gt;
end&lt;/div&gt;
&lt;div class="p5"&gt;
&lt;/div&gt;
&lt;div class="p5"&gt;
// Inizializziamo lo sfondo della mappa finale utilizzando il colore NERO. Il NERO indica il taglio eseguito in POV-Ray più distante dalla telecamera.  &lt;/div&gt;
immagineFinale = zeros(h, w);
&lt;div class="p6"&gt;
&lt;/div&gt;
&lt;div class="p2"&gt;
&lt;span class="s2"&gt;for&lt;/span&gt; i = 1:h&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; &lt;span class="s2"&gt;for&lt;/span&gt; j = 1:w&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 1) = 0; // R&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 2) = 0; // G &lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 3) = 0; // B&lt;/div&gt;
&lt;div class="p2"&gt;
&amp;nbsp; &amp;nbsp; &lt;span class="s2"&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
end&lt;/div&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
Adesso sovra-imponiamo le immagini dalla penultima alla prima. Il procedimento inizia dal penultimo taglio al primo così da "nascondere" quelle parti della scena che non sono mai visibili all'occhio umano perché dietro ad altri oggetti.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;div class="p2"&gt;
&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;span class="s1"&gt;for&lt;/span&gt; n = 0: numeroSubMappe - 1&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; mappaAlpha = listaSubMappeAlpha(:, :, numeroSubMappe - n); // Utilizziamo la mappaAlpha per conoscere la forma degli oggetti tagliati da POV-Ray al taglio (numeroSubMappe - n)&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; mappa = listaSubMappe{1, numeroSubMappe - n}; // Utilizziamo la mappa per conoscere il grigio da usare.&lt;/div&gt;
&lt;div class="p2"&gt;
&lt;/div&gt;
// Itera la sub-mappa in lungo e in largo.
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;for&lt;/span&gt; i = 1:h&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;for&lt;/span&gt; j = 1:w&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;if&lt;/span&gt; (mappaAlpha(i, j) ~= 0) // Controlla se il taglio ha intersecato un'oggetto o meno. &lt;/div&gt;
&lt;div class="p1"&gt;
&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grigioDaUsare =&amp;nbsp; mappa(i, j, 1); // Otteniamo il grigio da usare. Il grigio era già stato calcolato su POV-Ray.&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grigioDaUsare = double (grigioDaUsare) / 255.0; // In MATLAB i valori RGB sono compresi fra 0.0 e 1.0. Quindi dobbiamo dividere il nostra valore per 255.0 .&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 1) =  grigioDaUsare; // R&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 2) =&amp;nbsp; grigioDaUsare; // G&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; immagineFinale(i, j, 3) =&amp;nbsp; grigioDaUsare; // B&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &lt;span class="s1"&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div class="p2"&gt;
end&lt;/div&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Adesso abbiamo una matrice (immagineFinale) che rappresenta la nostra mappa di profondità. L'unica cosa che ci rimane da fare è salvare la matrice come un'immagine e il gioco è fatto.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;div class="p1"&gt;
imwrite(immagineFinale, 'MAPPA_FINALE.png');&lt;/div&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alla prossima ;)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;a href="http://www.mathworks.co.uk/products/matlab/"&gt;MATLAB&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/u-1qBE-7YPI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/3515829964101487584/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/06/matlab-creare-una-mappa-di-profondita.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3515829964101487584?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3515829964101487584?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/u-1qBE-7YPI/matlab-creare-una-mappa-di-profondita.html" title="MATLAB - Creare una mappa di profondità (non-omogenea) di una scena" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-fLQ47vVq8OM/T9KDEIU-JMI/AAAAAAAAAMQ/NgBJEBh-0-4/s72-c/finalMap.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/06/matlab-creare-una-mappa-di-profondita.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcGR307cSp7ImA9WhVaEUQ.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-4411898194127305831</id><published>2012-06-08T21:52:00.001+02:00</published><updated>2012-06-09T00:53:46.309+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-09T00:53:46.309+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Grafica" /><category scheme="http://www.blogger.com/atom/ns#" term="POV-Ray" /><title>POV-Ray - Creare una mappa di profondità (non-omogenea) di una scena</title><content type="html">&lt;div style="text-align: justify;"&gt;
Nel precedente articolo -&amp;nbsp;&lt;span style="font-size: small;"&gt;&lt;a href="http://sic-oding.blogspot.co.uk/2012/04/pov-ray-creare-una-mappa-di-profondita.html"&gt;POV-Ray - Creare una mappa di profondità (omogenea) di una scena&lt;/a&gt;&amp;nbsp;- è stato illustrato come creare delle prime semplici mappe di profondità in POV-Ray. Nel seguente articolo, invece, spiegherò come creare delle mappe di profondità non-omogenee (vedi immagine).&lt;/span&gt;&lt;a href="http://www.blogger.com/"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-ycKOTDSQWrU/T9JR_LUVZII/AAAAAAAAALw/qRPqi8jynxc/s1600/finalMap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://4.bp.blogspot.com/-ycKOTDSQWrU/T9JR_LUVZII/AAAAAAAAALw/qRPqi8jynxc/s400/finalMap.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
La scena originale è composta da cinque oggetti elementari disposti su un piano orizzontale che tende ad infinito.&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/-kOyIIm8ypd8/T9JSs_h7KEI/AAAAAAAAAL4/AXLRMdwgi3o/s1600/tutorial6_2Backup.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://3.bp.blogspot.com/-kOyIIm8ypd8/T9JSs_h7KEI/AAAAAAAAAL4/AXLRMdwgi3o/s400/tutorial6_2Backup.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
L'intera scena viene considerata come un solo oggetto nel seguente modo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;code style="word-wrap: normal;"&gt;#declare INTERA_SCENA = union {
&lt;/code&gt;     Oggetto 1
     Oggetto 2
     ...
     Oggetto N
}&lt;/pre&gt;
&lt;div&gt;
&lt;code style="word-wrap: normal;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;span style="text-align: -webkit-auto;"&gt;La scena quindi viene "tagliata" a una determinata profondità da un "sottile" parallelepipedo e vengono tenute in considerazione solo le parti intersecanti con l'intera scena. Inoltre la parte rimasta viene colorata utilizzando un determinato grigio (eliminando riflessi e ombre).&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-bdWELVolTxU/T9JUURUU8_I/AAAAAAAAAME/qVVm7-KE3Wo/s1600/tutorial6_2021.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://1.bp.blogspot.com/-bdWELVolTxU/T9JUURUU8_I/AAAAAAAAAME/qVVm7-KE3Wo/s400/tutorial6_2021.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;Quest'operazione è riassumibile in queste poche linee di codice:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;&lt;code style="word-wrap: normal;"&gt;intersection {
   INTERA_SCENA
    
   // Parallelepipedo.
   box {
       &amp;lt;500, -500, inizioTaglioZDepth&amp;gt;, 
       &amp;lt;-500, 500, fineTaglioZDepth&amp;gt;
   }

   pigment {
       rgb&amp;lt;rgbColor / rgbCoeff, rgbColor / rgbCoeff, rgbColor / rgbCoeff&amp;gt; // Grigio da usare per il taglio. 
   }
   finish {ambient 1 diffuse 0} // Colore uniforme al taglio.

}&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;code style="word-wrap: normal;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;L'operazione deve essere eseguita un determinata numero di volte, così da poter sezionare tutti gli elementi della scena e con diversi grigi. Quindi non andremmo semplicemente a Renderizzare ogni scena manualmente, ma utilizzeremo l'opzione ANIMATION di POV-Ray.&lt;br /&gt;&lt;br /&gt;Nel mio esempio ho attivato l'orologio con i seguenti parametri:&lt;br /&gt;Clock Initial = 0.0, Clock End = 1&lt;br /&gt;Initial Frame = 1, Final Frame = 100.&lt;br /&gt;&lt;br /&gt;Quindi l'orologio avanzerà di 0.01 alla fine di ogni renderizzazione per ben 100 volte.&lt;br /&gt;Utilizzando il valore di clock è possibile calcolare i valori dei "tagli", come anche i valori dei grigi.&lt;/span&gt;&lt;br /&gt;
&lt;pre style="background-color: #f7f7f7; border: 1px dashed rgb(204, 204, 204); font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 646px;"&gt;#declare rgbCoeff = 255;
#declare numeroMappe = 100;
#declare indiceMappa = clock * numberoMappe + 1;
#declare offsetLevels = rgbCoeff / (numberoMappe - 1);
#declare rgbColor = floor(abs(((indiceMappa -1) * offsetLevels) - rgbCoeff));
#declare offsetTaglio = 0.35;
#declare inizioTaglioZDepth = offsetTaglio * clock * numeroMappe;
#declare fineTaglioZDepth = offsetTaglio * (clock + 0.01) * numberMaps;&lt;/pre&gt;
&lt;div&gt;
&lt;code style="word-wrap: normal;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;Inoltre, per un risultato eccellente è bene ricordarsi di disattivare l'Anti-Aliasing.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red; font-family: inherit;"&gt;PANICO!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Adesso vi ritrovate con 100 mappe e non sapete che farne! Tranquilli, nel prossimo articolo illustrerò come mettere il tutto insieme utilizzando MATLAB.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/Ab4AMTtianw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/4411898194127305831/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/06/pov-ray-creare-una-mappa-di-profondita.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4411898194127305831?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4411898194127305831?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/Ab4AMTtianw/pov-ray-creare-una-mappa-di-profondita.html" title="POV-Ray - Creare una mappa di profondità (non-omogenea) di una scena" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-ycKOTDSQWrU/T9JR_LUVZII/AAAAAAAAALw/qRPqi8jynxc/s72-c/finalMap.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/06/pov-ray-creare-una-mappa-di-profondita.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MFRn87eyp7ImA9WhVWFkg.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-2979758392419600908</id><published>2012-04-29T01:23:00.000+02:00</published><updated>2012-04-29T01:23:37.103+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-29T01:23:37.103+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="OpenGL" /><category scheme="http://www.blogger.com/atom/ns#" term="Mac OS X" /><title>C - Sensore di movimento dei MacBook</title><content type="html">Nel seguente articolo parlerò del SMS: Sudden Motion Sensor. L'SMS è un sensore che è possibile trovare negli ultimi modelli dei portatili di casa Apple.&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;span style="background-color: white; color: #444444; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 11px; line-height: 18px;"&gt;All Intel-based Apple portables such as the MacBook, MacBook Pro, MacBook Air, PowerBook G4 computers starting with PowerBook G4 (12-inch 1.5GHz), PowerBook G4 (15-inch 1.67/1.5GHz), PowerBook G4 (17-inch 1.67GHz), and iBook G4 computers starting with iBook G4 (Mid 2005) have Sudden Motion Sensor technology.&lt;/span&gt;&lt;/blockquote&gt;
Questo sensore è stato progettato per rilevare movimenti inusuali del computer, così da ibernare temporaneamente l'hard disk ed evitare danneggiamenti su quest'ultimo.&lt;br /&gt;
&lt;br /&gt;
Questa caratteristica unica dei Mac può essere usata per tanti fini. Un fine sicuramente molto stimolante è quello dei giochi. Il video qui sotto mostra un giochino molto semplice, ma da sicuramente un'idea di cosa sia possibile creare.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object width="320" height="266" class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://2.gvt0.com/vi/j8MZhfqg5eY/0.jpg"&gt;&lt;param name="movie" value="http://www.youtube.com/v/j8MZhfqg5eY&amp;fs=1&amp;source=uds" /&gt;
&lt;param name="bgcolor" value="#FFFFFF" /&gt;
&lt;embed width="320" height="266"  src="http://www.youtube.com/v/j8MZhfqg5eY&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Questa semplice applicazione è stata creata utilizzando parte del progetto OpenSource &lt;a href="http://unimotion.sourceforge.net/" target="_blank"&gt;UniMotion&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://sic2@github.com/sic2/SMS.git" target="_blank"&gt;Qui&lt;/a&gt;&amp;nbsp;potete trovare l'implementazione di un'applicazione scritta da me che spero vi semplifichi l'utilizzo dell'SMS.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
Wikipedia:&lt;br /&gt;
http://it.wikipedia.org/wiki/Sudden_Motion_Sensor&lt;br /&gt;
&lt;br /&gt;
Unimotion:&lt;br /&gt;
http://unimotion.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
Apple:&lt;br /&gt;
http://support.apple.com/kb/HT1935&lt;br /&gt;
http://support.apple.com/kb/HT1934&lt;br /&gt;
&lt;br /&gt;
Altro:&lt;br /&gt;
http://www.shiffman.net/p5/sms/&lt;br /&gt;
&lt;br /&gt;
Per Python:&lt;br /&gt;
http://giasone.wordpress.com/tag/sudden-motion-sensor/&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/9jN5ZbCzXLM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/2979758392419600908/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/04/c-sensore-di-movimento-dei-macbook.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/2979758392419600908?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/2979758392419600908?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/9jN5ZbCzXLM/c-sensore-di-movimento-dei-macbook.html" title="C - Sensore di movimento dei MacBook" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/04/c-sensore-di-movimento-dei-macbook.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcCQX49fCp7ImA9WhVaEUQ.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-5193561171255841962</id><published>2012-04-25T22:40:00.001+02:00</published><updated>2012-06-09T00:54:20.064+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-09T00:54:20.064+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Grafica" /><category scheme="http://www.blogger.com/atom/ns#" term="POV-Ray" /><title>POV-Ray - Creare una mappa di profondità (omogenea) di una scena</title><content type="html">&lt;div style="text-align: justify;"&gt;
POV-Ray è un programma di &lt;a href="http://it.wikipedia.org/wiki/Ray_tracing" target="_blank"&gt;ray-tracing&lt;/a&gt; per creare scene virtuali molto realistiche, quasi fotografiche.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
POV-Ray, che a prima impressione fa pensare al suo cugino &lt;a href="http://www.blender.org/" target="_blank"&gt;Blender&lt;/a&gt;, è privo di un'interfaccia grafica molto "eccitante".&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Tuttavia POV-Ray si dimostra essere uno strumento molto potente perché permette al grafico di creare qualsiasi scena possibile e inimmaginabile, dato che ogni scena (dalla più piccola alla più complessa) viene generata utilizzando un linguaggio di script apposito. Qualcuno potrà non essere d'accordo con me, ma quando si programma non esistono limiti, diversamente da quando ci si affida interamente a uno strumento di supporto ad oggetti.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Nel seguente articolo spiegherò come creare una mappa di profondità di tipo omogenea per una data scena. Prima però mi sembra opportuno dare un pò di spazio ad alcune immagini molto belle, così da assaporare un pò le potenzialità di POV-Ray.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-1OlW6GcOo6k/T5hXHQyqlOI/AAAAAAAAAKQ/6YCf9AK3lBE/s1600/sherk-collins.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://4.bp.blogspot.com/-1OlW6GcOo6k/T5hXHQyqlOI/AAAAAAAAAKQ/6YCf9AK3lBE/s400/sherk-collins.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Y4tQRL5JKYo/T5hXI7JE_3I/AAAAAAAAAKY/NPvzDY-y4-o/s1600/mouille.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://2.bp.blogspot.com/-Y4tQRL5JKYo/T5hXI7JE_3I/AAAAAAAAAKY/NPvzDY-y4-o/s400/mouille.jpg" width="300" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
La generazione di ognuna di queste immagini è molto complessa e richiede almeno un paio di minuti. La qualità ha un suo prezzo, motivo in più per cui POV-Ray non è utilizzato nello sviluppo della grafica dei giochi.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Una mappa di profondità di una scena è solitamente utilizzata come metro per misurare la profondità di un determinato pixel, in un'immagine che alla fin fine è pur sempre in 2D.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Nell'esempio sottostante possiamo vedere come le zone bianche indicano gli oggetti più vicini. Man mano che si muove nelle zone più distanti della scena, la mappa di profondità tende verso il nero.&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-YryWdX_S7tM/T5hZfIs8NxI/AAAAAAAAAK8/jpFvjGUL-l0/s1600/chessRGB.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-YryWdX_S7tM/T5hZfIs8NxI/AAAAAAAAAK8/jpFvjGUL-l0/s320/chessRGB.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-HWLWB2ZJbLU/T5hZes4gxQI/AAAAAAAAAK4/SjKK1-JSeM8/s1600/chessDM.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-HWLWB2ZJbLU/T5hZes4gxQI/AAAAAAAAAK4/SjKK1-JSeM8/s320/chessDM.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-size: xx-small;"&gt;Le due immagini soprastanti sono state elaborate su Adobe Photoshop (plugin DOF-Pro).&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Come creare una propria mappa di profondità con POV-Ray? Prima di tutto creiamo la nostra scena.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-wvI1As5py9M/T5ha3_GbExI/AAAAAAAAALQ/w5JWEho-Rtg/s1600/tutorial6_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-wvI1As5py9M/T5ha3_GbExI/AAAAAAAAALQ/w5JWEho-Rtg/s320/tutorial6_1.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Questa scena è ottenuta utilizzando il codice sottostante. Per evitare di riscrivere il codice per la scena in se stessa e per creare la mappa di profondità ho utilizzato degli if-statement, che mi permettono di attivare e disattivare alcune porzioni di codice al bisogno.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre style="background: #f7f7f7; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 99%;"&gt;&lt;code style="color: black; word-wrap: normal;"&gt;#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
  
// Se generateMaps = false -&amp;gt; scena normale
// Se generateMaps = true -&amp;gt; mappa di profondità
#declare generateMaps = false;
    
light_source { &amp;lt;5, 30, -30&amp;gt; color White }
camera {
 location &amp;lt;0.0, 1.0, -10.0&amp;gt;
 look_at  &amp;lt;0.0, 1.0,  0.0&amp;gt;
 focal_point &amp;lt; 1, 1, -6&amp;gt;   
}


// Union to represent the entire scene
union {
 sphere {
  &amp;lt;-2, 0, -6&amp;gt;, 0.5
  
  #if (!generateMaps)
     pigment { NeonPink }
  #end
 }    

 box {
  &amp;lt;4, -2, 0&amp;gt;, &amp;lt; 6,  2,  3&amp;gt;
  rotate &amp;lt;0, -20, 0&amp;gt;

  #if (!generateMaps)
     pigment { Green }
  #end
   
 }       
 
 difference {
        box {
         -1,   1        
         #if (!generateMaps)
            pigment { Red }
         #end
          }
        cylinder {
         -1.0001*z, 1.0001*z, 0.5 
          #if (!generateMaps)
            pigment { Green }
          #end         
        }
 }

 #if (generateMaps)
 pigment {
  gradient z
  pigment_map {
   [ 0.0 White]
   [ 1.0 Black ]
  }
  scale &amp;lt;1, 1, 30&amp;gt;
  translate -10*z
 
 }
 finish {
  ambient 1
  diffuse 0
  specular 0
  phong 0
 }
 #end
 
}  // end union
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
Osserviamo che quando la variabile generateMaps è attivata (true) le textures degli oggetti delle scene sono disattivate, ed è attivata la seguente porzione di codice:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background: #f7f7f7; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; overflow: auto; padding: 0px; text-align: left; width: 99%;"&gt;&lt;code style="word-wrap: normal;"&gt;pigment {
  gradient z
  pigment_map {
   [ 0.0 White]
   [ 1.0 Black ]
  }
  scale &amp;lt;1, 1, 30&amp;gt;
  translate -10*z
 
 }
 finish {
  ambient 1
  diffuse 0
  specular 0
  phong 0
 }&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
Qui viene applicato un "pigmento" che transita dal Bianco al Nero lungo tutta la profondità (da z = -10 at z = 20).&lt;br /&gt;
Inoltre, impostando &lt;i&gt;ambient 1&lt;/i&gt; e &lt;i&gt;diffuse 0&lt;/i&gt;, rimuoviamo qualsiasi ombra creata tra gli oggetti nella scena.&lt;br /&gt;
Ed ecco il risultato finale:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-_CXLqKndzd8/T5heZ5EqjlI/AAAAAAAAALc/4YC2NQ8mOGY/s1600/tutorial6_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-_CXLqKndzd8/T5heZ5EqjlI/AAAAAAAAALc/4YC2NQ8mOGY/s320/tutorial6_1.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Per estendere o comprimere la scala dei grigi bisogna semplicemente allontanare o avvicinare il punto dal quale la scena viene colorata di bianco e quello finale in cui la scena è colorata di nero. Questo si ottiene giocherellando un pò con li argomenti di scale e translate.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
Inoltre, quando si crea la mappa di profondità è buon uso disattivare l'antialising. Io uso MegaPov (visto che sono su Mac) dove la disattivazione è un'azione molto semplice: Window/ Render Preferences / Image &amp;amp; Quality.&lt;br /&gt;
Se si usa Pov-Ray bisogna modificare il file povray.ini aggiungendo: Antialias=false.&lt;br /&gt;
&lt;br /&gt;
Questo è tutto e alla prossima.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;a href="http://www.povray.org/" target="_blank"&gt;Pov-Ray&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;a href="http://megapov.inetart.net/" target="_blank"&gt;MegaPov (Pov-Ray per Mac)&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;a href="http://wiki.povray.org/content/Main_Page" target="_blank"&gt;POV-Wiki&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Immagini scacchi:&amp;nbsp;http://www.dofpro.com/tutorial1.htm&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/uydHr9xx3oA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/5193561171255841962/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/04/pov-ray-creare-una-mappa-di-profondita.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5193561171255841962?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5193561171255841962?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/uydHr9xx3oA/pov-ray-creare-una-mappa-di-profondita.html" title="POV-Ray - Creare una mappa di profondità (omogenea) di una scena" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-1OlW6GcOo6k/T5hXHQyqlOI/AAAAAAAAAKQ/6YCf9AK3lBE/s72-c/sherk-collins.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/04/pov-ray-creare-una-mappa-di-profondita.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8DQXk5eyp7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-3059324612742666396</id><published>2012-04-20T22:06:00.001+02:00</published><updated>2012-07-01T11:27:50.723+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T11:27:50.723+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Competizioni" /><title>Java - Google Code Jam 2012 (Qualifications, Problem A)</title><content type="html">Dopo una breve introduzione al Google Jam Code 2012 e come prepararsi ad affrontare un problema della competizione nel miglior modo possibile, in questo articolo spiegherò la mia soluzione al primo problema: Speaking in Tongues.&lt;br /&gt;
&lt;br /&gt;
Potete trovare il problema originale alla fine dell'articolo, ma per semplificare la vita un pò a tutti riassumerò un pò il tutto in Italiano.&lt;br /&gt;
&lt;br /&gt;
Ci sono due lingue: l'Inglese e il Googlerese. Entrambe hanno 26 lettere e ogni lettera dell'alfabeto Inglese corrisponde a una lettera dell'alfabeto Googlerese. La mappatura fra i due alfabeti non cambia mai, quindi ogni informazione data dal problema può essere presa per buona.&lt;br /&gt;
La pri&lt;span style="font-family: inherit;"&gt;ma mappatura che possiamo estrapolare è per le seguenti tre lettere dall'Inglese al Googlerese:&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; text-align: justify;"&gt;&lt;span style="font-family: inherit;"&gt;'a' -&amp;gt; 'y', 'o' -&amp;gt; 'e', e 'z' -&amp;gt; 'q'.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; text-align: justify;"&gt;&lt;span style="font-family: inherit;"&gt;Ma dove troviamo il resto della mappatura? Facile! Usiamo l'esempio che ci viene dato.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;






Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify; width: 468px;"&gt;
&lt;br /&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;3&lt;br /&gt;ejp mysljylc kd kxveddknmc re jsicpdrysi&lt;br /&gt;rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd&lt;br /&gt;de kr kd eoya kw aej tysr re ujdr lkgc jv&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: our language is impossible to understand&lt;br /&gt;Case #2: there are twenty six factorial possibilities&lt;br /&gt;Case #3: so it is okay if you want to just give up&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
Come potrete vedere nella mia soluzione, che troverete più in basso, io ho semplicemente creato due ArrayList dove inserire in ordine le lettere da entrambi i testi (senza ripetizioni ovviamente). Dopo avere stampato la mia prima "mappatura" mi sono accorto che l'esempio sopra riportato non mi avrebbe permesso di mappare 'z'-&amp;gt;'q' e 'q'-&amp;gt;'z', quindi ho semplicemente inserito queste due relazioni manualmente visto che la prima era già stata suggerita all'inizio del problema.&lt;br /&gt;
&lt;br /&gt;
Dopodiché non mi è rimasto che scaricare il problema dalla competizione, leggere l'input, tradurre ogni caso proposto, chiudere il file di output e caricarlo nella piattaforma della competizione.&lt;br /&gt;
&lt;br /&gt;
Come potete vedere il problema era veramente semplice, ma se non si riesce a capirlo bene è possibile non venire mai a capo della soluzione.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;La mia soluzione&lt;/b&gt; (mi scuso in anticipo per lo stile, ma non era un concorso di bellezza):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:java"&gt;public class ProblemA {

 public static String initGooglerese;
 public static String initEnglish;
 public static ArrayList listGooglerese;
 public static ArrayList listEnglish;

 public static void main(String[] args) {
  try {
   init();
   Scanner input = new Scanner(new FileReader("A-small-attempt0.in"));
   PrintWriter output = new PrintWriter(new FileWriter("output.txt"));
   int index = 0;
   int numberCases = input.nextInt();
   
   String googlerese = input.nextLine();
   for (int i = 0; i &amp;lt; numberCases; i++) {
    output.print("Case #" + (i + 1) + ": ");
    
    // Get the line.
    googlerese = input.nextLine();
    for (int j = 0; j &amp;lt; googlerese.length(); j++) {
     if (googlerese.charAt(j) != ' ') {
      index = listGooglerese.indexOf(googlerese.charAt(j));
      output.print(listEnglish.get(index));
     } else {
      output.print(" ");
     }
    }
    output.print("\n");
   }
   
   output.flush();
   output.close();
   input.close();
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
 
 public static void init() {
  initGooglerese = "ejpmysljylckdkxveddknmcrejsicpdrysirbcpcypcrtcsradkhwyfrepkymveddknkmkrkcddekrkdeoyakwaejtysrreujdrlkgcjv";
  initEnglish = "ourlanguageisimpossibletounderstandtherearetwentysixfactorialpossibilitiessoitisokayifyouwanttojustgiveup";
  
  if (initGooglerese.length() != initEnglish.length()) {
   System.out.println("Error");
  } else {
   listGooglerese = new ArrayList();
   listEnglish = new ArrayList();
   for (int i = 0; i &amp;lt; initGooglerese.length(); i++) {
    if (listGooglerese.contains(initGooglerese.charAt(i)) == false) {
     listGooglerese.add(initGooglerese.charAt(i));
     listEnglish.add(initEnglish.charAt(i));
    }
   }
  }
  if (listGooglerese.contains('q') == false) {
   listGooglerese.add('q');
   listEnglish.add('z');
  }
  
  if (listGooglerese.contains('z') == false) {
   listGooglerese.add('z');
   listEnglish.add('q');
  }
  
 }

}
&lt;/pre&gt;
&lt;script src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlightLoader.js"&gt;
&lt;/script&gt;
&lt;b&gt;Problema originale&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








&lt;span style="color: #666666; font-size: x-small; font-weight: bold;"&gt;Problem A.&lt;/span&gt;&lt;span style="font-size: x-small; font-weight: bold;"&gt;&amp;nbsp;Speaking in Tongues&lt;/span&gt;&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
We have come up with the best possible language here at Google, called Googlerese. To translate text into Googlerese, we take any message and replace each English letter with another English letter. This mapping is&amp;nbsp;&lt;i&gt;one-to-one&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;onto&lt;/i&gt;, which means that the same input letter always gets replaced with the same output letter, and different input letters always get replaced with different output letters. A letter may be replaced by itself. Spaces are left as-is.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: 'a' -&amp;gt; 'y', 'o' -&amp;gt; 'e', and 'z' -&amp;gt; 'q'. This means that "a zoo" will become "y qee".&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
Googlerese is based on the best possible replacement mapping, and we will never change it. It will always be the same. In every test case. We will not tell you the rest of our mapping because that would make the problem too easy, but there are a few examples below that may help.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
Given some text in Googlerese, can you translate it to back to normal text?&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








Solving this problem&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only&amp;nbsp;&lt;b&gt;1 Small input&lt;/b&gt;. Once you have solved the Small input, you have finished solving this problem.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








Input&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow, one per line.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
Each line consists of a string&amp;nbsp;&lt;b&gt;G&lt;/b&gt;&amp;nbsp;in Googlerese, made up of one or more words containing the letters 'a' - 'z'. There will be exactly one space (' ') character between consecutive words and no spaces at the beginning or at the end of any line.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








Output&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
For each test case, output one line containing "Case #&lt;b&gt;X&lt;/b&gt;:&amp;nbsp;&lt;b&gt;S&lt;/b&gt;" where&amp;nbsp;&lt;b&gt;X&lt;/b&gt;&amp;nbsp;is the case number and&amp;nbsp;&lt;b&gt;S&lt;/b&gt;&amp;nbsp;is the string that becomes&amp;nbsp;&lt;b&gt;G&lt;/b&gt;&amp;nbsp;in Googlerese.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








Limits&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 30.&lt;br /&gt;
&lt;b&gt;G&lt;/b&gt;&amp;nbsp;contains at most 100 characters.&lt;br /&gt;
None of the text is guaranteed to be valid English.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 19px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: justify;"&gt;








Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify; width: 468px;"&gt;
&lt;br /&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;3&lt;br /&gt;ejp mysljylc kd kxveddknmc re jsicpdrysi&lt;br /&gt;rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd&lt;br /&gt;de kr kd eoya kw aej tysr re ujdr lkgc jv&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: our language is impossible to understand&lt;br /&gt;Case #2: there are twenty six factorial possibilities&lt;br /&gt;Case #3: so it is okay if you want to just give up&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/XuKbQTfZFVM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/3059324612742666396/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/04/java-google-code-jam-2012.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3059324612742666396?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3059324612742666396?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/XuKbQTfZFVM/java-google-code-jam-2012.html" title="Java - Google Code Jam 2012 (Qualifications, Problem A)" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/04/java-google-code-jam-2012.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UERXgyeip7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-1692042398721942875</id><published>2012-04-16T20:33:00.001+02:00</published><updated>2012-07-01T11:33:24.692+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T11:33:24.692+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Competizioni" /><title>Java - Google Code Jam: Prepararsi alla sfida</title><content type="html">Nel seguente articolo condividerò con tutti voi il codice base che ho usato io per il Google Code Jam durante le qualificazioni e che utilizzerò nelle fasi successive.&lt;br /&gt;
&lt;br /&gt;
Ogni problema proposto dalla competizione ha il seguente input (letto da file, con estensione .in):&lt;br /&gt;
&lt;br /&gt;
- Numero dei casi&lt;br /&gt;
- Caso 1&lt;br /&gt;
- Caso 2&lt;br /&gt;
- Caso 3&lt;br /&gt;
etc, etc fino alla fine del file&lt;br /&gt;
&lt;br /&gt;
Per ogni caso bisogna applicare la propria soluzione e scriverla in un'altro file nel seguente modo:&lt;br /&gt;
&lt;br /&gt;
Case #1: Soluzione a Caso 1&lt;br /&gt;
Case #2: Soluzione a Caso 2&lt;br /&gt;
Case #3: Soluzione a Caso 3&lt;br /&gt;
etc, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:java"&gt; 
import java.io.*;
import java.util.*;

public class Problema {

 public static void main(String[] args) {
         try {
                        // Apriamo il file contenente l'input.
                        // Una volta scaricato il file della competizione, rinominare input.in con il nome del file scaricato.
                        Scanner input = new Scanner(new FileReader("input.in"));
                        // Creiamo il file dove scrivere le nostre soluzioni
                        PrintWriter output = new PrintWriter(new FileWriter("output.txt"));

                        int numeroDiCasi = input.nextInt();
                        // Saltiamo alla prima linea del file -&amp;gt; Caso 1.   
                        String data = input.nextLine(); 

                        // Risolviamo tutti i casi proposti.
                        for (int i = 0; i &amp;lt; numeroDiCasi; i++) {
                                output.print("Case #" + (i + 1) + ": ");

                                // Leggiamo il caso 1 (un caso potrebbe essere costituito anche da più linee)
                                data = input.nextLine(); 
    
                                // RISOLUZIONE DEL PROBLEMA.

                                output.print(SOLUZIONE);
                                output.print("\n");
                        }
                        // Gli stream d' I/O vengono finalizzati e chiusi.
                        output.flush();
                        output.close();
                        input.close();
                } catch (FileNotFoundException e) {
                             e.printStackTrace();
                } catch (IOException e) {
                            e.printStackTrace();
                }
       }
}
&lt;/pre&gt;
&lt;script src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlightLoader.js"&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;br /&gt;
A questo punto, una volta risolto il problema, non ci resta che scaricare il problema "&lt;i&gt;Small Set&lt;/i&gt;" ed eseguire il proprio programma con l'input proposto. Poi bisogna caricare sia la l'&lt;b&gt;output.txt&lt;/b&gt; che il proprio &lt;b&gt;codice sorgente .java &lt;/b&gt;nella piattaforma della competizione e in alto apparirà l'esito: &lt;span style="color: #38761d;"&gt;Correct&lt;/span&gt; o &lt;span style="color: red;"&gt;Incorrect&lt;/span&gt;. &lt;br /&gt;
Se l'esito è Correct, allora si potrà scaricare il problema "Large Set" ed eseguire il proprio programma con questo nuovo input (più difficile). La piattaforma della competizione, tuttavia, non vi dirà l'esito del Large Set se non dopo la fine del round.&lt;br /&gt;
Se l'esito è Incorrect: avrete una penalità "temporale", ma potete comunque provare a risolvere il problema nuovamente.&lt;br /&gt;
Nel caso due concorrenti abbiano ottenuto lo stesso punteggio, le loro penalità temporali verranno tenute in considerazione.&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/mg_rGQ0De0k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/1692042398721942875/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/04/java-google-code-jam-prepararsi-alla.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/1692042398721942875?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/1692042398721942875?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/mg_rGQ0De0k/java-google-code-jam-prepararsi-alla.html" title="Java - Google Code Jam: Prepararsi alla sfida" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/04/java-google-code-jam-prepararsi-alla.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMFRXc_eCp7ImA9WhVXFEU.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-2778903147748563556</id><published>2012-04-15T11:32:00.000+02:00</published><updated>2012-04-15T11:33:34.940+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-15T11:33:34.940+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Competizioni" /><title>Google Code Jam 2012</title><content type="html">Ieri, 14 Aprile 2012, si è svolta la fase di qualificazione per &lt;a href="http://en.wikipedia.org/wiki/Google_Code_Jam" target="_blank"&gt;Code Jam&lt;/a&gt; 2012 organizzata da Google inc.&lt;br /&gt;
Per agevolare le diverse fasce orarie la durata della fase di qualificazione è stata di 25 ore.&lt;br /&gt;
I problemi da risolvere erano quattro (in qualsiasi linguaggio di programmazione), ma per passare alla fase successiva basta totalizzare almeno 20 punti di un totale di 100 (quindi bisognava risolvere in media due problemi).&lt;br /&gt;
&lt;br /&gt;
La mia gara è iniziata circa 9 ore dopo l'inizio della gara. Essendo alla prima partecipazione ho impiegato la mia prima mezz'oretta &amp;nbsp;a capire come funzionava il sistema e la fase di invio dei risultati.&lt;br /&gt;
&lt;br /&gt;
Potete trovare i problemi proposti alla fine dell'articolo, mentre scriverò articoli separati per le mie risposte nei giorni successivi.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Riassunto della mia gara&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
Il primo problema praticamente serviva per capire chi sapeva programmare, chi no. Il trucco consisteva nel creare una mappatura bidirezionale fra i due linguaggi proposti.&lt;br /&gt;
&lt;br /&gt;
Il secondo problema, invece, era sicuramente più intrigante. Poteva sicuramente essere risolto utilizzando del&amp;nbsp;brute-forcing, ma per rendere la cosa più interessante io ho optato in una risoluzione matematica del problema (che si è rilevata anche più efficiente: O(n) vs O(n^3)).&lt;br /&gt;
&lt;br /&gt;
Il terzo problema mi ha dato qualche difficoltà in quanto non ho inizialmente capito perfettamente il problema, tuttavia sono riuscito a risolverlo in un'oretta circa senza problemi eccessivi (questa volta ho optato nella forza del brute).&lt;br /&gt;
&lt;br /&gt;
Il quarto e ultimo problema era quello più impegnativo. L'ho trovato molto interessante, ma non eccessivamente difficile. Più che altro bisognava scrivere molto codice, ecco perché ho deciso di saltarlo visto che qualche ora dopo iniziava la competizione &lt;a href="http://community.topcoder.com/tco12/" target="_blank"&gt;TCO 2012&lt;/a&gt; che non potevo mancare.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PROBLEMI&lt;/b&gt;:&lt;br /&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





&lt;span style="color: #666666; font-size: small; font-weight: bold;"&gt;Problem A.&lt;/span&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;&amp;nbsp;Speaking in Tongues&lt;/span&gt;&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
We have come up with the best possible language here at Google, called Googlerese. To translate text into Googlerese, we take any message and replace each English letter with another English letter. This mapping is&amp;nbsp;&lt;i&gt;one-to-one&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;onto&lt;/i&gt;, which means that the same input letter always gets replaced with the same output letter, and different input letters always get replaced with different output letters. A letter may be replaced by itself. Spaces are left as-is.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: 'a' -&amp;gt; 'y', 'o' -&amp;gt; 'e', and 'z' -&amp;gt; 'q'. This means that "a zoo" will become "y qee".&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Googlerese is based on the best possible replacement mapping, and we will never change it. It will always be the same. In every test case. We will not tell you the rest of our mapping because that would make the problem too easy, but there are a few examples below that may help.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Given some text in Googlerese, can you translate it to back to normal text?&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





Solving this problem&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has only&amp;nbsp;&lt;b&gt;1 Small input&lt;/b&gt;. Once you have solved the Small input, you have finished solving this problem.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





Input&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow, one per line.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Each line consists of a string&amp;nbsp;&lt;b&gt;G&lt;/b&gt;&amp;nbsp;in Googlerese, made up of one or more words containing the letters 'a' - 'z'. There will be exactly one space (' ') character between consecutive words and no spaces at the beginning or at the end of any line.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





Output&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For each test case, output one line containing "Case #&lt;b&gt;X&lt;/b&gt;:&amp;nbsp;&lt;b&gt;S&lt;/b&gt;" where&amp;nbsp;&lt;b&gt;X&lt;/b&gt;&amp;nbsp;is the case number and&amp;nbsp;&lt;b&gt;S&lt;/b&gt;&amp;nbsp;is the string that becomes&amp;nbsp;&lt;b&gt;G&lt;/b&gt;&amp;nbsp;in Googlerese.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





Limits&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 30.&lt;br /&gt;
&lt;b&gt;G&lt;/b&gt;&amp;nbsp;contains at most 100 characters.&lt;br /&gt;
None of the text is guaranteed to be valid English.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;





Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 468px;"&gt;
&lt;br /&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;3&lt;br /&gt;ejp mysljylc kd kxveddknmc re jsicpdrysi&lt;br /&gt;rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd&lt;br /&gt;de kr kd eoya kw aej tysr re ujdr lkgc jv&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: our language is impossible to understand&lt;br /&gt;Case #2: there are twenty six factorial possibilities&lt;br /&gt;Case #3: so it is okay if you want to just give up&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;span style="background-color: white; color: #666666; font-family: Arial, sans-serif; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #666666; font-family: Arial, sans-serif; font-weight: bold;"&gt;Problem B.&lt;/span&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&amp;nbsp;Dancing With the Googlers&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, sans-serif;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
You're watching a show where Googlers (employees of Google) dance, and then each dancer is given a&amp;nbsp;&lt;i&gt;triplet of scores&lt;/i&gt;&amp;nbsp;by three judges. Each triplet of scores consists of three integer scores from 0 to 10 inclusive. The judges have very similar standards, so it's&lt;i&gt;surprising&lt;/i&gt;&amp;nbsp;if a triplet of scores contains two scores that are 2 apart. No triplet of scores contains scores that are more than 2 apart.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For example: (8, 8, 8) and (7, 8, 7) are not surprising. (6, 7, 8) and (6, 8, 8) are surprising. (7, 6, 9) will never happen.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The&amp;nbsp;&lt;i&gt;total points&lt;/i&gt;&amp;nbsp;for a Googler is the sum of the three scores in that Googler's triplet of scores. The&amp;nbsp;&lt;i&gt;best result&lt;/i&gt;&amp;nbsp;for a Googler is the maximum of the three scores in that Googler's triplet of scores. Given the total points for each Googler, as well as the number of surprising triplets of scores, what is the maximum number of Googlers that could have had a best result of at least&amp;nbsp;&lt;b&gt;p&lt;/b&gt;?&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For example, suppose there were 6 Googlers, and they had the following total points:&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;29, 20, 8, 18, 18, 21&lt;/code&gt;. You remember that there were 2 surprising triplets of scores, and you want to know how many Googlers could have gotten a best result of 8 or better.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
With those total points, and knowing that two of the triplets were surprising, the triplets of scores could have been:&lt;/div&gt;
&lt;pre style="background-color: whitesmoke; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; font-family: 'bogus font here', monospace; font-size: 12px; margin-bottom: 2em; margin-left: 2em; margin-right: 2em; margin-top: 2em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.5em; padding-left: 0.5em; padding-right: 0.5em; padding-top: 0.5em; width: 447px;"&gt;10 9 10
6 6 8 (*)
2 3 3
6 6 6
6 6 6
6 7 8 (*)
&lt;/pre&gt;
&lt;span style="background-color: white; font-family: Arial, sans-serif; font-size: x-small;"&gt;The cases marked with a (*) are the surprising cases. This gives us 3 Googlers who got at least one score of 8 or better. There's no series of triplets of scores that would give us a higher number than 3, so the answer is 3.&lt;/span&gt;&lt;br /&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Input&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow. Each test case consists of a single line containing integers separated by single spaces. The first integer will be&amp;nbsp;&lt;b&gt;N&lt;/b&gt;, the number of Googlers, and the second integer will be&amp;nbsp;&lt;b&gt;S&lt;/b&gt;, the number of surprising triplets of scores. The third integer will be&amp;nbsp;&lt;b&gt;p&lt;/b&gt;, as described above. Next will be&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;integers&amp;nbsp;&lt;b&gt;t&lt;sub&gt;i&lt;/sub&gt;&lt;/b&gt;: the total points of the Googlers.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Output&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the maximum number of Googlers who could have had a best result of greater than or equal to&amp;nbsp;&lt;b&gt;p&lt;/b&gt;.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Limits&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 100.&lt;br /&gt;
0 ≤&amp;nbsp;&lt;b&gt;S&lt;/b&gt;&amp;nbsp;≤ N.&lt;br /&gt;
0 ≤&amp;nbsp;&lt;b&gt;p&lt;/b&gt;&amp;nbsp;≤ 10.&lt;br /&gt;
0 ≤&amp;nbsp;&lt;b&gt;t&lt;sub&gt;i&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;≤ 30.&lt;br /&gt;
At least&amp;nbsp;&lt;b&gt;S&lt;/b&gt;&amp;nbsp;of the&amp;nbsp;&lt;b&gt;t&lt;sub&gt;i&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;values will be between 2 and 28, inclusive.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Small dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;≤ 3.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Large dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;≤ 100.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 468px;"&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;4&lt;br /&gt;3 1 5 15 13 11&lt;br /&gt;3 0 8 23 22 21&lt;br /&gt;2 1 1 8 0&lt;br /&gt;6 2 8 29 20 8 18 18 21&lt;/code&gt;&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: 3&lt;br /&gt;Case #2: 2&lt;br /&gt;Case #3: 1&lt;br /&gt;Case #4: 3&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style="background-color: white; color: #666666; font-family: Arial, sans-serif; font-weight: bold;"&gt;Problem C.&lt;/span&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&amp;nbsp;Recycled Numbers&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Do you ever become frustrated with television because you keep seeing the same things, recycled over and over again? Well I personally don't care about television, but I do sometimes feel that way about numbers.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Let's say a pair of distinct positive integers (&lt;i&gt;n&lt;/i&gt;,&amp;nbsp;&lt;i&gt;m&lt;/i&gt;) is&amp;nbsp;&lt;i&gt;recycled&lt;/i&gt;&amp;nbsp;if you can obtain&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;by moving some digits from the back of&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;to the front without changing their order. For example, (12345, 34512) is a recycled pair since you can obtain 34512 by moving 345 from the end of 12345 to the front. Note that&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;must have the same number of digits in order to be a recycled pair. Neither&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;nor&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;can have leading zeros.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Given integers&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;with the same number of digits and no leading zeros, how many distinct recycled pairs (&lt;i&gt;n&lt;/i&gt;,&amp;nbsp;&lt;i&gt;m&lt;/i&gt;) are there with&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;?&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Input&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow. Each test case consists of a single line containing the integers&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;B&lt;/b&gt;.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Output&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1), and y is the number of recycled pairs (&lt;i&gt;n&lt;/i&gt;,&amp;nbsp;&lt;i&gt;m&lt;/i&gt;) with&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;i&gt;n&lt;/i&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;i&gt;m&lt;/i&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Limits&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 50.&lt;br /&gt;
&lt;b&gt;A&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;have the same number of digits.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Small dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;≤ 1000.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Large dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;≤ 2000000.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 468px;"&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;4&lt;br /&gt;1 9&lt;br /&gt;10 40&lt;br /&gt;100 500&lt;br /&gt;1111 2222&lt;/code&gt;&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: 0&lt;br /&gt;Case #2: 3&lt;br /&gt;Case #3: 156&lt;br /&gt;Case #4: 287&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style="background-color: white; color: #666666; font-family: Arial, sans-serif; font-weight: bold;"&gt;Problem D.&lt;/span&gt;&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&amp;nbsp;Hall of Mirrors&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
You live in a 2-dimensional plane, and one of your favourite places to visit is the Hall of Mirrors. The Hall of Mirrors is a room (a 2-dimensional room, of course) that is laid out in a grid. Every square on the grid contains either a square mirror, empty space, or you. You have width 0 and height 0, and you are located in the exact centre of your grid square.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Despite being very small, you can see your reflection when it is reflected back to you exactly. For example, consider the following layout, where&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'#'&lt;/code&gt;&amp;nbsp;indicates a square mirror that completely fills its square,&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'.'&lt;/code&gt;&amp;nbsp;indicates empty space, and the capital letter&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'X'&lt;/code&gt;indicates you are in the center of that square:&lt;/div&gt;
&lt;pre style="background-color: whitesmoke; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; font-family: 'bogus font here', monospace; font-size: 12px; margin-bottom: 2em; margin-left: 2em; margin-right: 2em; margin-top: 2em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.5em; padding-left: 0.5em; padding-right: 0.5em; padding-top: 0.5em; width: 447px;"&gt;######
#..X.#
#.#..#
#...##
######
&lt;/pre&gt;
&lt;span style="background-color: white; font-family: Arial, sans-serif; font-size: x-small;"&gt;If you look straight up or straight to the right, you will be able to see your reflection.&lt;/span&gt;&lt;br /&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Unfortunately in the Hall of Mirrors it is very foggy, so you can't see further than&amp;nbsp;&lt;b&gt;D&lt;/b&gt;&amp;nbsp;units away. Suppose&amp;nbsp;&lt;b&gt;D&lt;/b&gt;=3. If you look up, your reflection will be 1 unit away (0.5 to the mirror, and 0.5 back). If you look right, your reflection will be 3 units away (1.5 to the mirror, and 1.5 back), and you will be able to see it. If you look down, your reflection will be 5 units away and you won't be able to see it.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
It's important to understand how light travels in the Hall of Mirrors. Light travels in a straight line until it hits a mirror. If light hits any part of a mirror but its corner, it will be reflected in the normal way: it will bounce off with an angle of reflection equal to the angle of incidence. If, on the other hand, the light would touch the corner of a mirror, the situation is more complicated. The following diagrams explain the cases:&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the following cases, light approaches a corner and is reflected, changing its direction:&lt;br /&gt;
&lt;img src="https://code.google.com/codejam/contest/images/?image=reflection.png&amp;amp;p=1285485&amp;amp;c=1460488" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; vertical-align: middle;" /&gt;&lt;br /&gt;
In the first two cases, light approached two adjacent mirrors at the point where they met. Light was reflected in the same way as if it had hit the middle of a long mirror. In the third case, light approached the corners of three adjacent mirrors, and returned in exactly the direction it came from.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the following cases, light approaches the corners of one or more mirrors, but does not bounce, and instead continues in the same direction:&lt;br /&gt;
&lt;img src="https://code.google.com/codejam/contest/images/?image=no_reflection.png&amp;amp;p=1285485&amp;amp;c=1460488" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; vertical-align: middle;" /&gt;&lt;br /&gt;
This happens when light reaches distance 0 from the corner of a mirror, but would not have to pass through the mirror in order to continue in the same direction. In this way, a ray of light can pass between two mirrors that are diagonally adjacent to each other -- effectively going through a space of size 0. Good thing it's of size 0 too, so it fits!&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the final case, light approaches the corner of one mirror and is destroyed:&lt;br /&gt;
&lt;img src="https://code.google.com/codejam/contest/images/?image=destruction.png&amp;amp;p=1285485&amp;amp;c=1460488" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; vertical-align: middle;" /&gt;&lt;br /&gt;
The mirror was in the path of the light, and the ray of light didn't approach the corners of any other mirrors.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
Note that light stops when it hits you, but it has to hit the exact centre of your grid square.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
How many images of yourself can you see?&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Input&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow. Each test case starts with a line containing three space-separated integers,&amp;nbsp;&lt;b&gt;H&lt;/b&gt;,&amp;nbsp;&lt;b&gt;W&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;D&lt;/b&gt;.&amp;nbsp;&lt;b&gt;H&lt;/b&gt;lines follow, and each contains&amp;nbsp;&lt;b&gt;W&lt;/b&gt;&amp;nbsp;characters. The characters constitute a map of the Hall of Mirrors for that test case, as described above.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Output&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the number of reflections of yourself you can see.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Limits&lt;/h3&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 100.&lt;br /&gt;
3 ≤&amp;nbsp;&lt;b&gt;H&lt;/b&gt;,&amp;nbsp;&lt;b&gt;W&lt;/b&gt;&amp;nbsp;≤ 30.&lt;br /&gt;
1 ≤&amp;nbsp;&lt;b&gt;D&lt;/b&gt;&amp;nbsp;≤ 50.&lt;br /&gt;
All characters in each map will be&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'#'&lt;/code&gt;,&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'.'&lt;/code&gt;, or&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'X'&lt;/code&gt;.&lt;br /&gt;
Exactly one character in each map will be&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'X'&lt;/code&gt;.&lt;br /&gt;
The first row, the last row, the first column and the last column of each map will be entirely filled with&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'#'&lt;/code&gt;&amp;nbsp;characters.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Small dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
There will be no more than&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;2W+2H-4&lt;/code&gt;&amp;nbsp;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;'#'&lt;/code&gt;&amp;nbsp;characters.&lt;/div&gt;
&lt;h4 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px;"&gt;

Large dataset&lt;/h4&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
The restriction from the Small dataset does not apply.&lt;/div&gt;
&lt;h3 style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal;"&gt;

Sample&lt;/h3&gt;
&lt;div class="problem-io-wrapper" style="background-color: #efefef; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 468px;"&gt;
&lt;table style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; font-size: small; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;&lt;tbody&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Input&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;br /&gt;
&lt;span class="io-table-header" style="font-size: 13px;"&gt;Output&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: top;"&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;6&lt;br /&gt;3 3 1&lt;br /&gt;###&lt;br /&gt;#X#&lt;br /&gt;###&lt;br /&gt;3 3 2&lt;br /&gt;###&lt;br /&gt;#X#&lt;br /&gt;###&lt;br /&gt;4 3 8&lt;br /&gt;###&lt;br /&gt;#X#&lt;br /&gt;#.#&lt;br /&gt;###&lt;br /&gt;7 7 4&lt;br /&gt;#######&lt;br /&gt;#.....#&lt;br /&gt;#.....#&lt;br /&gt;#..X..#&lt;br /&gt;#....##&lt;br /&gt;#.....#&lt;br /&gt;#######&lt;br /&gt;5 6 3&lt;br /&gt;######&lt;br /&gt;#..X.#&lt;br /&gt;#.#..#&lt;br /&gt;#...##&lt;br /&gt;######&lt;br /&gt;5 6 10&lt;br /&gt;######&lt;br /&gt;#..X.#&lt;br /&gt;#.#..#&lt;br /&gt;#...##&lt;br /&gt;######&lt;/code&gt;&lt;/td&gt;&lt;td style="border-bottom-width: 0pt; border-collapse: collapse; border-left-width: 0pt; border-right-width: 0pt; border-top-width: 0pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 1em; padding-right: 1em; padding-top: 0px; vertical-align: top;"&gt;&lt;code style="font-family: 'bogus font here', monospace; font-size: 13px;"&gt;Case #1: 4&lt;br /&gt;Case #2: 8&lt;br /&gt;Case #3: 68&lt;br /&gt;Case #4: 0&lt;br /&gt;Case #5: 2&lt;br /&gt;Case #6: 28&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the first case, light travels exactly distance 1 if you look directly up, down, left or right.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the second case, light travels distance 1.414... if you look up-right, up-left, down-right or down-left. Since light does not travel through you, looking directly up only shows you one image of yourself.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, sans-serif; font-size: small;"&gt;
In the fifth case, while the nearby mirror is close enough to reflect light back to you, light that hits the corner of the mirror is destroyed rather than reflected.&lt;/div&gt;
&lt;br /&gt;
&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; font-family: Arial, sans-serif; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/aS4SP65yTmA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/2778903147748563556/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/04/google-code-jam-2012.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/2778903147748563556?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/2778903147748563556?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/aS4SP65yTmA/google-code-jam-2012.html" title="Google Code Jam 2012" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/04/google-code-jam-2012.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUANRXY-eyp7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-5239230769081907342</id><published>2012-03-26T21:39:00.000+02:00</published><updated>2012-07-01T12:16:34.853+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T12:16:34.853+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Multimediale" /><title>Il futuro in una confezione di vetro</title><content type="html">&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Corning Incorporated è un'azienda Americana produttrice di vetri, ceramiche e altri materiali a fini industriali e scientifici. Qualche giorno fa navigato per internet mi sono imbattuto in dei video realizzati dalla Corning: A Day Made of Glass.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Questi video, che troverete qui sotto, mostrano come l'azienda immagina il nostro futuro. Un futuro sicuramente più tattile tanto è vero che i video parlano da sè, senza bisogno di spiegazioni o altro.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://3.gvt0.com/vi/6Cf7IL_eZ38/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/6Cf7IL_eZ38&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/6Cf7IL_eZ38&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://1.gvt0.com/vi/jZkHpNnXLB0/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/jZkHpNnXLB0&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/jZkHpNnXLB0&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Di seguito potete trovare il secondo video, ma con qualche spiegazione in più (in Inglese):&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://0.gvt0.com/vi/X-GXO_urMow/0.jpg" height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/X-GXO_urMow&amp;fs=1&amp;source=uds" /&gt;

&lt;param name="bgcolor" value="#FFFFFF" /&gt;

&lt;embed width="425" height="350"  src="http://www.youtube.com/v/X-GXO_urMow&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Personalmente trovo le idee veramente brillanti e intriganti. Con la tecnologia attuale tutto ciò sembra un sogno, ma è anche vero che da almeno 10 anni non assistiamo ad una vera rivoluzione tecnologica.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Voi cosa ne pensate? Come lo immaginate il vostro futuro tecnologico perfetto?&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/rSm6-caVulg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/5239230769081907342/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/03/il-futuro-in-una-confezione-di-vetro.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5239230769081907342?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5239230769081907342?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/rSm6-caVulg/il-futuro-in-una-confezione-di-vetro.html" title="Il futuro in una confezione di vetro" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/03/il-futuro-in-una-confezione-di-vetro.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8GR309eip7ImA9WhVRFk8.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-6338741988144405205</id><published>2012-03-24T23:38:00.005+01:00</published><updated>2012-03-24T23:40:26.362+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-24T23:40:26.362+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Fondamenti" /><category scheme="http://www.blogger.com/atom/ns#" term="MIPS32" /><category scheme="http://www.blogger.com/atom/ns#" term="ADT" /><category scheme="http://www.blogger.com/atom/ns#" term="Memoria" /><category scheme="http://www.blogger.com/atom/ns#" term="ISA" /><title>MIPS32 - Gestione della Memoria</title><content type="html">&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit; line-height: 19px;"&gt;MIPS (Microprocessor without Interlocked Pipeline Stages) è un processore con architettura (ISA - Instruction Set Architecture) di tipo RISC (Reduced Instruction Set Computer). Le prime architetture &amp;nbsp;MIPS erano a 32 bit, mentre quelle più moderne sono 64 bit.&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;L'architettura a 32 bit rimane tutta via quella più usata a scopo didattico perché ci permette di capire il funzionamento dell'architettura rimanendo in un'ambiente semplice da capire.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;Per i più curiosi ritengo che sia giusto riportare che alcuni dispositivi di Windows CE, Cisco, come la &amp;nbsp;anche la Nintendo64, Sony: PlayStation, PlayStation2 e PSP usano processori MIPS.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;Nel seguente articolo proporrò una mia soluzione alla gestione della memoria in MIPS32. Chi, invece, desidera leggere di più sull'architettura MIPS e la sua storia può trovare interessante quest'&lt;a href="http://it.wikipedia.org/wiki/Architettura_MIPS" target="_blank"&gt;articolo&lt;/a&gt; su Wikipedia come alcune delle fonti sotto riportate.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;In ogni sistema la quantità di memoria è finita. Per un processore a 32bits sono disponibili 4Gbytes di memoria (virtuale). Il sistema operativo preserva parte di questa memoria per se stesso, il resto è utilizzato da terzi.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;La sezione incapsulata fra gli indirizzi 0x0040000 e 0x10000000 (nell'immagine sottostante, nella realtà può variare) è chiamata Text Segment e contiene il linguaggio macchina del programma eseguito (in questo caso quello che andremmo a scrivere noi). Oltre l'indirizzo 0x10000000 troviamo la sezione Data Segment che contiene la porzione di memoria "richiesta" dal programma ad inizio esecuzione. La sezione Stack è utilizzata dallo stack del programma che si espande e comprime in continuazione in fase di esecuzione.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;L'area di memoria fra lo Stack e il Data Segment è comunemente chiamato Heap ed è quella memoria non ancora allocata (richiesta dall'utente/programmatore).&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;a href="http://4.bp.blogspot.com/-_t7th7kvOmk/T1_b_ehFN9I/AAAAAAAAAKE/bc202c33VgY/s1600/MIPS+Memory.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-_t7th7kvOmk/T1_b_ehFN9I/AAAAAAAAAKE/bc202c33VgY/s1600/MIPS+Memory.gif" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Durante l'esecuzione di un programma non è raro che quest'ultimo richieda una porzione di memoria. Tale porzione di memoria viene allocata dinamicamente dall'Heap tramite il sistema operativo. Porzioni di memoria possono anche essere de-allocati quando non più in uso. In MIPS32, tuttavia, quest'ultima operazione non è gestita dal sistema operativo, quindi è compito del programmatore gestire tutte quelle porzioni di memoria non più in uso.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Per poter illustrare facilmente come gestire la memoria in MIPS32 utilizzeremmo una semplice &lt;a href="http://sic-oding.blogspot.com/2011/11/java-singly-linked-list.html" target="_blank"&gt;Singly Linked List&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Innanzitutto vediamo come richiedere una porzione di memoria dal sistema operativo usando syscall:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;li&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$v0, 9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;# Servizio 9 del sistema.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333;"&gt;li&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a0, 8&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;            &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Spazio richiesto: 8bytes&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333;"&gt;syscall&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;                &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Spazio richiesto allocato&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333;"&gt;move&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;$s1, $v0&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Spostiamo lo spazio allocato nel registro $s1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Tuttavia, una soluzione più efficace è quella di richiedere una porzione di memoria più grande da syscall. L'uso di syscall, infatti, è abbastanza dispendioso e tale soluzione diminuirebbe il suo utilizzo durante l'esecuzione di un programma.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Quindi supponiamo che il nostro nodo della lista sia di 8bytes e usiamo i primi 4bytes per immagazzinare l'informazione voluta (un numero per esempio) e gli altri 4bytes come riferimento al nodo successivo nella lista.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;Per prima cosa dobbiamo definire due "etichette" (Labels in Inglese), una per far riferimento alla prima posizione libera ed usabile (quindi allocata) in memoria e un'altra per indicate l'ultima posizione disponibile. Quando l'ultima posizione disponibile è usata bisogna allocare nuova memoria.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;prossimoSpazioLibero:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .word &amp;nbsp; 0&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;ultimoSpazioLibero:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .word &amp;nbsp; 0&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;Quando gli indirizzi di memoria salvati su prossimoSpazioLibero e ultimoSpazioLibero sono identici, allora allochiamo nuova memoria altrimenti usiamo quella allocata precedentemente.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;lw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1,&amp;nbsp;prossimoSpazioLibero&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;lw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s2,&amp;nbsp;ultimoSpazioLibero&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;beq&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1, $s2, memoria_da_allocare &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;# Se le etichette puntano allo stesso luogo in memoria allora bisogna allocare nuova memoria&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;j&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;memoria_disponibile&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&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; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;# Altrimenti si usa la memoria già allocata&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;memoria_da_allocare&lt;/span&gt;&lt;span style="line-height: 19px;"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;li&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$v0, 9&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;li&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a0, 40 &lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="color: #38761d;"&gt;# 40 bytes -&amp;gt; 5 Nodi&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;syscall&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;move&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$s1, $v0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333; line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;sw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1,&amp;nbsp;&lt;/span&gt;&lt;span style="color: #333333; line-height: 19px;"&gt;prossimoSpazioLibero&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; line-height: 19px; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #38761d;"&gt;# Salviamo l'indirizzo della memoria allocata&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;addi&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$s2, $s1, 40&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333; line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;sw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s2,&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;ultimoSpazioLibero &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Calcoliamo l'indirizzo dell'ultimo spazio disponibile&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333; line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;j&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;memoria_disponibile &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Adesso la memoria è usabile e "saltiamo" a memoria_disponibile&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;Nel seguente metodo assumiamo che i registri $a1 e $a2 contengono rispettivamente il contenuto da salvare nel nodo corrente e il riferimento al nodo successivo.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;memoria_disponibile&lt;/span&gt;&lt;span style="line-height: 19px;"&gt;:&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a1, 0($s1)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Contenuto del nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a2, 4($s1)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Riferimento al prossimo nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;move&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;$v0, $s1&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&gt;&lt;span style="color: #38761d;"&gt;&amp;nbsp;# Indirizzo in memoria del nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;addi&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$s1, $s1, 8 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$s1, prossimoSpazioLibero&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Adesso prossimoSpazioLibero fa riferimento al prossimo nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Se il nostro obiettivo è quello di creare una lista, dovendo semplicemente inserire nuovi elementi ad essa, allora non dobbiamo preoccuparci del resto. Se invece vogliamo aggiungere la possibilità di poter eliminare un determinato elemento da una lista, la storia continua.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;L'espediente qui proposto non è l'unico disponibile, ma secondo me è quello più semplice ed anche molto efficace.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Ogni qualvolta che un' elemento della lista deve essere rimosso seguiamo il seguente processo logico:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol&gt;
&lt;li style="text-align: justify;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Troviamo il nodo (A) della lista che "punta" al nodo (B) contenente l'elemento da eliminare&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Memorizziamo l'indirizzo del nodo (B) da eliminare&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Facciamo si che il nodo (A) punti al prossimo valido nodo (C) della lista&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;Aggiungiamo il nodo (B) eliminato a una lista speciale (LS) contenente tutti i nodi eliminati e che possono essere riutilizzati in futuro&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;La nostra lista speciale verrà identificata dall'etichetta:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;listaNodiRiusabili:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .word &amp;nbsp; 0 &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
Ogni volta che un nodo o una determinata porzione di memoria vuole essere aggiunta alla lista dobbiamo far si che questa nuova porzione di memoria punti al primo nodo della listaNodiRiusabili.&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
Dopodiché la nuova porzione sarà il nuovo primo nodo della listaNodiRiusabili. Questo approccio è efficace perché eseguito tempo costante O(1).&amp;nbsp;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;lw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$t0, listNodiRiusabili&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;      &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Ripristiniamo il primo nodo della lista&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$t0, 8($a0)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&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: #38761d;"&gt;# Facciamo si che il nuovo nodo riusabile punto al primo nodo della lista&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a0, listaNodiRiusabili&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Il nuovo nodo adesso è il primo nodo della lista.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;Adesso è giunto il momento di modificare la nostra porzione di codice per richiedere nuova memoria. Se la nostra lista speciale (LS) contiene porzioni di memoria riutilizzabili, allora, bisogna preferire questi ad un ulteriore utilizzo di syscall.&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;lw &amp;nbsp; &amp;nbsp; &amp;nbsp;$t0, listaNodiRiusabili&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;                  &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Ripristina il primo nodo della lista&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;bne &amp;nbsp; &amp;nbsp; $t0, $zero, riusa_nodo&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Se la lista contiene almeno un nodo allora usiamolo!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="color: red;"&gt;#La porzione di codice sottostante è identica a quella precedente e così le relative procedure&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;lw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1,&amp;nbsp;prossimoSpazioLibero&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;lw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s2,&amp;nbsp;ultimoSpazioLibero&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;beq&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1, $s2, memoria_da_allocare &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;# Se le etichette puntano allo stesso luogo in memoria allora bisogna allocare nuova memoria&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;j&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;memoria_disponibile&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&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; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;# Altrimenti si usa la memoria già allocata&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: #333333;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;riusa_nodo:&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; lw&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$s1, listaNodiRiusabili&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; lw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$t0, 8($s1)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Otteniamo l'indirizzo del secondo nodo riusabile (questo è 0 se non c'è un secondo nodo)&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: 19px; text-align: justify;"&gt;
&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$t0, listaNodiRiusabili&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Fa si che il secondo nodo diventi il primo nodo della lista.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #333333; line-height: 19px;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #333333; font-family: inherit; line-height: 19px;"&gt;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; font-family: inherit; line-height: 19px; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333; font-family: inherit; line-height: 19px;"&gt;$a1, 0($s1)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; font-family: inherit; line-height: 19px; white-space: pre;"&gt;          &lt;/span&gt;&lt;span style="font-family: inherit; line-height: 19px;"&gt;&lt;span style="color: #38761d;"&gt;# Contenuto del nodo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp;sw&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #333333;"&gt;$a2, 4($s1)&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;          &lt;/span&gt;&lt;span style="color: #38761d;"&gt;# Riferimento al prossimo nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp;move&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #333333;"&gt;$v0, $s1&lt;/span&gt;&lt;span class="Apple-tab-span" style="color: #333333; white-space: pre;"&gt;   &lt;/span&gt;&lt;span style="color: #333333;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d;"&gt;&amp;nbsp;# Indirizzo in memoria del nodo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: #333333; line-height: 19px; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;strong&gt;Fonti&lt;/strong&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;MIPS:&amp;nbsp;http://it.wikipedia.org/wiki/Architettura_MIPS&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;SPIM MIPS Simulator:&amp;nbsp;http://spimsimulator.sourceforge.net/&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;MARS MIPS Simulator:&amp;nbsp;http://courses.missouristate.edu/KenVollmar/MARS/&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;MIPS Tutorial (en): http://www.cse.hcmut.edu.vn/~vtphuong/KTMT/Links/TutorialContents.html&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="color: #333333; line-height: 19px;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;Lista servizi di sistema (en): http://courses.missouristate.edu/KenVollmar/MARS/Help/SyscallHelp.html&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #333333; line-height: 19px;"&gt;ComputerSystems (en):&amp;nbsp;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="line-height: 19px;"&gt;http://wiki.cse.unsw.edu.au/cs1917cgi/10s1/ComputerSystems/Notes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/hGEFTkKD0so" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/6338741988144405205/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/03/mips32-gestione-della-memoria.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6338741988144405205?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6338741988144405205?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/hGEFTkKD0so/mips32-gestione-della-memoria.html" title="MIPS32 - Gestione della Memoria" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-_t7th7kvOmk/T1_b_ehFN9I/AAAAAAAAAKE/bc202c33VgY/s72-c/MIPS+Memory.gif" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/03/mips32-gestione-della-memoria.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8EQHY9eSp7ImA9WhVTFU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-8789870054331666453</id><published>2012-02-29T18:00:00.000+01:00</published><updated>2012-02-29T18:00:01.861+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-29T18:00:01.861+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Fondamenti" /><title>C - Controllare che un numero inserito sia corretto</title><content type="html">&lt;div style="text-align: justify;"&gt;
Una delle regole fondamentali della programmazione è quella di creare un software robusto: un software che sappia come reagire ad ogni evenienza e non vada in tilt ogni volta che avviene un'operazione non prestabilita.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Per chi ha un pò di esperienza in Java o in Python, sicuramente, sa che un blocco &lt;b&gt;try and catch&lt;/b&gt; o semplicemente un &lt;b&gt;throw exception&lt;/b&gt;&amp;nbsp;(solo Java) risolverebbe la questione.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Tuttavia in un linguaggio più a basso livello come C creare un software robusto richiede uno sforzo maggiore. Nel seguente articolo verrà spiegato come controllare che un numero intero, inserito da tastiera dall'utente, sia corretto o meno.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In C un numero intero di tipo &lt;b&gt;int&lt;/b&gt; è definito fra&amp;nbsp;&amp;nbsp;-2147483648 (&lt;b&gt;INT_MIN&lt;/b&gt;) e &amp;nbsp;2147483647 (&lt;b&gt;INT_MAX&lt;/b&gt;). Quindi qualsiasi numero inserito da tastiera che sia minore di INT_MIN o maggiore di INT_MAX non è da considerarsi valido.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Affinché il software sia robusto, è necessario riuscire a individuare altri tipi di errori come:&lt;/div&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;L'input non è un numero ma un carattere o una sequenza di caratteri&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;L'input è costituito da numeri e caratteri&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;L'input è costituito da un solo numero&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;div style="text-align: justify;"&gt;
Innanzitutto bisogna ricevere un input da tastiera. La soluzione più ovvia sarebbe quella di utilizzare scanf().&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
numeroElementi = Scanf("%d", &amp;amp;numero);&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Scanf(), infatti, restituirebbe un numberoElementi diverso da 1 nel caso l'input non sia valido.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Tuttavia, utilizzando scanf(), non è possibile controllare che il numero inserito sia nel range dei numeri perché scanf() converte qualsiasi input contenente delle cifre in un numero.&lt;br /&gt;
Quindi se viene inserito un numero troppo grande come 100000000000, scanf() restituirà un altro numero, per esempio -2452145, che rientra nel range dei numeri interi. Ciò non ci permette di controllare che il nostro numero sia valido.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
La soluzione è utilizzare fgets(), che ci permette di leggere alcun tipo di stringa (indipendentemente dalla sua lunghezza). Qualora l'input contenga più caratteri di quelli permessi, quelli in eccesso vanno a finire nel buffer che può sempre essere ripulito tramite un'operazione di flush.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Utilizzando fgets(), quindi, non leggiamo l'input direttamente come un numero, ma come una stringa. La stringa deve essere allora convertita in un numero e ciò avviene tramite la funzione: strtol().&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Nel nostro caso strtol() accetta i seguenti parametri:&lt;/div&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;stringa - La stringa da convertire in numero.&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&amp;amp;endptr - Un pointer dove viene "immagazzinato" tutto ciò che è superfluo&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;10 - la base numerica. In questo caso il numero sarà in base 10.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Il numero ritornato da strtol() è di tipo long. Inoltre, strtol() setta la variabile errno (importata da errno.h) a un valore diverso da 0 se alcun tipo di errore è stato individuato.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Test no. 1&lt;/b&gt;-&amp;gt; Affinché l'input possa considerarsi valido:&lt;/div&gt;
&lt;ol&gt;
&lt;li style="text-align: justify;"&gt;Nessun errore di tipo generico deve essere stato individuato&lt;/li&gt;
&lt;li&gt;&lt;div style="text-align: justify;"&gt;
L'input deve contenere esclusivamente cifre&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: justify;"&gt;
&lt;textarea cols="50" name="Code" rows="7" style="margin-left: 2px; margin-right: 2px; width: 371px;" title="Code"&gt;if ( errno
     || endptr == stringa 
     || *endptr != '\0') {
     printf("Errore 1\n");
} 
&lt;/textarea&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Test no. 2&lt;/b&gt; -&amp;gt; L'input per poter essere considerato un numero intero valido deve essere maggiore o uguale a INT_MIN e minore o uguale a INT_MAX. E' importante notare che non sempre il range long è uguale a quello di int, quindi bisogna eseguire un operazione di cast da long a int.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;textarea cols="20" name="Code" rows="12" style="height: 97px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px; width: 478px;" title="Code"&gt;// INT_MAX = 2147483647
// INT_MIN = -2147483648
if ((risultato &amp;lt; (long)INT_MIN) || (risultato &amp;gt; (long) INT_MAX)) {
      printf("Errore 2\n");
}
&lt;/textarea&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Ecco il codice intero per validare un numero intero da tastiera:&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;textarea cols="70" name="Code" rows="50" title="Code"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;limits.h&amp;gt; 
#include &amp;lt;errno.h&amp;gt; 

int validaNumeroIntero() {
 
 // La lunghezza massima è 13
 // INT_MIN = '-' + 11 cifre + '\0'
 // '\0' indica la fine di una stringa.
 int lunghezza = 13; 
 char stringa[lunghezza];
 long risultato;
 int temporaryBuffer;
 
 do{
  int i;
  char *endptr;
  
  printf("Inserire un numero intero: \n");
  fgets(stringa, lunghezza, stdin);
  // L'ultimo carattere in stringa deve essere
  // sostituito con '\0' per indicarne la fine.
  i = strlen(stringa)-1;
  if( stringa[i] == '\n') 
   stringa[i] = '\0';
  else {
   // Flush del buffer
   // La funzione flush() non può essere utilizzata in questo caso
   while (((temporaryBuffer = getchar()) != '\n')
       &amp;amp;&amp;amp; (temporaryBuffer != EOF));
  }

  // Convertire stringa in un numero di tipo long
  // in base 10 
  // Maggior informazioni su strtol() al sito:
  // http://linux.die.net/man/3/strtol
                // errno è una variabile di tipo int importata dalla libreria
                // errno.h. Qui viene settata a 0 per default per indicare che 
                // nessun errore è stato trovato.
  risultato = strtol(stringa, &amp;amp;endptr, 10);
  errno = 0;
  
  // Controlla che l'input sia valido:
  // 1. nessun errore generico sia stato individuato
  // 2. non siano stati trovati dei caratteri oltre che a dei numeri
  if ( errno
       || endptr == stringa 
       || *endptr != '\0') {
   errno = 1;
   printf("Errore 1\n");
  } 
   
  // Controlla che l'input sia tra INT_MIN e INT_MAX
  // INT_MAX = 2147483647
  // INT_MIN = -2147483648
  if ((risultato &amp;lt; (long)INT_MIN) || (risultato &amp;gt; (long) INT_MAX)) {
   errno = 1;
   printf("Errore 2\n");
  }
  
 } while (errno); // Uscire dal loop solo quando nessun errore sia stato individuato.
 
 return (int)risultato;
}


&lt;/textarea&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/rxx9ZAos9Q0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/8789870054331666453/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/02/c-controllare-che-un-numero-inserito.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8789870054331666453?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8789870054331666453?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/rxx9ZAos9Q0/c-controllare-che-un-numero-inserito.html" title="C - Controllare che un numero inserito sia corretto" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/02/c-controllare-che-un-numero-inserito.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UMQXk9fyp7ImA9WhJSEU4.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-4841484766841003375</id><published>2012-02-01T16:25:00.000+01:00</published><updated>2012-07-01T11:34:40.767+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-01T11:34:40.767+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Matematica" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Giochi" /><title>Java - Giochi da tavolo, Bit-Boards e Bit-Masks</title><content type="html">&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Quasi ad ogni programmatore, più o meno esperto che sia, è capitato almeno una volta nella propria carriera di creare un programma per gioco da tavolo.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Il gioco da tavolo è un gioco che richiede una superficie di gioco prestabilita at priori sulla quale vengono disposti i pezzi dei giocatori. Molte volte il tavolo da gioco può essere rappresentato geometricamente in modo molto semplice e intuitivo (vedi la scacchiera degli scacchi, dama o reversi). Altre volte, invece, ciò può apparire più complicato, come nel gioco di Risiko. Tuttavia, anche in queste situazioni la "mappa" può essere ridotta a un modello più semplice di grafo e come ben sappiamo un grafo può facilmente essere rappresentato da una matrice 2x2.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Se stiamo programmando in Java, o in qualsiasi altro linguaggio ad oggetti, rappresentare la stato del tavolo di gioco risulta abbastanza diretto. Basta, infatti, creare un array 2x2 di oggetti e inserire i pezzi dei giocatori nelle apposite posizioni.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Molte altre volte non è possibile rappresentare il tavolo da gioco usando degli oggetti oppure persiste la necessità di aumentare la velocità di calcolo quando si eseguono determinate operazioni sui pezzi della superficie. In questi casi useremmo le Bit Boards!&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Per Bit Board si indica un tavolo da gioco rappresentato come una sequenza di bits. Quindi di 0 e 1.&amp;nbsp;Per chi non fosse famigliare con il sistema binario consiglio il seguente &lt;a href="http://sic-oding.blogspot.com/2011/11/il-sistema-binario.html" target="_blank"&gt;articolo&lt;/a&gt;.&amp;nbsp;In Java esiste la classe &lt;a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/BitSet.html" target="_blank"&gt;BitSet&lt;/a&gt; che potrebbe essere utilizzata per rappresentare le sequenze di bits. Tuttavia le operazioni Booleane e di shifting risultano alquanti tediose. Una soluzione più semplice ed efficace, quindi, è quella di rappresentare le sequenza di bit in formato decimale. Per un tavolo da gioco 4x4 useremmo &lt;b&gt;short&lt;/b&gt; (dato che è 16 bits) e &lt;b&gt;long&lt;/b&gt; per un tavolo 8x8 (dato che è 64 bits). Questi tipi primitivi, oltre a favorire le operazioni prima elencate, favoriscono una velocità di calcolo maggiore rispetto all'uso di oggetti (che occupano più spazio in memoria). Ciò si rileva fondamentale se stiamo programmando un sistema d'intelligenza artificiale e nell'uso dell'algoritmo di MiniMax si producono centinaia di migliaia di casi e relative tavole da gioco virtuali.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Di seguito riporto un esempio grafico molto semplice per illustrare un utilizzo di Bit Board.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-3yJFEkm50wM/TyayQOrNh8I/AAAAAAAAAJ0/PRvP7048HIY/s1600/bitboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="249" src="http://3.bp.blogspot.com/-3yJFEkm50wM/TyayQOrNh8I/AAAAAAAAAJ0/PRvP7048HIY/s640/bitboard.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Tramite operazioni di shifting, inoltre, è possibile calcolare le mosse disponibili per ogni giocatore. In Java le operazioni di shifting avvengono tramite gli operatori '&lt;b&gt;&amp;lt;&amp;lt;&lt;/b&gt;' (shift a sinistra) e '&lt;b&gt;&amp;gt;&amp;gt;&lt;/b&gt;' (shift a destra). Tuttavia questo va oltre l'obbiettivo del seguente articolo perché ogni gioco da tavolo possiede regole diverse e quindi le operazioni di shifting avverranno di conseguenza.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Un altro elemento importante sono le Bit Masks. Le Bit Masks sono un sottotipo di Bit Boards utilizzate per rimuovere certe parti del tavolo da gioco. Le Masks in generale trovano anche &lt;a href="http://en.wikipedia.org/wiki/Mask_(computing)" target="_blank"&gt;altri utilizzi&lt;/a&gt;, come nell'ambito della grafica.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Ecco un esempio che illustra come creare una Bit Mask per rimuovere la prima riga e la prima colonna di un tavolo da gioco.&amp;nbsp;&lt;/div&gt;
&lt;pre class="brush:java"&gt; 
int[][] mask = { { 1, 1, 1 },
                          { 1, 0, 0 },
                          { 1, 0, 0 } };

short bitMask = 0; 
short power2 = 1;

for ( int i = mask.length - 1; i &amp;gt;= 0; i-- ) {
      for ( int j = mask[0].length - 1; j &amp;gt;= 0; j-- ) {
            bitMask += power2 * mask[i][j];
            power2 *= 2;
            }
      }
&lt;/pre&gt;
&lt;script src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlightLoader.js"&gt;
&lt;/script&gt;

Capire e usare Bit Boards e Bit Masks può non essere facile e immediato, ma come per ogni cosa nella programmazione bisogna: provare e sbagliare finché non ci si riesce.&amp;nbsp;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Per ulteriori informazioni e approfondimenti consiglio vivamente di visitare i link citati tra le fonti.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
http://chessprogramming.wikispaces.com/Bitboards&lt;br /&gt;
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/0BmOPcrwBYY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/4841484766841003375/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/02/java-giochi-da-tavolo-bit-boards-e-bit.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4841484766841003375?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4841484766841003375?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/0BmOPcrwBYY/java-giochi-da-tavolo-bit-boards-e-bit.html" title="Java - Giochi da tavolo, Bit-Boards e Bit-Masks" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-3yJFEkm50wM/TyayQOrNh8I/AAAAAAAAAJ0/PRvP7048HIY/s72-c/bitboard.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/02/java-giochi-da-tavolo-bit-boards-e-bit.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkACQHc5cCp7ImA9WhRUFU0.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-6498056453343156415</id><published>2012-01-25T10:11:00.000+01:00</published><updated>2012-01-25T17:26:01.928+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-25T17:26:01.928+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Haskell" /><category scheme="http://www.blogger.com/atom/ns#" term="Grafica" /><title>Haskell - Grafica 2D con Gloss</title><content type="html">La libreria &lt;a href="http://hackage.haskell.org/packages/archive/gloss/1.0.0.1/doc/html/Graphics-Gloss.html" target="_blank"&gt;Gloss&lt;/a&gt;, in Haskell, ci permette di creare delle semplici interfacce grafiche 2D. Gloss è particolarmente conosciuta per la sua semplicità e facilità d'uso.&lt;br /&gt;
&lt;br /&gt;
In questo articolo spiegherò le basi per poter utilizzare la libreria Gloss.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Il primo passo è importare la libreria nel proprio documento .hs :&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;import Graphics.Gloss&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
A questo punto viene richiamata la funzione display della libreria, come nell'esempio qui sotto:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;main &lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;= display&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (InWindow&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Hello World" &lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp;-- titolo della finestra&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;(400, 150) &lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- dimensione della finestra&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;(10, 10)) &lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- posizione della finestra&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;white&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- colore sfondo&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;picture&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- immagine da visualizzare.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
La palette dei colori usata da Gloss è la seguente:&lt;br /&gt;
Black, White, Red, Green, Blue, Yellow, Cyan, Magenta, Rose, Violet, Azure, Aquamarine, Chartreuse, Orange. Per ulteriori informazioni sui colori in Gloss e il loro utilizzo raccomando la seguente &lt;a href="http://hackage.haskell.org/packages/archive/gloss/1.0.0.1/doc/html/Graphics-Gloss-Color.html" target="_blank"&gt;pagina&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Con picture si può intendere una singola immagine, come una collezione di immagini da visualizzare.&lt;br /&gt;
Nel seguente esempio Picture è:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;picture&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;= Translate (-170) (-20) -- sposta l'immagine al centro della finestra&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$ Scale 0.5 0.5&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;-- visualizza l'immagine al 50% della dimensione originaria&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;$ Text "Hello World" &amp;nbsp; &amp;nbsp;-- testa da visualizzare&lt;/i&gt;&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/-M-TOLe565sM/Tx0fRZOxbiI/AAAAAAAAAJI/husTE8yEBFw/s1600/gloss-hello.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-M-TOLe565sM/Tx0fRZOxbiI/AAAAAAAAAJI/husTE8yEBFw/s400/gloss-hello.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Alcuni degli esempi ufficiali della libreria possono essere trovati &lt;a href="http://hackage.haskell.org/package/gloss-examples-1.5.0.1" target="_blank"&gt;qui&lt;/a&gt;.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Nell'esempio Clock possiamo notare come Picture rappresenti un insieme di "Pictures":&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;i&gt;Pictures
  [ Line [(0, 0), ( 0,  a)]
  , Line [(0, 0), ( 1, -b)]
  , Line [(0, 0), (-1, -b)] ]&lt;/i&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;Dove &lt;b&gt;a&lt;/b&gt; e &lt;b&gt;b&lt;/b&gt; rappresentano delle variabili che definiscono le coordinate dell'oggetto Line. La libreria Gloss da la possibilità di usare anche delle forme più complesse oltre che alla semplice linea. &lt;a href="http://hackage.haskell.org/packages/archive/gloss/1.0.0.1/doc/html/Graphics-Gloss-Shapes.html" target="_blank"&gt;Qui&lt;/a&gt; è possibile trovare la pagina ufficiale di Gloss con tutte le forme e i rispettivi parametri, come rectangleSolid e &lt;a href="http://hackage.haskell.org/packages/archive/gloss/1.0.0.1/doc/html/Graphics-Gloss-Picture.html#t:Picture" target="_blank"&gt;Circle&lt;/a&gt;. &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;Inoltre è possibile impostare colore e coordinate di ogni singolo oggetto come nell'esempio seguente:&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="white-space: pre-wrap;"&gt;&lt;i&gt;Pictures [(Color red  (translate x y
                                      (rectangleSolid width height)))
             ]&lt;/i&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="white-space: pre-wrap;"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="white-space: pre-wrap;"&gt;In questo esempio viene creato un rettangolo di colore rosso (&lt;b&gt;red&lt;/b&gt;) in posizione (&lt;b&gt;x, y&lt;/b&gt;) dall'origine rispetto all'asse cartesiano e con larghezza &lt;b&gt;width&lt;/b&gt; e larghezza &lt;b&gt;height&lt;/b&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="text-align: -webkit-auto; word-wrap: break-word;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="white-space: pre-wrap;"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;Altre volte, invece, il numero di oggetti da visualizzare non è conosciuto. In questo caso la soluzione risiede nella tecnica più usata in Haskell: la &lt;i&gt;ricorsione&lt;/i&gt;.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;i&gt;listaImmagini :: Int -&amp;gt; Picture&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;i&gt;
&lt;div&gt;
listaImmagini 0 = Pictures [Blank]&lt;/div&gt;
&lt;div&gt;
listaImmagini&amp;nbsp;n&amp;nbsp;= Pictures [(Color&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;red&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(translate &amp;nbsp;x y&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(rectangleSolid width height)))&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,&amp;nbsp;listaImmagini&amp;nbsp;(n - 1)]&lt;/div&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Come gli operatori '&lt;b&gt;:&lt;/b&gt;'&amp;nbsp;e '&lt;b&gt;++&lt;/b&gt;'&lt;b&gt;&amp;nbsp;&lt;/b&gt;vengono comunemente usati per appendere un qualcosa ad una lista, in Picture l'operatore di "aggiunta" è '&lt;b&gt;,&lt;/b&gt;' e la funzione listaImmagini viene chiamata ricorsivamente finché non si raggiunge il caso base zero e l'ultima immagine ad essere aggiunta è quella nulla: &lt;b&gt;Blank&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Ecco un esempio tratto dal gioco Core War (versione scritta dal sottoscritto).&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/-yj8EqXjnKpU/Tx0kMmHjK5I/AAAAAAAAAJQ/xwCObmAc82U/s1600/Schermata+2012-01-23+a+09.11.32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="382" src="http://2.bp.blogspot.com/-yj8EqXjnKpU/Tx0kMmHjK5I/AAAAAAAAAJQ/xwCObmAc82U/s400/Schermata+2012-01-23+a+09.11.32.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
http://gloss.ouroborus.net/&lt;br /&gt;
http://hackage.haskell.org/packages/archive/gloss/1.0.0.1/doc/html/Graphics-Gloss.html&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/lGHClW4Q1sE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/6498056453343156415/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/01/haskell-grafica-2d-con-gloss.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6498056453343156415?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6498056453343156415?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/lGHClW4Q1sE/haskell-grafica-2d-con-gloss.html" title="Haskell - Grafica 2D con Gloss" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-M-TOLe565sM/Tx0fRZOxbiI/AAAAAAAAAJI/husTE8yEBFw/s72-c/gloss-hello.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/01/haskell-grafica-2d-con-gloss.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEFQX86eCp7ImA9WhJTFEs.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-8151404771529988474</id><published>2012-01-10T17:51:00.001+01:00</published><updated>2012-06-23T16:43:30.110+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-23T16:43:30.110+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Network" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Mac OS X" /><title>KisMAC - Scovare e crackare reti Wireless (WEP e WAP)</title><content type="html">&lt;div style="text-align: justify;"&gt;
KisMAC&amp;nbsp;è un OpenSource software per Mac in grado di scovare reti wireless e crackarle.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Prima di iniziare a parlarvi di questo fantastico strumento premetto che KisMAC non dovrebbe essere utilizzato per scopi illeciti. KisMAC è per chi ha intenzione di imparare qualcosa di nuovo.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Prima di iniziare a vedere come usare KisMAC bisogna scaricare l'applicazione dal sito ufficiale:&amp;nbsp;&lt;a href="http://kismac-ng.org/" target="_blank"&gt;KisMAC&lt;/a&gt;.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Cosa fa KisMAC&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;Rileva SSIDs (nome con cui una rete WiFi si identifica ai suoi utenti) nascoste, mascherate e/o chiuse.&amp;nbsp;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Mostra gli utenti connessi (con indirizzo &lt;a href="http://it.wikipedia.org/wiki/Indirizzo_MAC" target="_blank"&gt;MAC&lt;/a&gt;, &lt;a href="http://it.wikipedia.org/wiki/Internet_Protocol" target="_blank"&gt;IP&lt;/a&gt; e potenza di segnale)&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Pcap" target="_blank"&gt;PCAP&lt;/a&gt;: API per registrare il traffico di rete&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Supporta gli standard 802.11b/g&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Supporta diversi attacchi alla rete (WPA, WEP, etc)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
In poche parole KisMAC ci permette di "&lt;a href="http://www.dia.unisa.it/~ads/corso-security/www/CORSO-0001/snifferPCAP/Documentazione/sniffer.htm" target="_blank"&gt;sniffare&lt;/a&gt;" una rete.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Innanzitutto bisogna definire le due modalità supportate dalla schede di rete: &lt;a href="http://trac.kismac-ng.org/wiki/FAQ#ActivePassive" target="_blank"&gt;&lt;b&gt;Active Mode&lt;/b&gt; e &lt;b&gt;Passive Mode&lt;/b&gt;&lt;/a&gt;.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Active Mode&lt;/b&gt;:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;Invia sonde per esplorare la rete (&lt;b&gt;probes&lt;/b&gt;)&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Poco utilizzato perché raccoglie anche dati che non sono utili&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Passive Mode&lt;/b&gt; (Monitor Mode):&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;Permette di vedere qualsiasi cosa entro un certo raggio&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Permette injection-attacks&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Permette de-authentication attacks&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Configurare KisMAC&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Dopo aver installato KisMAC recarsi nel pannello di preference (KisMAC/ Preferences) e nello specchietto dei Drivers selezionare il driver da utilizzare per la scansione della rete.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Selezionando il driver avrete una schermata simile a quella mostrata qui in basso. Nell'area Dump Filter ho selezionato No Dumping perché personalmente non sono interessato nel conservare i dati raccolti per poi analizzarli con altri strumenti.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Ecco, comunque, a cosa servono le altre tre opzioni:&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="background-color: white; text-align: -webkit-left;"&gt;
&lt;li style="text-align: justify;"&gt;Keep everything - Il traffico raccolto è memorizzato in un file di log&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Data only - Solo i pacchetti con del contenuto sono memorizzati nel file di log&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Weak frames only - Solo pacchetti con vettori d'inizializzazione debole sono memorizzati nel file di log&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-w6gbwyzoows/Twxi1V7fC6I/AAAAAAAAAIk/HmNbKDFWgtw/s1600/setup.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://2.bp.blogspot.com/-w6gbwyzoows/Twxi1V7fC6I/AAAAAAAAAIk/HmNbKDFWgtw/s400/setup.png" width="328" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Osservare il traffico&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: right;"&gt;
&lt;a href="http://1.bp.blogspot.com/-VPGAH61m49I/TwxjCKWlc_I/AAAAAAAAAIs/k6ri_Fc4_NQ/s1600/Schermata+2012-01-10+a+15.41.34.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="448" src="http://1.bp.blogspot.com/-VPGAH61m49I/TwxjCKWlc_I/AAAAAAAAAIs/k6ri_Fc4_NQ/s640/Schermata+2012-01-10+a+15.41.34.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;b style="text-align: -webkit-auto;"&gt;&lt;a href="http://it.wikipedia.org/wiki/Wired_Equivalent_Privacy" target="_blank"&gt;&lt;span style="font-size: large;"&gt;WEP&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;b style="text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Injection&lt;/b&gt;: cos'è e quando usarlo.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Per Injection ci si riferisce ad una particolare tecnica per ottenere più pacchetti possibili da una rete. Se la propria scheda di rete supporta Injection allora uno speciale pacchetto (che sarà come dire "Ciao" al telefono) verrà inviato ad un computer e questo molto probabilmente invierà indietro una risposta. Se quest'operazione è eseguita centinaia di volte, allora noi riceveremmo altrettanti pacchetti risposta e sarà più facile crackare la chiave di cifratura. Per iniziare la fase di Injection selezionare dal menù: Network / Reinject Packets.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-PXZ4e-KU22M/TwxjIJ1LlYI/AAAAAAAAAI0/iAxmNwi_3kI/s1600/Schermata+2012-01-10+a+16.07.36.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="161" src="http://1.bp.blogspot.com/-PXZ4e-KU22M/TwxjIJ1LlYI/AAAAAAAAAI0/iAxmNwi_3kI/s320/Schermata+2012-01-10+a+16.07.36.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Injection è una tecnica usata solamente per crackare una rete protetta da cifratura WEP. Per riuscire a trovare la chiave di cifratura bisogna raccogliere almeno 200,000 pacchetti ed ecco perché usiamo Injection. E' comunque consigliabile comprare una scheda di rete apposita, invece della scheda Airport Extreme che esce con il vostro Mac.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Dopo aver collezionato abbastanza pacchetti selezionare: Network / Crack / Weck Scheduling Attacks / Against 40-bit. Se questo tipo di attacco non funziona, allora provate gli altri. Se nessuno degli attacchi funziona allora è consigliabile raccogliere più pacchetti o visitare il sito ufficiale per maggiori informazioni.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;&lt;a href="http://it.wikipedia.org/wiki/Wi-Fi_Protected_Access" target="_blank"&gt;WPA&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Scovare una chiave WPA, per KisMAC, può essere semplice o impossibile. Il problema risiede nel fatto che per crackare una rete protetta da WPA, KisMAC deve riuscire a "catturare" un &lt;a href="http://it.wikipedia.org/wiki/Handshake" target="_blank"&gt;handshake&lt;/a&gt;. Per ottenere un handshake bisogna utilizzare un de-authenticate attack: Network / Deauthenticate&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Inoltre, una ragione per cui KisMAC non potrebbe mai trovare la chiave è che l'handshake è basato su una lista di parole: &lt;a href="http://trac.kismac-ng.org/wiki/wordlists" target="_blank"&gt;wordlist&lt;/a&gt;&amp;nbsp;poco adatta.&amp;nbsp;Esistono tuttavia altre modi per crackare una rete protetta da WPA che non funzionano con KisMAC e che discuterò in futuro.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Ok, passiamo avanti e vediamo come scovare la chiave WPA se si è ricevuto l'handshake. Se si è ricevuto l'handshake l'icona sull'ultima colonna a destra nella figura in basso sarà verde, altrimenti rossa.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Se l'icona è verde allora si può partire con l'attacco: Network / Crack / Wordlist Attack / Against WPA Key (scegliere quindi un file contenente la lista di parole. E' possibile trovarne &lt;a href="http://trac.kismac-ng.org/wiki/wordlists" target="_blank"&gt;qui&lt;/a&gt;).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-wd6F8zzFpDo/TwxjLshC0iI/AAAAAAAAAI8/yxvOLluYEVY/s1600/Schermata+2012-01-10+a+15.41.26.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="280" src="http://2.bp.blogspot.com/-wd6F8zzFpDo/TwxjLshC0iI/AAAAAAAAAI8/yxvOLluYEVY/s400/Schermata+2012-01-10+a+15.41.26.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;Note&lt;/span&gt;&lt;/b&gt;:&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Purtroppo l'Injection non funziona con Airport Extreme sotto MAC OS X Leopard.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Il sito ufficiale consiglia, comunque, di aquistare un supporto USB esterno con chip: Prism2, RT73, RT2570, o RTL8187.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Fonti&lt;/b&gt;:&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Sito ufficiale: http://kismac-ng.org/&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Wiki:&amp;nbsp;http://trac.kismac-ng.org/&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Guida: http://stagingkiller.wordpress.com/2009/06/26/the-definitive-kismac-article/&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Forum:&amp;nbsp;http://forum.kismac-ng.org/&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/f0zRl0RfYf0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/8151404771529988474/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/01/kismac-scovare-e-crackare-reti-wireless.html#comment-form" title="7 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8151404771529988474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8151404771529988474?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/f0zRl0RfYf0/kismac-scovare-e-crackare-reti-wireless.html" title="KisMAC - Scovare e crackare reti Wireless (WEP e WAP)" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-w6gbwyzoows/Twxi1V7fC6I/AAAAAAAAAIk/HmNbKDFWgtw/s72-c/setup.png" height="72" width="72" /><thr:total>7</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/01/kismac-scovare-e-crackare-reti-wireless.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MERnw6fip7ImA9WhRVEUg.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-7276307326588318288</id><published>2012-01-09T23:30:00.000+01:00</published><updated>2012-01-10T00:23:27.216+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-10T00:23:27.216+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Matematica" /><category scheme="http://www.blogger.com/atom/ns#" term="Algoritmi" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Fondamenti" /><title>Bubble Sort vs Merge Sort</title><content type="html">&lt;div style="text-align: justify;"&gt;
In questo articolo parlerò di un analisi degli algoritmi Bubble Sort e Merge Sort che ho fatto in uno dei miei progetti universitari.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
I due algoritmi appena citati vengono utilizzati per ordinare un insieme di elementi (numeri, lettere, e qualsiasi oggetto che può essere confrontato con un suo simile sulla base &lt;i&gt;maggiore di, minore di, uguale a&lt;/i&gt;).&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Di seguito riporto entrambi gli algoritmi con descrizione:&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;Grafica&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Letterale&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;usando Pseudo-codice o codice&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Bubble Sort&lt;/b&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-_nT8LofOPnw/TwGE4RFpHOI/AAAAAAAAAFQ/Bd6IByj-gT0/s1600/Bubble-sort-example-300px.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="192" src="http://4.bp.blogspot.com/-_nT8LofOPnw/TwGE4RFpHOI/AAAAAAAAAFQ/Bd6IByj-gT0/s320/Bubble-sort-example-300px.gif" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;i&gt;Pseudo-codice&lt;/i&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
- Traversare un array (o lista) scambiando i numeri adiacenti che non sono in ordine. L'ordinamento finisce quando non è più necessario scambiare numeri adiacenti.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
while scambio&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; scambio = Falso (False)&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; for j = 0 to j &amp;lt; (Array.length - i - 1)&amp;nbsp;&amp;lt;--&amp;nbsp;&lt;b&gt;Bolla&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&amp;nbsp;Array[j] &amp;gt;&amp;nbsp;Array[j + 1]&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scambia&amp;nbsp;Array[j] con&amp;nbsp;Array[j + 1]&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scambio = Vero (True)&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Merge Sort&lt;/b&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-fhZBjWaL6Ww/TwGFRsXATOI/AAAAAAAAAFo/il3tdQqY_J8/s1600/Merge-sort-example-300px.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="192" src="http://1.bp.blogspot.com/-fhZBjWaL6Ww/TwGFRsXATOI/AAAAAAAAAFo/il3tdQqY_J8/s320/Merge-sort-example-300px.gif" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;i&gt;Pseudo-codice&lt;/i&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Se l'array (o la lista) ha lunghezza 0 o 1 allora è ordinata. Altrimenti:&lt;/li&gt;
&lt;li&gt;Dividere l'array disordinato in due sub-array la cui lunghezza è la metà dell'array iniziale&lt;/li&gt;
&lt;li&gt;Ordina ogni sub-array ricorsivamente usando&lt;b&gt; Merge Sort&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Merge&lt;/b&gt; (unire) i due sub-array in un unico ordinato array.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
In questo caso ritengo più opportuno riportare il codice in Java, invece, che in pseudo-codice perché ritengo che il funzionamento dell'algoritmo Merge Sort possa essere compreso più facilmente in questo modo.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;public int[] &lt;b&gt;mergeSort&lt;/b&gt; (int[] array) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;if (array.length &amp;lt;= 1) return&amp;nbsp;array;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int metaDimensione =&amp;nbsp;array.length / 2;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int[] primoArray = new int[metaDimensione];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int[] secondoArray = new int[array.length -&amp;nbsp;metaDimensione];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// Crea il primoArray&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;for(int i = 0; i &amp;lt;&amp;nbsp;metaDimensione; i ++) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;primoArray[i] =&amp;nbsp;array[i];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// Crea il&amp;nbsp;secondoArray&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;for(int i =&amp;nbsp;metaDimensione; i &amp;lt;&amp;nbsp;array.length; i ++) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;secondoArray[i -&amp;nbsp;metaDimensione] =&amp;nbsp;array[i];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;primoArray&amp;nbsp;=&amp;nbsp;&lt;b&gt;mergeSort&lt;/b&gt;(primoArray);&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;secondoArray&amp;nbsp;=&amp;nbsp;&lt;b&gt;mergeSort&lt;/b&gt;(secondoArray);&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int[] arrayOrdinato = &lt;b&gt;merge&lt;/b&gt;(primoArray,&amp;nbsp;secondoArray);&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;return&amp;nbsp;arrayOrdinato;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;private int[] &lt;b&gt;merge&lt;/b&gt;(int[]&amp;nbsp;primoArray, int[]&amp;nbsp;secondoArray) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int[] arrayFinale = new int[primoArray.length +&amp;nbsp;secondoArray.length];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int indicePrimoArray = 0;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int&amp;nbsp;indiceSecondoArray&amp;nbsp;= 0;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;int&amp;nbsp;indiceArrayFinale&amp;nbsp;= 0;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;while ((indicePrimoArray&amp;nbsp;&amp;lt;&amp;nbsp;primoArray.length) &amp;amp;&amp;amp; (indiceSecondoArray&amp;nbsp;&amp;lt;&amp;nbsp;secondoArray.length)) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;if (primoArray[indicePrimoArray] &amp;lt;=&amp;nbsp;secondoArray[indiceSecondoArray]) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;arrayFinale[indiceArrayFinale] =&amp;nbsp;primoArray[indicePrimoArray];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;indicePrimoArray&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;} else {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;arrayFinale[indiceArrayFinale] =&amp;nbsp;secondoArray[indiceSecondoArray];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;indiceSecondoArray&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;indiceArrayFinale&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// Append all the rest of the left Array&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;while (indicePrimoArray&amp;nbsp;&amp;lt;&amp;nbsp;primoArray.length) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;arrayFinale[indexResult] =&amp;nbsp;primoArray[indicePrimoArray];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;indicePrimoArray&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;indiceArrayFinale&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;// Append all the rest of the right Array.&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;while (indiceSecondoArray&amp;nbsp;&amp;lt;&amp;nbsp;secondoArray.length) {&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;arrayFinale[indexResult] =&amp;nbsp;secondoArray[indiceSecondoArray];&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;indiceSecondoArray&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;indiceArrayFinale&amp;nbsp;++;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;return&amp;nbsp;arrayFinale;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-style: italic;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-MKX8xTcVDwY/TwGFebTE8VI/AAAAAAAAAF0/jnm8m2RKM2U/s1600/618px-Merge_sort_algorithm_diagram.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="308" src="http://4.bp.blogspot.com/-MKX8xTcVDwY/TwGFebTE8VI/AAAAAAAAAF0/jnm8m2RKM2U/s320/618px-Merge_sort_algorithm_diagram.svg.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Algoritmi a confronto&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Prima di iniziare a fare un confronto fra i due algoritmi ritengo opportuno dare un'occhiata agli algoritmi singolarmente.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Bubble Sort&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Osservando lo pseudo-codice (vedi sopra) possiamo subito notare che la prima volta che l'array in questione è "traversato" l'elemento con il valore più alto è spostato all'estrema destra dell'array (ordinamento ascendente). Quindi, supponendo che l'array è di dimensione &lt;b&gt;n&lt;/b&gt;, l'algoritmo traversa (&lt;b&gt;n - 1&lt;/b&gt;) elementi la volta successiva. All'iterazione jth, l'algoritmo di Bubble sort traversa (&lt;b&gt;n - j&lt;/b&gt;) elementi, dove j è un intero compreso fra 0 e (&lt;b&gt;n - 1&lt;/b&gt;).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Possiamo quindi dire che la complessità è O(n^2). Nel miglior caso è O(n) dato che la lista è subito riconosciuta come ordinata e non c'è alcun bisogno di traversala altre volte.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Eseguendo l'algoritmo migliaia di volte su lista diverse di dimensioni diverse ho collezionato una certa quantità di dati che ho poi espresso graficamente:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-4jfAPeV1riE/Twtt3v1HF-I/AAAAAAAAAHE/t3Nv66bEMEY/s1600/bubble+sort.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="468" src="http://3.bp.blogspot.com/-4jfAPeV1riE/Twtt3v1HF-I/AAAAAAAAAHE/t3Nv66bEMEY/s640/bubble+sort.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Utilizzando Excel ho potuto confrontare i dati con la linea di miglior approssimazione, verificando la credibilità dei dati raccolti. Inoltre, sempre usando Excel, ho calcolato l'equazione della curva ottenuta e ho potuto notare che il grado è 2, come ci si aspettava da un algoritmo di complessità O(n^2).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Merge Sort&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
La complessità dell'algoritmo di Merge Sort avviene in due fasi:&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li style="text-align: justify;"&gt;La lista viene divisa in due parti ricorsivamente -&amp;gt; O(log n)&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;Due liste vengono unite in una -&amp;gt; O (n)&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
Quindi la complessità è O(n (log n)).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Il grafico sottostante è il risultato ottenuto dopo aver ordinato migliaia di liste usando Merge Sort.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-WnBm-kGEr0E/Twtwb_EPhYI/AAAAAAAAAHM/7IbgnrHV2NU/s1600/merge+sort.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="466" src="http://2.bp.blogspot.com/-WnBm-kGEr0E/Twtwb_EPhYI/AAAAAAAAAHM/7IbgnrHV2NU/s640/merge+sort.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Faccio notare che, a differenza del algoritmo Bubble Sort, la curva ottenuta è lineare e di grado 1 ad una prima analisi. Tuttavia, dopo una più attenta analisi con Excel ho potuto constatare che l'equazione della linea di migliore approssimazione (linea rossa) è:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
f(n) = 55 * n * log (n) + 50000, che è di ordine n * log(n) come previsto.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Tuttavia, per capire meglio quale dei due algoritmi è migliore bisogna sovrapporre i due grafici, che parlano da sè:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-bRo7q8jJsrI/TwtyE8LFMKI/AAAAAAAAAHU/ZOdQGKl_RyM/s1600/bubble+sort+vs+merge+sort.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="472" src="http://1.bp.blogspot.com/-bRo7q8jJsrI/TwtyE8LFMKI/AAAAAAAAAHU/ZOdQGKl_RyM/s640/bubble+sort+vs+merge+sort.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b&gt;Analisi Avanzata degli Algoritmi&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Nel mio esperimento universitario ho ben deciso di analizzare anche altri aspetti degli algoritmi per capire quando un algoritmo "&lt;i&gt;consuma"&lt;/i&gt; di più.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;b&gt;Bubble Sort&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Il seguente grafico mostra il tempo impiegato ad ogni &lt;b&gt;bolla&lt;/b&gt; (un iterazione dell'array). Il grafico mostra come il tempo speso su ogni bolla diminuisce come l'array diventa più ordinata. Tuttavia all'inizio il tempo impiegato su ogni bolla incrementa probabilmente. Questo purtroppo è un fatto che non sono riuscito a capire del tutto.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-Hw8mmLDAJug/TwtyhZHLnYI/AAAAAAAAAHc/5tsLNRv_bek/s1600/bubble+sort+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="366" src="http://3.bp.blogspot.com/-Hw8mmLDAJug/TwtyhZHLnYI/AAAAAAAAAHc/5tsLNRv_bek/s640/bubble+sort+2.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
I dati possono essere meglio analizzati osservando il grafico cumulativo di quello appena mostrato:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-_sdJemHtXtw/Twt0XD7wiOI/AAAAAAAAAHk/YcH35xfJsPI/s1600/bubble+sort+3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="396" src="http://2.bp.blogspot.com/-_sdJemHtXtw/Twt0XD7wiOI/AAAAAAAAAHk/YcH35xfJsPI/s640/bubble+sort+3.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Osserviamo come la pendenza della curva, man mano che l'array diventa più ordinato, diminuisce. Questo è un segno che l'algoritmo diventa più veloce sulle ultime bolle rispetto all'inizio, quando la lista è completamente disordinata.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;b&gt;Merge Sort&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Il grafico sottostante mostra i dati che ho collezionato per il tempo speso ogni volta che la funzione &lt;b&gt;Merge&lt;/b&gt; è stata utilizzata. Ho deciso di analizzare solo la funzione di Merge perché è la parte dell'algoritmo dove viene speso più tempo.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Quando ho analizzato l'algoritmo, l'albero che ne nasce dall'algoritmo è stato traversato &lt;a href="http://en.wikipedia.org/wiki/Tree_traversal#Postorder_Traversal" target="_blank"&gt;post-order&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Il puntino blu in alto a destra mostra il tempo impiegato per unire (Merge) le due liste ottenute dalla lista originale e che sono già ordinate (i due puntini blu sottostanti, time: 25000 circa sull'asse delle y).&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: justify;"&gt;
Da notare che i puntini alla stessa altezza nell'asse del tempo (asse delle y) sono sempre potenze di due. L'agglomerato di puntini blu rappresenta tutte quelle liste di dimensione molto piccola per cui la fase di Merge avviene molto rapidamente.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-i00bsg4ic9Q/Twt04DP7oSI/AAAAAAAAAHs/GEQ9i8b40PU/s1600/merge+sort+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="480" src="http://1.bp.blogspot.com/-i00bsg4ic9Q/Twt04DP7oSI/AAAAAAAAAHs/GEQ9i8b40PU/s640/merge+sort+2.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Note&lt;/b&gt;:&lt;br /&gt;
I dati sono stati raccolti usando un MacBookPro (CPU: Intel Core 2 Duo 2,4 GHz, RAM: 4GB)&lt;br /&gt;
I dati sono stati analizzati usando Microsoftft®&amp;nbsp;Excel® per&amp;nbsp;Mac&amp;nbsp;2011.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fonti:&lt;/b&gt;&lt;br /&gt;
Immagini: wikipedia.org&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/8687EwodyRc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/7276307326588318288/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/01/bubble-sort-vs-merge-sort.html#comment-form" title="1 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/7276307326588318288?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/7276307326588318288?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/8687EwodyRc/bubble-sort-vs-merge-sort.html" title="Bubble Sort vs Merge Sort" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-_nT8LofOPnw/TwGE4RFpHOI/AAAAAAAAAFQ/Bd6IByj-gT0/s72-c/Bubble-sort-example-300px.gif" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/01/bubble-sort-vs-merge-sort.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcNQH4zeip7ImA9WhRWGE0.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-4935522731522518365</id><published>2012-01-05T21:00:00.000+01:00</published><updated>2012-01-05T22:48:11.082+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-05T22:48:11.082+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Network" /><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Fondamenti" /><title>Internet - Un pò di storia</title><content type="html">Internet, personalmente, è l'invenzione più geniale di sempre perché ha permesso all'uomo di immagazzinare tutta la propria conoscenza al servizio di tutti. Inoltre, Internet ha eliminato distanze e tempi rendendo il concetto di globalizzazione realizzabile. Ma cos'è Internet? E com'è nato?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Definizione di Internet&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
Internet è un sistema globale di reti di calcolatori interconnessi fra di loro tramite la suite di protocolli TCP/IP. Il TCP e l'IP costituiscono il "linguaggio comune" utilizzato fra i computer connessi a Internet (&lt;b&gt;host&lt;/b&gt;). L'Internet contiene una quantità inimmaginabile di informazioni e servizi: come i documenti del &lt;b&gt;W&lt;/b&gt;orld &lt;b&gt;W&lt;/b&gt;ide &lt;b&gt;W&lt;/b&gt;eb (pagine web) o le infrastrutture che supportano i servizi di email.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Un pò di storia&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Il concetto di "interazioni sociali" attraverso una rete risale al Agosto 1962 da parte di J. C. R. Licklider e prendeva il nome di "Rete Galattica". L'idea si basava su un insieme di computer interconnessi globalmente a cui ognuno poteva avere accesso.&amp;nbsp;Licklider era a capo della &lt;a href="http://it.wikipedia.org/wiki/Defense_Advanced_Research_Projects_Agency" target="_blank"&gt;DARPA&lt;/a&gt;. Nel 1966 Lawrence G. Roberts, un ricercatore del MIT, propose all'agenzia DARPA il concetto proposto anni prima da Licklider su una rete di computer. Ebbe inizio il progetto: &lt;a href="http://it.wikipedia.org/wiki/ARPANET" target="_blank"&gt;ARPANET&lt;/a&gt;, pubblicato nel 1967. Il progetto ARPANET nasceva come una rete di computer a scopo militare in grado di resistere agli attacchi nemici (l'epoca in questione è quella della guerra fredda). Se un host sarebbe stato distrutto dal nemico la rete ARPANET, infatti, garantiva l'operabilità fra il resto degli host.&lt;br /&gt;
&lt;br /&gt;
Nel 1969, il progetto entrò nella sua fase sperimentale e l'Università della California, Los Angeles (UCLA) divenne il primo host di ARPANET. Entrò la fine dello stesso anno altre tre università di attaccarono alla rete: Standford, Santa Barbara e Utah.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 1.167em; line-height: 17px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;


&lt;/h3&gt;
&lt;div&gt;
Negli anni successivi molti altri host si attaccarono alla rete e tra il 1971 e il 1972 gli utenti della rete poterono iniziare a sviluppare le loro prime applicazioni da usare oltre la rete.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 17px; padding-bottom: 1.1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;
&lt;span style="font-family: inherit;"&gt;Nel 1982 fu coniata la parola Internet e TCP/IP per il corrispettivo protocollo. Inoltre, presero strada le seguenti quattro idee:&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; padding-bottom: 1.1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; vertical-align: top;"&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="line-height: 17px;"&gt;Ogni rete deve essere indipendente e deve essere in grado di collegarsi alla rete globale: Internet&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="line-height: 17px;"&gt;Le comunicazioni devono cercare di essere efficienti e affidabili: un pacchetto dati viene ritrasmesso se non è stato ricevuto da un destinatario entro un certo lasso di tempo&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="line-height: 17px;"&gt;L'uso di ponti nella comunicazione che si basino sull'idea della scatola nera, dove il contenuto delle informazioni è sconosciuto&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="line-height: 17px;"&gt;Nessun controllo globale al livello operazionale&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style="line-height: 17px;"&gt;Già nel 1985, Internet era una struttura stabile e usata a livello internazionale da ricercatori e programmatori e iniziava ad essere usata per comunicare tramite e-mail.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="line-height: 17px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="line-height: 17px;"&gt;Tuttavia, fu solo tra il 1989 e il 1990 che Internet conobbè il suo boom. Tim Berners-Lee, un ricercatore del Conseil Européenne pour la Recherche Nucleaire (CERN), a Ginevra (Svizzera), sviluppò il concetto di HyperText e World Wide Web. Da allora il numero di utenti crebbe vertiginosamente fino all'Internet che conosciamo oggi: in moltissimi dispositivi elettronici di uso comune e con tantissime applicazioni: motori di ricerca, social networks, blogs, etc...&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Mappa di Internet &lt;/b&gt;(2005)&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-akAT-6Ww9eU/TwWXHM1Jg0I/AAAAAAAAAG8/2HyR58tleV8/s1600/ascoreApr2005.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;span style="color: black;"&gt;&lt;img border="0" height="500" src="http://2.bp.blogspot.com/-akAT-6Ww9eU/TwWXHM1Jg0I/AAAAAAAAAG8/2HyR58tleV8/s640/ascoreApr2005.png" width="640" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;div style="font-size: medium; text-align: -webkit-auto;"&gt;
&lt;i&gt;fonte:&amp;nbsp;http://www.caida.org/research/topology/as_core_network/pics/ascoreApr2005.png&lt;/i&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;Date principali della storia di Internet&lt;/b&gt; (da it.wikipedia.org)&lt;br /&gt;
&lt;ul style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px; list-style-image: url(data:image/png; list-style-type: square; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.3em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1960: Avvio delle ricerche di&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Defense_Advanced_Research_Projects_Agency" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Defense Advanced Research Projects Agency"&gt;ARPA&lt;/a&gt;, progetto del&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Dipartimento_della_Difesa_degli_Stati_Uniti" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Dipartimento della Difesa degli Stati Uniti"&gt;Ministero della Difesa degli Stati Uniti&lt;/a&gt;&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1967: Prima conferenza internazionale sulla rete&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/ARPANET" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="ARPANET"&gt;ARPANET&lt;/a&gt;&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1969: Collegamento dei primi computer tra 4 università americane&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1971: La rete ARPANET connette tra loro 23 computer&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1972: Nascita dell'InterNetworking Working Group, organismo incaricato della gestione di Internet.&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Ray_Tomlinson" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Ray Tomlinson"&gt;Ray Tomlinson&lt;/a&gt;&amp;nbsp;propone l'utilizzo del segno @ per separare il nome utente da quello della macchina.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1973: La&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Gran_Bretagna" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Gran Bretagna"&gt;Gran Bretagna&lt;/a&gt;&amp;nbsp;e la&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Norvegia" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Norvegia"&gt;Norvegia&lt;/a&gt;&amp;nbsp;si uniscono alla rete con un computer ciascuna.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1979: Creazione dei primi&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Newsgroup" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Newsgroup"&gt;Newsgroup&lt;/a&gt;&amp;nbsp;(forum di discussione) da parte di studenti americani&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1981: Nasce in Francia la rete Minitel. In breve tempo diventa la più grande rete di computer al di fuori degli USA&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1982: Definizione del protocollo&amp;nbsp;&lt;a class="mw-redirect" href="http://it.wikipedia.org/wiki/TCP/IP" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="TCP/IP"&gt;TCP/IP&lt;/a&gt;&amp;nbsp;e della parola "&lt;a href="http://it.wikipedia.org/wiki/Internet" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Internet"&gt;Internet&lt;/a&gt;"&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1983: Appaiono i primi server dei nomi dei siti&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1984: La rete conta ormai mille computer collegati&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1985: Sono assegnati i domini nazionali: .it per l'Italia, .de per la Germania, .fr per la Francia, ecc.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1986: Viene lanciato&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/LISTSERV" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="LISTSERV"&gt;LISTSERV&lt;/a&gt;, il primo software per la gestione di una&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Mailing_list" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Mailing list"&gt;mailing list&lt;/a&gt;. In aprile, da&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Pisa" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Pisa"&gt;Pisa&lt;/a&gt;, sede del Centro Nazionale Universitario di Calcolo Elettronico (Cnuce) viene realizzata la prima connessione Internet dall'Italia con gli Stati Uniti.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1987: Sono connessi 10&amp;nbsp;000 computer. Il&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/23_dicembre" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="23 dicembre"&gt;23 dicembre&lt;/a&gt;&amp;nbsp;viene registrato “cnr.it”, il primo dominio con la denominazione geografica dell'Italia; è il sito del&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Consiglio_Nazionale_delle_Ricerche" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Consiglio Nazionale delle Ricerche"&gt;Consiglio Nazionale delle Ricerche&lt;/a&gt;.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1989: Sono connessi 100mila computer&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1990: Scomparsa di ARPANET; apparizione del linguaggio HTML&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1991: Il CERN (Centro Europeo di Ricerca Nucleare) annuncia la nascita del World Wide Web&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1992: Un milione di computer sono connessi alla rete&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1993: Apparizione del primo&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Browser" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Browser"&gt;browser&lt;/a&gt;&amp;nbsp;pensato per il web,&amp;nbsp;&lt;a href="http://it.wikipedia.org/wiki/Mosaic" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; text-decoration: none;" title="Mosaic"&gt;Mosaic&lt;/a&gt;&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1996: Sono connessi 10 milioni di computer&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;1999: Gli utenti di Internet sono 200 milioni in tutto il mondo&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;2008: Gli utenti di Internet sono circa 600 milioni in tutto il mondo&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;2009: Gli utenti di Internet sono circa 1 miliardo in tutto il mondo&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;2011: Gli utenti di Internet sono circa 2 miliardi in tutto il mondo&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;Video&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
Breve storia di Internet, con Stefano Quintarelli&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://2.gvt0.com/vi/TSxW0yJxYKI/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/TSxW0yJxYKI&amp;fs=1&amp;source=uds" /&gt;





&lt;param name="bgcolor" value="#FFFFFF" /&gt;





&lt;embed width="320" height="266"  src="http://www.youtube.com/v/TSxW0yJxYKI&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
La storia di Internet [English]&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://1.gvt0.com/vi/URieXGX4TME/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/URieXGX4TME&amp;fs=1&amp;source=uds" /&gt;





&lt;param name="bgcolor" value="#FFFFFF" /&gt;





&lt;embed width="320" height="266"  src="http://www.youtube.com/v/URieXGX4TME&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Fonti e ulteriori informazioni:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
http://www.internetsociety.org/internet/internet-51/history-internet/brief-history-internet&lt;br /&gt;
http://it.wikipedia.org/wiki/Storia_di_Internet&lt;br /&gt;
http://www.pinzani.it/storia-internet.php&lt;br /&gt;
http://youtube.com&lt;br /&gt;
http://gandalf.it/dati/dati1.htm&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/cC84o5pUV2A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/4935522731522518365/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/01/internet-un-po-di-storia.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4935522731522518365?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/4935522731522518365?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/cC84o5pUV2A/internet-un-po-di-storia.html" title="Internet - Un pò di storia" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-akAT-6Ww9eU/TwWXHM1Jg0I/AAAAAAAAAG8/2HyR58tleV8/s72-c/ascoreApr2005.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/01/internet-un-po-di-storia.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UER3c-fyp7ImA9WhRWFUk.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-5509640035311994643</id><published>2012-01-03T00:00:00.000+01:00</published><updated>2012-01-03T00:00:06.957+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-03T00:00:06.957+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Network" /><category scheme="http://www.blogger.com/atom/ns#" term="HTTP" /><category scheme="http://www.blogger.com/atom/ns#" term="Python" /><title>Python - Richieste GET e POST su HTTP</title><content type="html">&lt;div style="text-align: justify;"&gt;
L'HTTP (&lt;b&gt;H&lt;/b&gt;yper&lt;b&gt;T&lt;/b&gt;ext &lt;b&gt;T&lt;/b&gt;ransfer &lt;b&gt;P&lt;/b&gt;rotocol) è il protocollo principale al Livello Applicazioni (i livelli sono quattro: Applicazioni, Trasporto, Internetworking, Collegamento) usato per la trasmissione di informazioni sul web. Generalmente, un Server HTTP utilizza il protocollo &lt;b&gt;TCP&lt;/b&gt; (Transmission &amp;nbsp;Control Protocol) sulla porta &lt;b&gt;80&lt;/b&gt;.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
L'HTTP si basa su un meccanismo: richiesta/risposta (client/server). Il client esegue una richiesta e il server restituisce la risposta. E' importante tenere in mente che una applicazione può agire sia da client che da server. &amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Se la nostra applicazione sta effettuando, per esempio, il login ad un sito allora è buon uso utilizzare un &lt;a href="http://it.wikipedia.org/wiki/Cookie" target="_blank"&gt;cookie&lt;/a&gt; per salvare le impostazioni di login.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
I metodi HTTP (versione 1.1) sono i seguenti, ma noi analizzeremmo solo i primi due:&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;GET&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;POST&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;HEAD&lt;/li&gt;
&lt;li&gt;PUT&lt;/li&gt;
&lt;li&gt;DELETE&lt;/li&gt;
&lt;li&gt;TRACE&lt;/li&gt;
&lt;li&gt;OPTIONS&lt;/li&gt;
&lt;li&gt;CONNECT&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
In Python è possibile utilizzare il codice qui sotto per effettuare delle richieste HTTP.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Codice in Python&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1"&gt;
    &lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;"""Questa classe effettua delle richieste HTTP"""&lt;br /&gt;
import urllib&lt;br /&gt;
import urllib2&lt;br /&gt;
import cookielib&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;#Inizializza il cookie&lt;/span&gt;&lt;br /&gt;
cookie = None&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# Effettua una richiesta HTTP dati i seguenti:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# 1: metodo: GET o POST&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# 2: sito, per esempio: www.blogger.com&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# 3: url_api, per esempio: api/comment&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# 4: **parametri: argomenti aggiuntivi per la richiesta&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #38761d;"&gt;# per esempio: modhash, title, id, etc..&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
def effettua_una_richiesta_HTTP (metodo, sito,&amp;nbsp;url_api, **&amp;nbsp;parametri):&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# cookie diventa globale così da essere usato all'interno di questo metodo&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; global cookie&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style="color: #38761d;"&gt; # Se il cookie non è presente allora crearlo.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if cookie == None:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Crea il cookie per salvare cookie HTTP.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cookie = cookielib.CookieJar()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Gestisce i cookie.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; http_cookie = urllib2.HTTPCookieProcessor(cookie)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; opener = urllib2.build_opener(http_cookie)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Apre l'url così che urlopen usa l'opener.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; urllib2.install_opener(opener)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color: #6aa84f;"&gt;# Se dei parametri sono stati passati alla funzione&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; # allora convertirli in formato url&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if&amp;nbsp;parametri&amp;nbsp;!= None:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; postdata = urllib.urlencode(parametri)&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;span style="color: #38761d;"&gt;&amp;nbsp; #Se il metodo è GET allora creare un link appropriato per la richiesta HTTP.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if metodo == "GET":&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;url_api&amp;nbsp;+= "?"&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="color: #38761d;"&gt; # Aggiunge i parametri al link.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for key in parameters:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;url_api&amp;nbsp;= (url_api&amp;nbsp;+&lt;br /&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;key + "=" +&lt;br /&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;parametri[key] + "&amp;amp;")&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;parametri&amp;nbsp;= None&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Effettua la richiesta.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; richiesta = urllib2.Request(sito +&amp;nbsp;url_api, parametri)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; risposta = urllib2.urlopen(richiesta)&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color: #38761d;"&gt;# Estrae i cookie e li muove nella variabile cookie.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cookie.extract_cookies(risposta,&amp;nbsp;richiesta)&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style="color: #38761d;"&gt; # La risposta dal sito viene restituita dalla funzione.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return risposta&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;
      

&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;Tale funzione può essere usata come di seguito:&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;GET&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
risposta = &amp;nbsp;effettua_una_richiesta_HTTP("GET",&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url_sito,&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url_home_page)&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;POST&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
risposta =&amp;nbsp;effettua_una_richiesta_HTTP("POST",&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url_sito,&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url_login,&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; user = username,&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; passwd = password,&amp;nbsp;&lt;/div&gt;
&lt;div&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; api_type = "json")&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #990000;"&gt;Nota&lt;/span&gt;: consultare sempre l'API di un sito per accertarsi che la richiesta viene effettuata correttamente.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
La risposta ottenuta contiene tre parti:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Riga di stato&lt;/li&gt;
&lt;li&gt;Header&lt;/li&gt;
&lt;li&gt;Body&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
La riga di stato consiste in un codice di tre cifre:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;1xx : Messaggi informativi&lt;/li&gt;
&lt;li&gt;2xx : La richiesta è stata effettuata con successo&lt;/li&gt;
&lt;li&gt;3xx : Non c'è risposta immediata, ma la richiesta è sensata&lt;/li&gt;
&lt;li&gt;4xx : La richiesta non può essere effettuata perché errata&lt;/li&gt;
&lt;li&gt;5xx : La richiesta non può essere effettuata per un errore nel server.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Per un elenco più dettagliato cliccare &lt;a href="http://it.wikipedia.org/wiki/Elenco_dei_codici_di_stato_HTTP" target="_blank"&gt;qui&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Gli header più comuni sono due:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Server: indica tipo e versione del server&lt;/li&gt;
&lt;li&gt;Content-Type: indica il tipo di contenuto resistuito. Alcuni fra questi:&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;text/html&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;text/plain&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;text/xml&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;image/jpeg&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Il body contiene il contenuto della risposta.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Fonti&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
https://github.com/gehsekky/reddit-scripts/blob/master/reddit_friend_sync.py&lt;br /&gt;
http://it.wikipedia.org&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/BFSZjSvGLLw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/5509640035311994643/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2012/01/python-richieste-get-e-post-su-http.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5509640035311994643?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/5509640035311994643?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/BFSZjSvGLLw/python-richieste-get-e-post-su-http.html" title="Python - Richieste GET e POST su HTTP" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2012/01/python-richieste-get-e-post-su-http.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAMSHY6eip7ImA9WhRWE08.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-3915978214648717720</id><published>2011-12-31T11:30:00.000+01:00</published><updated>2011-12-31T11:36:29.812+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-31T11:36:29.812+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Virus" /><title>Virus - Trojan.Win32.FakeGdF.</title><content type="html">Qualche giorno fa mi sono imbattuto in un computer infettato da un virus che blocca il computer e visualizza una pagine della Guardia di Finanza con il seguente indirizzo URL: http://78.47.58.6 .&lt;br /&gt;
Analizziamo un pò questo virus e scopriamo come eliminarlo.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Descrizione&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Il Trojan.Win32.FakeGdF.&amp;lt;A-R&amp;gt; (Versioni attualmente identificate dalla A alla R) è un malware che blocca completamente il computer collegandosi ad un sito in Russia. Il sito in questione si spaccia per quello della Guardia di Finanza e appare come il seguente:&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/-EhJoGFCXDUE/Tv2mD-h4jxI/AAAAAAAAAFE/1lsD7-J44F8/s1600/virus_finanza.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="245" src="http://3.bp.blogspot.com/-EhJoGFCXDUE/Tv2mD-h4jxI/AAAAAAAAAFE/1lsD7-J44F8/s400/virus_finanza.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Il sito appare a tutto schermo non permettendo all'utente alcuna interazione con il sistema operativo. La barra di navigazione del browser scompare e l'unica operazione disponibile è inserire i codici pin di &lt;a href="http://en.wikipedia.org/wiki/Ukash" target="_blank"&gt;Ukash&lt;/a&gt; o &lt;a href="http://en.wikipedia.org/wiki/PaySafe" target="_blank"&gt;Paysafe&lt;/a&gt;.&lt;br /&gt;
Il sito, in pratica, avverte l'utente che al vostro indirizzo IP sono ricollegate operazioni illecite:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;atti di terrorismo&lt;/li&gt;
&lt;li&gt;download di pornografia minorile&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Per ripristinare il computer al suo stato precedente, quindi, viene chiesto di pagare 100 euro tramite Ukash o PaysafeCard.&lt;br /&gt;
La multa è solo un pretesto per rubare soldi all'utente!!! In realtà, infatti, è il virus&amp;nbsp;Trojan.Win32.FakeGdF.&amp;lt;A-R&amp;gt; che blocca il computer sotto il falso nome:&amp;nbsp;&lt;span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; text-align: -webkit-left;"&gt;WPBT0.DLL &lt;/span&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;&lt;span style="font-family: inherit;"&gt;nella cartella: &amp;lt;user&amp;gt; / IMPOSTAZIONI LOCALI / TEMP /&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; text-align: -webkit-left;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1" cellpadding="1" cellspacing="1" style="background-color: white; color: black; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; width: 590px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Nome file:&lt;/td&gt;&lt;td&gt;WPBT0.DLL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;dimensione:&lt;/td&gt;&lt;td&gt;174592 byte&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;MD5&lt;/td&gt;&lt;td&gt;37f939b59edce18204f3db1fc18e79ff&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;File compresso:&lt;/td&gt;&lt;td&gt;UPX&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Time Stamp del file:&lt;/td&gt;&lt;td&gt;17/07/2011 21.58.49&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Esecuzione automatica:&lt;/td&gt;&lt;td&gt;dal menu Avvio (%user%\Menu Avvio\Programmi\Esecuzione automatica\wpbt0.dll.lnk&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Del virus ne esistono diverse versioni che agiscono in modi alquanto analoghi.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Versioni:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;strong&gt;&lt;span style="background-color: white; font-family: arial; font-size: x-small; text-align: -webkit-left;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;table border="1" bordercolor="#000000" cellspacing="1" dir="ltr" style="background-color: white; color: black; font-family: arial; font-size: small; font-weight: 800; width: 590px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;b&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;Nome&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;b&gt;&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Dimensione&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;b&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;MD5&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;b&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;Sito ip&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;b&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;Time stamp&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.A&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;174592&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;37f939b59edce18204f3db1fc18e79ff&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;83.69.236.38&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;17/07/2011 21.58.49&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.B&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;203264&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;1d10fb2bb8fac1122e2452975acfb701&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;31.31.200.105&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/12/2011 09.35.29&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.C&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;203264&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;58bca204698ff459697e6c1d9b8a5519&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;31.31.200.105&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/12/2011 15.34.14&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.D&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;180736&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;ef9b87a2780047307ac6c7280dc5feff&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;78.47.58.6&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;12/01/2011 09.08.08&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.E&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;194048&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;d0d0b5b6023d7534e05e44d18e7e11e1&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;78.47.58.6&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;15/12/2011 16.21.14&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.F&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;203776&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;78900f3e233ac18e29795bf0381526c9&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;85.17.168.194&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;11/12/2011 20.43.32&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.G&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;182272&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;750d4b7b1b0278b34f3afe15d81df559&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;46.161.31.157&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;26/06/2011 08.22.02&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.H&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;171008&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;b9a08f4e586f278e2c3420676bcde367&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/03/2011 10.04.03&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.I&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;193024&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;ec31d1eef414fefa17fef71573dd62f1&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;09/04/2011 13.07.01&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.J&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;179200&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;76376367a43a2ac4e718ca6fc8932648&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;83.69.236.38&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/05/2011 11.16.59&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.K&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;184320&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;3f657024d7a7e9da7215df7f87982df6&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;85.17.168.194&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;26/03/2011 08.38.56&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.L&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;165376&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;4b6de49e05c9c27892f465ac663b387f&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;28/02/2011 05.29.55&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.M&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;185344&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;26caa122cc0d01f788af005ea0135d08&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/03/2011 07.02.45&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.N&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;185856&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;d3b6c37e2de28822aae217b5e8b85d68&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;62.76.190.68&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;14/06/2011 09.30.20&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.O&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;204288&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;102ac369ffb35df07fb0ead427e45955&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;78.47.15.197&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;15/07/2011 02.33.58&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.P&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;195584&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;fc6042028b7b552cb2b2b09e8a28e550&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;78.47.15.197&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;27/04/2011 01.43.55&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.Q&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;190464&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;73e8702fcb76dfb5dbf1a6ba48ef8325&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;16/02/2011 19.34.00&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="font-size: 12px;" valign="top" width="25%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;Trojan.Win32.FakeGdF.R&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="12%"&gt;&lt;div align="center" style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;199680&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="31%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;def27a897bff7e75155e7255083f868f&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="15%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;64.120.143.226&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style="font-size: 12px;" valign="top" width="17%"&gt;&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;28/02/2011 16.06.38&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span lang="JA" style="font-family: Arial; font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;La cura&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Riavviare il computer in modalità provvisoria (premere F8 prima che Windows parta)&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Per la versione &lt;b&gt;A&lt;/b&gt;:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Cancellare il file:&lt;i&gt; &amp;lt;user&amp;gt; / Menu Avvio / Programmi / Esecuzione Automatica /&lt;span style="font-family: inherit;"&gt;&amp;nbsp;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;wpbt0.dll.lnk&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;Cancellare il file:&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;&lt;i&gt;&amp;lt;user&amp;gt; / IMPOSTAZIONI LOCALI / TEMP / WPBT0.DLL&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;
Per le altre versioni:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Cancellare il file: &lt;i&gt;&amp;lt;user&amp;gt; / Menu Avvio / Programmi / Esecuzione Automatica /&lt;span style="font-family: inherit;"&gt;&amp;nbsp;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;0.[numero casuale].exe.lnk&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;Cancellare il file:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;&amp;lt;user&amp;gt; / IMPOSTAZIONI LOCALI / TEMP /&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; text-align: -webkit-left;"&gt;0.[numero casuale].exe&lt;/span&gt;&lt;/i&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: -webkit-left;"&gt;
Dove &amp;lt;user&amp;gt; si trova nelle seguenti directory:&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: -webkit-left;"&gt;
&lt;ul&gt;
&lt;li&gt;Windows 2000 / XP / Server 2003:&lt;span style="font-family: inherit;"&gt;&amp;nbsp;&lt;i&gt;&lt;span lang="JA" style="background-color: white;"&gt;c:\documents and settings\&amp;lt;nome utente&amp;gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Windows Vista / 7 / Server 2008:&lt;i&gt;&amp;nbsp;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: white;"&gt;c:\users\&lt;/span&gt;&lt;span style="background-color: white;"&gt;&amp;lt;nome utente&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
Se file e cartelli non sono presenti nel vostro computer rendere file e cartelle nascoste visibili (premere &lt;a href="http://www.kkaio.com/articoli/visualizzare-file-e-cartelle-nascosti.shtm" target="_blank"&gt;qui&lt;/a&gt; per scoprire come).&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: x-small;"&gt;Fonte:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: arial; text-align: -webkit-left;"&gt;&lt;strong&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;div style="font-weight: normal; margin-bottom: 7px; margin-top: 7px; text-align: justify;"&gt;
&lt;strong style="background-color: white; font-family: arial; text-align: -webkit-left;"&gt;&lt;strong&gt;&lt;span lang="JA" style="font-family: Arial; font-size: x-small;"&gt;&lt;b&gt;&lt;u&gt;C.R.A.M. by TG Soft www.tgsoft.it&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/7M8NQCRUxgg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/3915978214648717720/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2011/12/virus-trojanwin32fakegdf.html#comment-form" title="1 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3915978214648717720?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3915978214648717720?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/7M8NQCRUxgg/virus-trojanwin32fakegdf.html" title="Virus - Trojan.Win32.FakeGdF.&lt;A-R&gt;" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-EhJoGFCXDUE/Tv2mD-h4jxI/AAAAAAAAAFE/1lsD7-J44F8/s72-c/virus_finanza.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2011/12/virus-trojanwin32fakegdf.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQFQ3w_fSp7ImA9WhRWEkk.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-3099921141319906411</id><published>2011-12-30T00:30:00.000+01:00</published><updated>2011-12-30T12:08:32.245+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-30T12:08:32.245+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Pattern" /><title>Abstract Factory</title><content type="html">&lt;br /&gt;
&lt;div class="p1"&gt;
&lt;div style="text-align: justify;"&gt;
L'Abstract Factory è uno dei design pattern base descritti nel famoso libro&lt;i&gt; Design Patterns: Elements of Reusable Object-Oriented Software&lt;/i&gt; (1994).&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
L'uso dell'Abstract Factory è utile per creare famiglie di oggetti (connessi o dipendenti per loro) in modo tale che la classe che li implementa non deve specificare la classe dell'oggetto esplicitamente.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In tal modo un software si può suddividere in due parti: la parte concreta e la parte client. La prima implementa il "cuore" del software, mentre la seconda si appoggia alla prima. Ad esempio, la parte client potrebbe essere una suite di JUnit Tests e usando la tecnica dell'Abstract Factory è possibile utilizzare la stessa suite per testare diverse implementazioni del software.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Il diagramma seguente è la rappresentazione logica dell'Abstract Factory Pattern.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-YoPsiWgr9yc/Tv2VdCJzS9I/AAAAAAAAAE4/ywxOwxePcvs/s1600/factory.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="228" src="http://3.bp.blogspot.com/-YoPsiWgr9yc/Tv2VdCJzS9I/AAAAAAAAAE4/ywxOwxePcvs/s400/factory.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
Ecco alcuni punti principali presi da wikipedia e che ritengo abbastanza validi:&lt;/div&gt;
&lt;ul style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px; list-style-image: url(data:image/png; list-style-type: square; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.3em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;si vuole un sistema indipendente da come gli oggetti vengono creati, composti e rappresentati&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;si vuole permettere la configurazione del sistema come scelta tra diverse famiglie di prodotti&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;si vuole che i prodotti che sono organizzati in famiglie siano vincolati ad essere utilizzati con prodotti della stessa famiglia&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;si vuole fornire una libreria di classi mostrando solo le interfacce e nascondendo le implementazioni.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;Di seguito porto un esempio di come si possa usare questa tecnica in Java.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;b&gt;Nota&lt;/b&gt;: consiglio vivamente di mettere le interfacce in un package "Interfacce" e le classi concrete in un package "Implementazione".&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;Per prima cosa iniziamo con le interfaccia, così ci si rende già conto di cosa devono fare le classi concrete.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;b&gt;Interfaccia Fattoria&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="p1"&gt;
&lt;span style="font-family: inherit;"&gt;public&lt;span class="s1"&gt; &lt;/span&gt;interface&lt;span class="s1"&gt; IFattoria {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p2"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; IProdotto creaProdotto();&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;b&gt;Interfaccia Prodotto&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;public interface IProdotto {&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp;&lt;span style="color: #38761d;"&gt; // I metodi del prodotto (no costruttore come di regola).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="p4"&gt;
&lt;span style="font-family: inherit;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;Osservando le due interfacce qui sopra ci rendiamo conto che è la fattoria il cuore di questa tecnica (come ci si aspettava dal nome, dopotutto).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="line-height: 19px;"&gt;&lt;b&gt;&lt;span style="font-family: inherit;"&gt;Fattoria&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="p1"&gt;
&lt;span class="s1"&gt;public&lt;/span&gt; &lt;span class="s1"&gt;class&lt;/span&gt; Fattoria&amp;nbsp;&lt;span class="s1"&gt;implements&lt;/span&gt; IFattoria {&lt;/div&gt;
&lt;div class="p2"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="p3"&gt;
&lt;span class="s2"&gt;&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #999999;"&gt;@Override&lt;/span&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&lt;span class="s1"&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt; IProdotto creaProdotto() {&lt;/div&gt;
&lt;div class="p1"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="color: #38761d;"&gt; // Crea il prodotto dal suo costruttore.&lt;/span&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&lt;span class="s1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt; &lt;span class="s1"&gt;new&lt;/span&gt; Prodotto();&lt;/div&gt;
&lt;div class="p1"&gt;
&lt;span class="Apple-tab-span"&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class="p2"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="p1"&gt;
}&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/YmSghF3juMw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/3099921141319906411/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2011/12/abstract-factory.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3099921141319906411?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/3099921141319906411?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/YmSghF3juMw/abstract-factory.html" title="Abstract Factory" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-YoPsiWgr9yc/Tv2VdCJzS9I/AAAAAAAAAE4/ywxOwxePcvs/s72-c/factory.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2011/12/abstract-factory.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MHRnY-eCp7ImA9WhVQFUg.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-6190617162372419743</id><published>2011-12-02T21:30:00.001+01:00</published><updated>2012-04-04T18:03:57.850+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-04T18:03:57.850+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mac OS X" /><title>Mac OS X- Disabilitazione Screensaver come Desktop</title><content type="html">&lt;div style="text-align: justify;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 14px;"&gt;Ciao!&lt;/span&gt;&lt;/div&gt;
&lt;div class="kmsgbody" style="display: table; line-height: 14px; margin-top: 5px; min-height: 180px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 10px; table-layout: fixed; text-align: justify; width: 650px;"&gt;
&lt;div class="kmsgtext" style="font-size: 1em; word-wrap: break-word;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="kmsgtext" style="font-size: 1em; word-wrap: break-word;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;Lo so che è da tanto che non scrivo ma sono stato e sono molto impegnato in questo periodo. Mi concedo comunque il tempo di scrivere questo articoletto oggi.&lt;/span&gt;&lt;/div&gt;
&lt;div class="kmsgtext" style="font-size: 1em; word-wrap: break-word;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="kmsgtext" style="font-size: 1em; word-wrap: break-word;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;Finalmente, infatti, ho risolto un problema molto discusso per i fan Mac ma irrisolto. Perlomeno io ho cercato per un anno in tutti i siti in inglese e in italiano una soluzione ma nessuna funzionava.&lt;br /&gt;&lt;br /&gt;Come ben sappiamo i Mac hanno un terminale e si possono fare tante cose carine. Una di queste è impostare uno screensaver come desktop usando questo comando:&lt;br /&gt;&lt;i&gt;&lt;br /&gt;/System/Library/Frameworks/ScreenSaver.framework/Resources/&lt;br /&gt;ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; font-size: small;"&gt;&lt;i style="background-color: white;"&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: small;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;Tuttavia se si chiude il terminale l'effetto svanisce. La soluzione per averlo sempre lì quindi è mettere l'ampersand alla fine:&lt;br /&gt;&lt;i&gt;&lt;br /&gt;/System/Library/Frameworks/ScreenSaver.framework/Resources/&lt;br /&gt;ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &amp;amp;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Ma come fermarlo? Premendo&amp;nbsp;&lt;i&gt;Control+C&lt;/i&gt;&amp;nbsp;....questo è quello che suggerivano in molti: ma nada de nada..&lt;br /&gt;L'unica soluzione era uccidere il processo:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Killall -9 ScreenSaverEngine&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Ma poi ho scoperto che ogni volta che aprivo il mio terminale mi spuntava questa cosa...e mi consumava tutta la CPU! che rottura eseguire sempre il comando&amp;nbsp;&lt;i&gt;Killall -9 ScreenSaverEngine&lt;/i&gt;&amp;nbsp;ogni volta che aprivo il terminale.&lt;br /&gt;&lt;br /&gt;Ci ho sbattuto la testa per un anno per capire dove stava il problema...suggerimenti assurdi da tanti forum, ma nessuno funzionante..&lt;br /&gt;&lt;br /&gt;Ma oggi..per caso ho risolto tutto! Viva la serendipità :)&lt;br /&gt;&lt;br /&gt;Ecco come fare dal terminale:&lt;br /&gt;&lt;br /&gt;Andare alla home directory:&lt;br /&gt;&lt;b&gt;cd ~&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Visualizzare tutti gli elementi (anche quelli nascosti):&lt;br /&gt;l&lt;b&gt;s -a&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Aprire il file del profilo:&lt;br /&gt;&lt;b&gt;open .profile&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;oppure&lt;br /&gt;&lt;b&gt;open .bash_profile&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Ed ecco fatto....troverete nelle prime linee del documento questo:&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;strike&gt;/System/Library/Frameworks/ScreenSaver.framework/Resources/&lt;br /&gt;ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &amp;amp;&lt;/strike&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Toglietelo, eliminatelo, bruciatelo....e godetevi nuovamente il vostro stupendo terminale con serenità...&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/SEsFC3hJbz8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/6190617162372419743/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2011/12/mac-disabilitazione-screensaver-come.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6190617162372419743?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/6190617162372419743?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/SEsFC3hJbz8/mac-disabilitazione-screensaver-come.html" title="Mac OS X- Disabilitazione Screensaver come Desktop" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2011/12/mac-disabilitazione-screensaver-come.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08CSX8zeyp7ImA9WhRRFE8.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-627810016153573464</id><published>2011-11-27T20:30:00.000+01:00</published><updated>2011-11-27T21:31:08.183+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-27T21:31:08.183+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Curiosità" /><category scheme="http://www.blogger.com/atom/ns#" term="Python" /><title>Python - Generare l'Insieme di Mandelbrot</title><content type="html">L'insieme (o frattale) di Mandelbrot (1975) è uno dei frattali più famosi. Un frattale è un oggetto geometrico che si ripete nella propria struttura su scale diverse. I frattali sono molto comuni in natura e un esempio ne è la costa della Gran Bretagna.&lt;br /&gt;
&lt;br /&gt;
L'insieme di Mandelbrot è definito per i numeri complessi &lt;b&gt;c&lt;/b&gt; per i quali la seguente successione è vera e limitata:&lt;br /&gt;
&lt;br /&gt;
Z(n + 1) = Z(n) ^ 2 + &lt;b&gt;c &lt;/b&gt;, Z(0) = 0&lt;br /&gt;
&lt;br /&gt;
Per informazioni più dettagliate clicca &lt;a href="http://it.wikipedia.org/wiki/Insieme_di_Mandelbrot" target="_blank"&gt;qui&lt;/a&gt;.&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/-bQ0-8UVe4tQ/TtIyN-zBobI/AAAAAAAAAEc/vNCuM2RGpcU/s1600/300px-Mandel_zoom_00_mandelbrot_set.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-bQ0-8UVe4tQ/TtIyN-zBobI/AAAAAAAAAEc/vNCuM2RGpcU/s1600/300px-Mandel_zoom_00_mandelbrot_set.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
L'insieme prende il nome dal suo creatore: Ben&lt;span style="background-color: white; line-height: 19px;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;oît&lt;/span&gt;&lt;/span&gt;&amp;nbsp;Mandelbrot, famoso matematico polacco per aver reso i frattali celebri. Tuttavia si seppe dare una forma o una rappresentazione grafica all'insieme di Mandelbrot solo grazie all'aiuto dell'informatica.&lt;br /&gt;
&lt;br /&gt;
Nel 1985 fu pubblicato sulla rivista Scientific American il primo algoritmo per calcolare l'insieme di Mandelbrot.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;L'algoritmo&lt;/b&gt; (per ogni punto C):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Z ha valore iniziale 0;&lt;/li&gt;
&lt;li&gt;Scegliere C come il punto corrente. C è un numero complesso, quindi C = Parte Reale + Parte Immaginaria. Nel piano cartesiano l'asse delle ascisse (retta orizzontale) rappresenta la parte reale, mentre l'asse delle ordinate (retta verticale) rappresenta la parte immaginaria di C;&lt;/li&gt;
&lt;li&gt;Iterazione = Z = Z^2 + C;&lt;/li&gt;
&lt;li&gt;Fermarsi quando Z^2 è più grande del raggio massimo;&lt;/li&gt;
&lt;li&gt;Count = numero di iterazioni prima di superare il raggio massimo;&lt;/li&gt;
&lt;li&gt;Colore = dipende dal valore di Count.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Di seguito vi invito a provare questo generatore di Mandelbrot.&lt;br /&gt;
L'esecuzione di questo programma è molto lenta e può impiegare vari minuti per generare un immagine discreta dell'insieme. L'immagine verrà salvata come M.bmp sulla directory in cui state eseguendo il programma.&lt;br /&gt;
Vi propongo questa versione per tre motivi:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;E' molto corta;&lt;/li&gt;
&lt;li&gt;E' offuscata: cosa molto rara in Python dove l'indendatione e gli spazi sono significativi;&lt;/li&gt;
&lt;li&gt;La sua forma ricorda l'insieme di Mandelbrot.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= &amp;nbsp; (&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 255,&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lambda&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;V &amp;nbsp; &amp;nbsp; &amp;nbsp; ,B,c&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;:c &amp;nbsp; and Y(V*V+B,B, &amp;nbsp;c&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-1)if(abs(V)&amp;lt;6)else&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;2+c-4*abs(V)**-0.4)/i&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;) &amp;nbsp;;v, &amp;nbsp; &amp;nbsp; &amp;nbsp;x=1500,1000;C=range(v*x&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );import &amp;nbsp;struct;P=struct.pack;M,\&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j &amp;nbsp;='&amp;lt;QIIHHHH',open('M.bmp','wb').write&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;for X in j('BM'+P(M,v*x*3+26,26,12,v,x,1,24))or C:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i &amp;nbsp;,Y=_;j(P('BBB',*(lambda T:(T*80+T**9&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *i-950*T &amp;nbsp;**99,T*70-880*T**18+701*&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;T &amp;nbsp;**9 &amp;nbsp; &amp;nbsp; ,T*i**(1-T**45*2)))(sum(&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y(0,(A%3/3.+X%v+(X/v+&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A/3/3.-x/2)/1j)*2.5&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;/x &amp;nbsp; -2.7,i)**2 for &amp;nbsp;\&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; in C&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [:9]])&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /9)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;) &amp;nbsp; )&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nell'ottava riga x = 1500, 1000 indica la dimensione dell'immagine che verrà generata. E' possibile cambiare questi valori, ma ricordatevi che il tempo impiegato per generare l'immagine varierà drasticamente. Io personalmente l'ho provato con una risoluzione 7200x4800 e mi ci sono volute circa 2-3 ore prima di vedere l'immagine (ho usato un MacBook Pro CPU = 2.4GHZ. La CPU era impiegata al 50% durante l'esecuzione dell'algoritmo).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Siti di riferimento&lt;/b&gt;:&lt;br /&gt;
&lt;a href="http://preshing.com/20110926/high-resolution-mandelbrot-in-obfuscated-python" target="_blank"&gt;Preshing On Programming&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://it.wikipedia.org/wiki/Beno%C3%AEt_Mandelbrot" target="_blank"&gt;Wikipedia&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Per coloro alle prime armi&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Se non avete un compilatore python scaricatelo al seguente &lt;a href="http://www.python.it/download/" target="_blank"&gt;link&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Copiare il proprio codice in un normale text editor (non usate word o open office)&lt;/li&gt;
&lt;li&gt;Dalla vostra finestra del terminale digitate python "nome del file dove avete copiato il programma"&lt;/li&gt;
&lt;li&gt;Se volete evitare di usare il terminale potete trovare degli ambienti di sviluppo su grafica (IDE) &lt;a href="http://wiki.python.org/moin/IntegratedDevelopmentEnvironments" target="_blank"&gt;qui&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/dcEyW70Udvg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/627810016153573464/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2011/11/python-generare-linsieme-di-mandelbrot.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/627810016153573464?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/627810016153573464?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/dcEyW70Udvg/python-generare-linsieme-di-mandelbrot.html" title="Python - Generare l'Insieme di Mandelbrot" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-bQ0-8UVe4tQ/TtIyN-zBobI/AAAAAAAAAEc/vNCuM2RGpcU/s72-c/300px-Mandel_zoom_00_mandelbrot_set.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2011/11/python-generare-linsieme-di-mandelbrot.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMCQ3g_cSp7ImA9WhRREks.&quot;"><id>tag:blogger.com,1999:blog-3927955777425519410.post-8555824685845236678</id><published>2011-11-25T22:57:00.001+01:00</published><updated>2011-11-25T23:34:22.649+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-25T23:34:22.649+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Network" /><category scheme="http://www.blogger.com/atom/ns#" term="Python" /><title>Python - Creare un network: Server-Client (UDP)</title><content type="html">Lo User Datagram Protocol (&lt;b&gt;UDP&lt;/b&gt;) è il protocollo principale (insieme a quello TCP) a&lt;a href="http://wiki.python.org/moin/UdpCommunication" target="_blank"&gt; livello di trasporto &lt;/a&gt;nella comunicazione fra hosts. &lt;a href="http://it.wikipedia.org/wiki/Suite_di_protocolli_Internet" target="_blank"&gt;Qui&lt;/a&gt; trovate una descrizione dei livelli di comunicazione.&lt;br /&gt;
&lt;br /&gt;
L'UDP è :&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;connectionless: un messaggio non viene mandato a un altro host tramite un apposito stream di dati stabilito in precedenza. I dati quindi possono facilmente essere persi senza che chi li invii ne venga a conoscenza;&lt;/li&gt;
&lt;li&gt;I dati ricevuti non sono necessariamente in ordine. Un file di dimensione &lt;b&gt;A&lt;/b&gt;, infatti, viene suddiviso in &lt;b&gt;n&lt;/b&gt; pacchetti di dimensione &lt;b&gt;A/n&lt;/b&gt;&amp;nbsp;e ognuno di essi viene inviato separatamente. Per ricostruire A, tuttavia, i pacchetti devono essere "uniti" nell'ordine esatto;&lt;/li&gt;
&lt;li&gt;Rapido (ottimo per l'invio di Audio/Video in streaming);&lt;/li&gt;
&lt;li&gt;Supporta il Broadcast (dati inviati a tutti nel network locale) e il &lt;a href="http://sic-oding.blogspot.com/2011/11/python-ip-multicasting.html" target="_blank"&gt;Multicasting&lt;/a&gt; (dati inviati a tutti coloro che lo richiedono);&lt;/li&gt;
&lt;li&gt;Non supporta il controllo di congestione della rete.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Possiamo ben notare che questo protocollo presenta alcuni pregi, ma anche molti difetti. Allora perché preoccuparsi tanto?&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
L'UDP, a differenza del TCP, è molto più flessibile. Volendo è possibile costruite un proprio protocollo TCP partendo dall'UDP. In poche parole l'UDP è flessibile (personalizzabile).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Un pacchetto dati UDP (&lt;b&gt;Datagram&lt;/b&gt;) contiene le seguenti principali informazioni:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Indirizzo mittente (IP + Porta) (Facoltativo)&lt;/li&gt;
&lt;li&gt;Indirizzo destinatario (IP + Porta)&lt;/li&gt;
&lt;li&gt;Lunghezza del pacchetto in ottetti&lt;/li&gt;
&lt;li&gt;I dati da inviare&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre style="font-size: 1em;"&gt;                  0      7 8     15 16    23 24    31
                 +--------+--------+--------+--------+
                 |     Source      |   Destination   |
                 |      Port       |      Port       |
                 +--------+--------+--------+--------+
                 |                 |                 |
                 |     Length      |    Add. Info    |
                 +--------+--------+--------+--------+
                 |
                 |               DATA ...
                 +---------------- ...&lt;/pre&gt;
&lt;br /&gt;Di seguito troverete le istruzioni base per inviare informazioni tramite UDP:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;MITTENTE&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre dir="ltr" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="background-color: white;"&gt;&lt;span class="line"&gt;&lt;span class="ResWord"&gt;import&lt;/span&gt; &lt;span class="ID"&gt;socket&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre dir="ltr" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d;"&gt;# Indirizzo destinatario (in questo caso è lo stesso host del mittente)&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d_3"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-3-1"&gt;&lt;/span&gt;&lt;span class="ID"&gt;IP_UDP &lt;/span&gt;= &lt;span class="String"&gt;"&lt;/span&gt;&lt;span class="String"&gt;127.0.0.1&lt;/span&gt;&lt;span class="String"&gt;" &lt;span style="color: #38761d;"&gt;# "localhost" o ""&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d_4"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-4-1"&gt;&lt;/span&gt;&lt;span class="ID"&gt;PORTA_UDP &lt;/span&gt;= &lt;span class="Number"&gt;5005&lt;/span&gt;&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d_5"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-5-1"&gt;&lt;/span&gt;&lt;span class="ID"&gt;MESSAGGIO &lt;/span&gt;= &lt;span class="String"&gt;"&lt;/span&gt;&lt;span class="String"&gt;&lt;span style="color: #cc0000;"&gt;Sic-Oding&lt;/span&gt;&lt;/span&gt;&lt;span class="String"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre dir="ltr" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d;"&gt;# AF_INET --&amp;gt; Uso del protocollo IP /IPv4
# usare AF_INET6 per IPv6 se disponibile
# SOCK_DGRAM --&amp;gt; Crea una socket di tipo Datagram (UDP)&lt;/span&gt;
&lt;/span&gt;&lt;span class="line" style="background-color: white;"&gt;&lt;span class="ID"&gt;sock&lt;/span&gt; = &lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;socket&lt;/span&gt;( &lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;AF_INET&lt;/span&gt;, &lt;/span&gt;&lt;span class="line" style="background-color: white;"&gt;&lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;SOCK_DGRAM&lt;/span&gt; )&lt;/span&gt;&lt;/pre&gt;
&lt;pre dir="ltr" id="CA-324d3815f4a4135cc55ea46a1b82c2bd5a3a415d" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span class="line" style="background-color: white;"&gt;&lt;span style="color: #38761d;"&gt;# Invia il messaggio all'indirizzo specificato
# L'indirizzo è sotto forma di una TUPLA.&lt;/span&gt;
&lt;/span&gt;&lt;span class="ID" style="background-color: white;"&gt;sock&lt;/span&gt;&lt;span style="background-color: white;"&gt;.&lt;/span&gt;&lt;span class="ID" style="background-color: white;"&gt;sendto&lt;/span&gt;&lt;span style="background-color: white;"&gt;(&lt;/span&gt;&lt;span style="background-color: white;"&gt;MESSAGGIO&lt;/span&gt;&lt;span style="background-color: white;"&gt;, (&lt;/span&gt;&lt;span style="background-color: white;"&gt;IP_UDP&lt;/span&gt;&lt;span style="background-color: white;"&gt;, &lt;/span&gt;&lt;span style="background-color: white;"&gt;PORTA_UDP&lt;/span&gt;&lt;span style="background-color: white;"&gt;))&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;RICEVENTE&lt;/b&gt;&lt;br /&gt;
&lt;pre dir="ltr" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="background-color: white;"&gt;&lt;span class="line"&gt;&lt;span class="ResWord"&gt;import&lt;/span&gt; &lt;span class="ID"&gt;socket&lt;/span&gt;&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_2"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-2-2"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;span style="background-color: white;"&gt;IP_UDP &lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span class="line"&gt;= &lt;span class="String"&gt;"&lt;/span&gt;&lt;span class="String"&gt;127.0.0.1&lt;/span&gt;&lt;span class="String"&gt;"&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;span style="background-color: white;"&gt;PORTA_UDP &lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span class="line"&gt;= &lt;span class="Number"&gt;5005&lt;/span&gt;&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_5"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-5-2"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_6"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-6-2"&gt;&lt;/span&gt;&lt;span class="ID"&gt;sock&lt;/span&gt; = &lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;socket&lt;/span&gt;( &lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;AF_INET&lt;/span&gt;,&lt;/span&gt;&lt;span class="line"&gt; &lt;span class="ID"&gt;socket&lt;/span&gt;.&lt;span class="ID"&gt;SOCK_DGRAM&lt;/span&gt; )
&lt;/span&gt;&lt;span style="color: #38761d;"&gt;# L'indirizzo specificato è vincolato per la socket sock.&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_8"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-8-2"&gt;&lt;/span&gt;&lt;span class="ID"&gt;sock&lt;/span&gt;.&lt;span class="ID"&gt;bind&lt;/span&gt;( (&lt;span class="ID"&gt;UDP_IP&lt;/span&gt;,&lt;span class="ID"&gt;UDP_PORT&lt;/span&gt;) )&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre dir="ltr" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c" lang="en" style="border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; font-family: courier, monospace; font-size: 14px; line-height: 21px; padding-bottom: 10pt; padding-left: 10pt; padding-right: 10pt; padding-top: 10pt; white-space: pre-wrap; word-wrap: break-word;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d;"&gt;# Ascolta ripetutamente per dei dati.&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_10"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-10-2"&gt;&lt;/span&gt;&lt;span class="ResWord"&gt;while&lt;/span&gt; &lt;span class="ResWord"&gt;True&lt;/span&gt;:
&lt;/span&gt;    &lt;span style="color: #38761d;"&gt;# Riceve 1024 bytes alla volta.&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_11"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-11-2"&gt;&lt;/span&gt;    &lt;span class="ID"&gt;messaggio&lt;/span&gt;, &lt;span class="ID"&gt;indirizzo&lt;/span&gt; = &lt;span class="ID"&gt;sock&lt;/span&gt;.&lt;span class="ID"&gt;recvfrom&lt;/span&gt;( &lt;span class="Number"&gt;1024&lt;/span&gt; )&lt;/span&gt;
&lt;span class="line"&gt;&lt;span class="LineAnchor" id="CA-eed6059a95a95ea8e98512ef9ba0a30b9238b63c_12"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-12-2"&gt;&lt;/span&gt;    &lt;span class="ResWord"&gt;print&lt;/span&gt; &lt;span class="String"&gt;"&lt;span style="color: #cc0000;"&gt;Messaggio ricevuto &lt;/span&gt;&lt;/span&gt;&lt;span class="String"&gt;&lt;span style="color: #cc0000;"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class="String"&gt;"&lt;/span&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white;"&gt;messaggio&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;Tutorial di approfondimento in Inglese (mi dispiace ma non ne ho trovati in Italiano):&lt;br /&gt;&lt;a href="http://wiki.python.org/moin/UdpCommunication" target="_blank"&gt;Wiki.Python&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://tools.ietf.org/html/rfc768" target="_blank"&gt;UDP RFC&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.ibm.com/developerworks/linux/tutorials/l-pysocks/l-pysocks-pdf.pdf" target="_blank"&gt;Sockets programming in python&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://docs.python.org/library/socket.html" target="_blank"&gt;Docs.Python&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/TmCJR/~4/qKwlC9Fucy4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://sic-oding.blogspot.com/feeds/8555824685845236678/comments/default" title="Commenti sul post" /><link rel="replies" type="text/html" href="http://sic-oding.blogspot.com/2011/11/python-creare-un-network-server-client_25.html#comment-form" title="0 Commenti" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8555824685845236678?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3927955777425519410/posts/default/8555824685845236678?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/TmCJR/~3/qKwlC9Fucy4/python-creare-un-network-server-client_25.html" title="Python - Creare un network: Server-Client (UDP)" /><author><name>Simone</name><uri>http://www.blogger.com/profile/12420238198345813177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://4.bp.blogspot.com/-kKHLWApJQ10/Twt72_ibG5I/AAAAAAAAAH4/DAeKG5r81X8/s220/DSC04395.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://sic-oding.blogspot.com/2011/11/python-creare-un-network-server-client_25.html</feedburner:origLink></entry></feed>
