<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>programming &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/programming/</link>
	<description>Feed of posts on WordPress.com tagged "programming"</description>
	<pubDate>Sun, 19 May 2013 05:37:00 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Introduction to Genetic Algorithms]]></title>
<link>http://themusegarden.wordpress.com/2013/05/17/introduction-to-genetic-algorithms/</link>
<pubDate>Sat, 18 May 2013 00:08:28 +0000</pubDate>
<dc:creator>themusegarden</dc:creator>
<guid>http://themusegarden.wordpress.com/2013/05/17/introduction-to-genetic-algorithms/</guid>
<description><![CDATA[In response to my previous article about genetic algorithms for Ramsey theory, a few readers asked m]]></description>
<content:encoded><![CDATA[<p>In response to my previous article about <a title="A Genetic Algorithm Approach to Ramsey Theory" href="http://themusegarden.wordpress.com/2013/05/11/a-genetic-algorithm-approach-to-ramsey-theory/">genetic algorithms for Ramsey theory</a>, a few readers asked me to give a bit more of an introduction about genetic algorithms. As such, here you will find a beginner&#8217;s look at what a genetic algorithm is, what it is useful for, and how you can use one in your own work.</p>
<p><strong>What <em>is</em> a genetic algorithm (GA)?</strong></p>
<p>To begin with, let&#8217;s talk about what a genetic algorithm <em>is</em>, on its most basic level. The word genetic suggests something to do with biology, and if you can reach way back when in your high school science classes you might remember the basic genetic process: plants and animals are born, mate with one another, and create new generations. Over time, these generations tend to emphasize certain traits essential to survival, while downplaying the weaker (recessive) traits. A genetic algorithm works much the same way. We come up with a population of possible solutions to a problem, &#8220;mate&#8221; them together, and look at our new solutions to see if they are any better. Over time, we can create solutions that converge to better and better values. This is useful when a problem is too complex to search all possibilities. Below you will see an image describing how a simple GA works.</p>
<p><a href="http://themusegarden.files.wordpress.com/2013/05/geneticalgorithms-1-e1368814707601.png"><img class="aligncenter size-large wp-image-473" alt="GeneticAlgorithms (1)" src="http://themusegarden.files.wordpress.com/2013/05/geneticalgorithms-1-e1368814707601.png?w=470&#038;h=591" width="470" height="591" /></a></p>
<p><b>Crossovers, fitness, mutation, oh my!</b></p>
<p>Before moving on, it would be useful to define some of the terms used above.</p>
<ul>
<li><span style="text-decoration:underline;"><em><strong>chromosome:</strong></em><strong> </strong></span><strong> </strong>a proposed &#8220;solution&#8221; to the problem at hand. This is usually represented by a bitstring, that is to say, a list of 0&#8242;s and 1&#8242;s. It can also hold any other information that is crucial to our problem.</li>
</ul>
<ul>
<li><em><span style="text-decoration:underline;"><strong>population:</strong></span></em><strong> </strong>a collection of these &#8220;chromosomes&#8221; that we use to combine together and make new generations. The population represents the set of all the ideas that we have about this problem at the moment</li>
</ul>
<ul>
<li><em><span style="text-decoration:underline;"><strong>fitness:</strong></span></em><strong> </strong>the fitness of a chromosome is a number representing how good it is. That is, the fitness represents how good this solution is at solving our problem. Are there glaring errors in this design? It will show through in the fitness calculation. Or maybe this solution is a really good one, after all, in which case it would have a good fitness. An example of this is say you were trying to find the shortest route to get somewhere. Fitness for a problem like this would be a number representing the distance it takes for each path you could choose. In the end, you want to find the path with the shortest distance (and the lowest fitness).</li>
</ul>
<ul>
<li><b><i><span style="text-decoration:underline;">mutation:</span></i> </b>mutation is the random entering of new data into the gene pool. Just like in biology, sometimes mutations occur and create things that were never intended. However, sometimes this inadvertent change can be to our advantage if we&#8217;re getting stuck. A common example of a mutation is to just change a small part of the chromosome, and move on.</li>
</ul>
<ul>
<li><em><span style="text-decoration:underline;"><strong>crossover:</strong></span></em> the &#8220;crossover function&#8221; represents the operations that we do in order to &#8220;mate&#8221; two (or sometimes more) of our chromosomes. There are many different types of crossover techniques, some better for certain situations than others, but at the heart of it a crossover just represents a way to combine the &#8220;traits&#8221; of two or more chromosomes into a new &#8220;baby&#8221; chromosome to be inserted into our population. This is the bulk of a genetic algorithms&#8217; work, because as the population evolves and new generations of solutions are created, the goal is to keep around the solutions with &#8220;good&#8221; fitness, and get rid of the chromosomes that aren&#8217;t doing so well.</li>
</ul>
<ul>
<li><em><span style="text-decoration:underline;"><strong>termination condition:</strong></span></em><strong> </strong>all good things must come to an end. While we in theory <em>could</em> just leave our algorithm running forever, that would not be very helpful because as I will discuss later in this post, solutions can&#8217;t keep getting better forever. In addition, sometimes you won&#8217;t actually get to the &#8220;best solution&#8221; and instead will converge on what&#8217;s called a &#8220;local minima/maxima&#8221;. When this happens, it means you&#8217;ve found an &#8220;okay&#8221; solution, but the population got flooded with many similar chromosomes and couldn&#8217;t really improve itself after that point. Think of it this way: if everyone in the world were exactly the same, would you expect any different from their children? Common terminating conditions are:
<ul>
<li>a) finding the best solution (ideal)</li>
<li>b) running a preset number of generations and using that as a cutoff point</li>
<li>c) quitting after every member of the population falls within a certain similarity range (this means that no new/better solutions are likely to be produced)</li>
</ul>
</li>
</ul>
<p>&#160;</p>
<p><b>But why would I want to do all this?</b></p>
<p>I know this seems like a pretty complicated process. Why not just use a computer to figure out the real solution instead of dancing around it in this complicated manner? I hear you saying. Well, it turns out that&#8217;s not always possible&#8230;</p>
<p>Enter the <a title="Traveling Salesman" href="http://en.wikipedia.org/wiki/Travelling_salesman_problem" target="_blank">Traveling Salesman Problem (TSP)</a>. While there are many problems that are still very hard for us to solve with computers, this is one of the best known and most studied, and it turns out that using a genetic algorithm is actually a pretty good approach and is much quicker than running an exhaustive search of all paths possible. Remember when I used the example of finding the shortest distance to go somewhere? That&#8217;s pretty much what this is. I&#8217;ve done a blog post on this before (see <a title="Holiday Maths Puzzle #2" href="http://themusegarden.wordpress.com/2012/12/25/holiday-maths-puzzle-2/" target="_blank">here</a>). In the traveling salesman problem, there is a man that needs to visit a list of different cities on his route, but he wants to get there and back as quickly as possible. Therefore, you need to find the shortest route to hit all the cities and return home. This isn&#8217;t always as easy as it sounds, and as the number of cities grows, so too does the time it takes to find the right one. Very quickly it becomes implausible to check every possible path, so we use a genetic algorithm to help us weed out the bad ones.</p>
<p>Another example of how we would use a genetic algorithm is for <a href="http://en.wikipedia.org/wiki/Graph_theory" target="_blank">graph theory</a> problems that also have a huge number of possible solutions. You can see how I applied a genetic algorithm to the problem of Ramsey numbers <a title="A Genetic Algorithm Approach to Ramsey Theory" href="http://themusegarden.wordpress.com/2013/05/11/a-genetic-algorithm-approach-to-ramsey-theory/" target="_blank">here</a>.</p>
<p>&#160;</p>
<p><strong>Okay, so how do I use this in my project?</strong></p>
<p>It&#8217;s pretty simple. I know, I know, it looks complicated, but once you get everything apportioned out correctly its not that bad. Things to think about when applying a GA to a hard problem (we will use the Traveling Salesman Problem as an example here):</p>
<ul>
<li>First decide what your &#8220;chromosomes&#8221; will look like. These are the meat of your population, and these are what will be mutated and crossovered in order to create better solutions. For the TSP, we will use a a sequence of numbers denoting what cities to visit and in what order. (For example, &#8220;1 5 4 2 3&#8243; describes a way you could make a circuit through 5 cities).</li>
</ul>
<ul>
<li>Decide on how fitness will be evaluated, this is important, because members with better fitness will be the ones that stick around in your population and (hopefully) make your solutions better. In our problem, fitness refers to how far our chosen path takes us. The lower the fitness score, the shorter our travel is. We want to minimize this number with our algorithm.</li>
</ul>
<ul>
<li>Next we need to figure out what our crossover will be. This is very important to consider, because we want something that will take parts of both of our &#8220;parents&#8221; and combine them together in some way to make a &#8220;baby&#8221;. For traveling salesman, we can&#8217;t just grab some from one parent and some from the other, because we run the risk of duplicates. (we don&#8217;t want a path to look like &#8220;1 2 2 3 4&#8243;, city 2 is visited twice and we never get to city 5). Therefore, we have to use more sophisticated methods. I won&#8217;t go into them here, but if you&#8217;re interested check out <a href="http://en.wikipedia.org/wiki/Crossover_(genetic_algorithm)" target="_blank">this wikipedia page </a>for more info on crossover techniques.</li>
</ul>
<p>&#160;</p>
<p><strong>What are the downsides?</strong></p>
<p>&#8220;Every rose has its thorn,&#8221; as they say, and genetic algorithms are no different. What seems like a cure-all for all our intractable problem needs can have hindrances as well. As I mentioned before, GAs have a problem of converging too early to a &#8220;not quite value&#8221;. Often this takes many repetitions of running the program and fine tuning things such as population size and mutation rate. Sometimes happening upon the &#8220;best&#8221; solution is a product of randomness. But in a GA, we use this randomness to our advantage as much as we can. Another inherent problem is the fact that we have to program all this framework around it. Using a GA is only viable if its an extremely complex problem that cannot be solved more efficiently. For example, using a GA to solve a 5 city TSP would be foolish. We can run through all those possibilities very quickly. On the other hand, bumping that up to 50 or 500 cities proves a much harder challenge.</p>
<p>In addition, using a genetic algorithm means you have to find a type of chromosome, fitness function, population size, and crossover that works for you. Pick the wrong values for these, and the program will behave less than optimally. Even in some genetic algorithms, the fitness function for even one chromosome can take quite a while to compute, and as such it also becomes very slow to use on highly computational problems.</p>
<p>&#160;</p>
<p><strong>Where can I learn more?</strong></p>
<p>I hope this has covered the basics of genetic algorithms and interested you in learning more. If you would like to see a project I have done involving GAs you can read <a title="A Genetic Algorithm Approach to Ramsey Theory" href="http://themusegarden.wordpress.com/2013/05/11/a-genetic-algorithm-approach-to-ramsey-theory/" target="_blank">A Genetic Algorithm Approach to Ramsey Theory</a>, and for a broader range of discussion about the theory and applications of GAs check out the book <a href="http://amzn.com/0262631857" target="_blank">An Introduction To Genetic Algorithms</a> by Melanie Mitchell.</p>
<p>Hope you enjoyed this introduction to the wide world of genetic programming; if you have questions or suggestions please leave them in the comments below!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[3D-DEF code and manual/tutorial (.pdf)]]></title>
<link>http://geomechanics.wordpress.com/2013/05/17/3d-def-code-and-manualtutorial-pdf/</link>
<pubDate>Fri, 17 May 2013 23:46:44 +0000</pubDate>
<dc:creator>pablojgonzalez</dc:creator>
<guid>http://geomechanics.wordpress.com/2013/05/17/3d-def-code-and-manualtutorial-pdf/</guid>
<description><![CDATA[Recently, I encountered a ground deformation problem where the slip along a particular fault seems n]]></description>
<content:encoded><![CDATA[<p>Recently, I encountered a ground deformation problem where the slip along a particular <a href="http://en.wikipedia.org/wiki/Fault_%28geology%29" target="_blank">fault</a> seems not partitioned (distributed) as usual. Most of the elastic dislocation codes assume that slip partitions about half of the slip on one side block (hangingwall) and the other half along the other block (footwall), e.g., the popular <a href="http://www.mathworks.com/matlabcentral/fileexchange/25982" target="_blank">Okada codes</a>. These codes will not work when slip occurs only due to the motion of one block. This is basically the problem I want to study, for this you need more advance and flexible programs, one of those is 3D-DEF.</p>
<p><a href="http://www.ceri.memphis.edu/people/ellis/3ddef/" target="_blank">3D-DEF</a> code is a three-dimensional boundary-element model that allows the calculation of stresses, strains, and displacements within and on the surface of an elastic half-space (it means, there is no bottom to the model). The power of the model comes from the ability to a) solve for a variety of deformation quantities on a variety of faults and planes simultaneously, and b) to drive the deformation in relatively realistic (and therefore potentially complex) ways.</p>
<p>So, I just downloaded the package few days ago. However, I found that the package you can download from <a href="https://umdrive.memphis.edu/mellis/public/3ddef.tar" target="_blank">here</a> will not compile at your first try using default linux-installed <em>gfortran</em> compiler. Some modifications were necessary, which are minimal but related to the length of lines (a constrain of fortran codes). Another problem was the order of compilation of the subprograms, even after correcting this. Compilation will fail due to some preexisting .mod files, producing some errors. So I have worked around those little problems, and I have uploaded a mild corrected version of the package <a href="http://geomechanics.files.wordpress.com/2013/05/3ddef-tar-bz2_removepdfextension.pdf" target="_blank">here</a> (well due to restriction on the file extensions in wordpress, it&#8217;ll require that you remove the &#8220;<em>_removepdfextension.pdf</em>&#8221; before uncompress the tarball file). In this package, in addition to the slightly modified code, I have added a simple <em>compile.me</em> script that can be executed and will create the <em>3d</em> program for you.</p>
<p>Finally, I also typeset the manual from the website in latex to generate the documentation in an amenable and print-able friendly way. There are two documents, the manual and the tutorial. Those documents provide essentially the same information as in the website, but I cannot discard typos during the translation. So, I encourage to visit the <a href="http://www.ceri.memphis.edu/people/ellis/3ddef/index.html" target="_blank">on-line documentation</a>.</p>
<p>So I hope those modifications will be of some help.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Newton's Method and Implied Volatility]]></title>
<link>http://quanttutorials.wordpress.com/2013/05/17/newtons-method-and-implied-volatility/</link>
<pubDate>Fri, 17 May 2013 23:23:05 +0000</pubDate>
<dc:creator>David Herssein</dc:creator>
<guid>http://quanttutorials.wordpress.com/2013/05/17/newtons-method-and-implied-volatility/</guid>
<description><![CDATA[There are many scenarios where one wants to find the roots of an algebraic expression (e.g. calculat]]></description>
<content:encoded><![CDATA[<p>There are many scenarios where one wants to find the roots of an algebraic expression (e.g. calculating the <a title="Finance: What is Volatility?" href="http://quanttutorials.wordpress.com/2013/05/08/finance-what-is-volatility/">implied volatility </a>of an option). However, sometimes it is very difficult (if not impossible) to find a closed form solution to a given expression, e.g. solve for x: <img src='http://s0.wp.com/latex.php?latex=100+%3D+1.5e%5E%7B-0.5x%7D+%2B+1.5e%5E%7B-x%7D+%2B+1.5e%5E%7B-1.5x%7D+%2B+101.5e%5E%7B-2x%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='100 = 1.5e^{-0.5x} + 1.5e^{-x} + 1.5e^{-1.5x} + 101.5e^{-2x}' title='100 = 1.5e^{-0.5x} + 1.5e^{-x} + 1.5e^{-1.5x} + 101.5e^{-2x}' class='latex' />. This is where iterative methods such as Newton&#8217;s method come in.</p>
<p>An iterative method is simply a method that begins with a fixed value, and by plugging that fixed value into the method, we are able to calculate the next value. Doing this over and over again, the method converges to the solution to the equation. Hence the name <em>iterative</em> method.</p>
<p>Newton&#8217;s method, is one such method, and works the following way: suppose we have some function <img src='http://s0.wp.com/latex.php?latex=f%28x%29+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x) ' title='f(x) ' class='latex' /> and we are trying to find <img src='http://s0.wp.com/latex.php?latex=x%5E%2A&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x^*' title='x^*' class='latex' /> such that <img src='http://s0.wp.com/latex.php?latex=f%28x%5E%2A%29+%3D+0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x^*) = 0' title='f(x^*) = 0' class='latex' /> (i.e. we want to find the root of the function). We can start with some guess <img src='http://s0.wp.com/latex.php?latex=x_0+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x_0 ' title='x_0 ' class='latex' />, draw the tangent line to the curve at the point <img src='http://s0.wp.com/latex.php?latex=x_0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x_0' title='x_0' class='latex' />. Now, where the tangent line crosses the x-axis is our next guess <img src='http://s0.wp.com/latex.php?latex=x_1+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x_1 ' title='x_1 ' class='latex' />, and we repeat (see the animation for a depiction of how this converges to a root).</p>
<p>The equation of Newton&#8217;s method is: <img src='http://s0.wp.com/latex.php?latex=x_n+%3D+x_%7Bn-1%7D+-+%5Cfrac%7Bf%28x_%7Bn-1%7D%29%7D%7Bf%27%28x_%7Bn-1%7D%29%7D+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x_n = x_{n-1} - &#92;frac{f(x_{n-1})}{f&#039;(x_{n-1})} ' title='x_n = x_{n-1} - &#92;frac{f(x_{n-1})}{f&#039;(x_{n-1})} ' class='latex' />.</p>
<div class="wp-caption alignright" style="width: 310px"><a href="http://commons.wikipedia.org/wiki/File:NewtonIteration_Ani.gif" target="_blank"><img class="zemanta-img-inserted" title="Animation of Newton method" alt="Animation of Newton method" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/NewtonIteration_Ani.gif/300px-NewtonIteration_Ani.gif" width="300" height="214" /></a><p class="wp-caption-text">Animation of Newton method (Photo credit: Wikipedia)</p></div>
<p>It is easy to see that one obvious downfall of Newton&#8217;s method is that you must be able to differentiate the function that you are using. One way to get around this would be to use the <a title="Secant Method" href="http://en.wikipedia.org/wiki/Secant_method" target="_blank">Secant method</a> which works very similarly to Newton&#8217;s method, but does not require the function to be differentiable.</p>
<p>In order to implement Newton&#8217;s method, we need an initial guess (which is of course dependent on the function) and a given tolerance that we should stop within (since this is a convergent method, it would need to loop infinitely for an exact solution).</p>
<pre class="brush: cpp; title: ; notranslate" title="">
double newtons_method(double x_0, double tol){
    // It is assumed that f() and f_prime() are
    // functions that are elsewhere declared

    // declare and initiate parameters
    double x_new = x_0;
    double x_old = x_0 - 1;

    // now we perform the iterative Newton's method
    do{
        x_old = x_new; // store the old x value
        x_new = x_old - f(x_old)/f_prime(x_old); // calculate the new x value
    }while(fabs(x_old - x_new) &#62; tol); // loop until within the given tolerance

    return x_new;
}
</pre>
<p>Using the above code with an implemented Black-Scholes model, we would be able to calculate the implied volatility of an option by setting the function <img src='http://s0.wp.com/latex.php?latex=f%28x%29+%3D+V_%7BBS%7D+-+V_%7BMarket%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x) = V_{BS} - V_{Market}' title='f(x) = V_{BS} - V_{Market}' class='latex' />, where <img src='http://s0.wp.com/latex.php?latex=V_%7BBS%7D+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='V_{BS} ' title='V_{BS} ' class='latex' /> is the BS value of the option for a given volatility <img src='http://s0.wp.com/latex.php?latex=%5Csigma&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;sigma' title='&#92;sigma' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=V_%7BMarket%7D+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='V_{Market} ' title='V_{Market} ' class='latex' /> is the market price of the option, and <img src='http://s0.wp.com/latex.php?latex=f%27%28x%29+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f&#039;(x) ' title='f&#039;(x) ' class='latex' /> refers to the Vega of the option.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SqlBulkCopy]]></title>
<link>http://csjlsolutions.wordpress.com/2013/05/17/sqlbulkcopy/</link>
<pubDate>Fri, 17 May 2013 23:18:54 +0000</pubDate>
<dc:creator>changsul</dc:creator>
<guid>http://csjlsolutions.wordpress.com/2013/05/17/sqlbulkcopy/</guid>
<description><![CDATA[MSDN class page SqlBulkCopy is useful especially to import bulk data ( ~= 600,000, e.g.) records fro]]></description>
<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx" target="_blank">MSDN class page</a></p>
<p>SqlBulkCopy is useful especially to import bulk data ( ~= 600,000, e.g.) records from a SQL or another source to a designated table in a SQL server.</p>
<p>BUT if you do this in a EntityFramework environment in .NET framework, then you might want to have this structure for faster performance.</p>
<p>{<br />
// set db config properties to false to disable all the auto-detect and auto-validation<br />
dbContext.Configuration.AutoDetectChangesEnabled = false;<br />
dbContext.Configuration.ValidateOnSaveEnabled = false;</p>
<p>// perform bulk copy to SQL<br />
using(SqlBulkCopy myCopy = SqlBulkCopy(sqlConnStr))<br />
{<br />
&#8230;<br />
myCopy.BatchSize = 100; // row number to send to the server as a batch proc.<br />
myCopy.WriteToServer(your data here);<br />
&#8230;<br />
}<br />
// Re-set db configuration properties to true.<br />
dbContext.Configuration.AutoDetectChangesEnabled = true;<br />
dbContext.Configuration.ValidateOnSaveEnabled = true;<br />
}</p>
<p>For details re how to use SqlBulkCopy, pls refer to the MSDN page link at the top of this article. Hope this helps. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Practice Room SRM 177 DIV 2, Problem 500 Rep]]></title>
<link>http://topblogcoder.wordpress.com/2013/05/18/practice-room-srm-177-div-2-problem-500-rep/</link>
<pubDate>Fri, 17 May 2013 22:32:40 +0000</pubDate>
<dc:creator>Alethor</dc:creator>
<guid>http://topblogcoder.wordpress.com/2013/05/18/practice-room-srm-177-div-2-problem-500-rep/</guid>
<description><![CDATA[Here a new problem I´ve solved right now! Here i decided a for loop, in each iteration use regular e]]></description>
<content:encoded><![CDATA[<p>Here a new problem I´ve solved right now!</p>
<p>Here i decided a for loop, in each iteration use regular expression to get the first index of the first digit, then, extract the name, and then extract the next 3 elements in the element, and eliminate the white spaces if exist, then, check if is bigger than the maximum previously stored. When the for loop ends, remove the white spaces in the beginning of the result and at the end, and then return the result.</p>
<p>Here the <strong>problem statement</strong>:</p>
<p>Our student data is a mess! Each student is described with one string. At least a student&#8217;s data always starts with her name, then her age, and then her address, and none of these is ever missing. The name and age are separated by one or more spaces and the age is separated from the address by one or more spaces. There may be leading and trailing spaces in a student&#8217;s data.</p>
<p>A student&#8217;s name always consists only of uppercase letters &#8216;A&#8217;-'Z&#8217; and embedded (not leading or trailing) spaces. A student&#8217;s age always consists of exactly 1, 2, or 3 digits, and its leading digit is not a zero. A student&#8217;s address always contains at least one non-space character.</p>
<p>We need to find the name of the oldest student. If there are several, we want the one that appears earliest in the data. The name should include its embedded spaces (even if there are several consecutive embedded spaces), but no leading spaces and no trailing spaces.</p>
<p>Create a class OldestOne that contains a method oldest that is given a string[] <b>data</b> where each element is the data for a student, and that returns the name of the oldest student. </p>
<p>Here <strong>my code</strong>:</p>
<pre>public class OldestOne
    {
        public string oldest(string[] data)
        {
            string pattern = "[1234567890]";
            string res = "";
            int max = 0;
            for (int i = 0; i &#60; data.Length; i++)
            {
                Regex r = new Regex(pattern);
                string name = data[i].Substring(0, r.Match(data[i]).Index - 1);
                string age = data[i].Substring(r.Match(data[i]).Index, 3);
                if (age[2] == ' ')
                    age = age.Remove(2, 1);
                if (age[1] == ' ')
                {
                    if(age.Length &#62; 2)
                        age = age.Remove(1, 2);
                    else
                        age = age.Remove(1, 1);
                }
                if (int.Parse(age) &#62; max)
                {
                    max = int.Parse(age);
                    res = name;
                }
            }
            while (res[0] == ' ')
                res = res.Remove(0, 1);
            while(res[res.Length - 1] == ' ')
                res = res.Remove(res.Length - 1,1);
            return res;
        }
    }</pre>
<p>If you have another approach, please share with me in a comment!</p>
<p>Thank you very much</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Briefly ROS - Lesson One]]></title>
<link>http://machinelearning1.wordpress.com/2013/05/17/briefly-ros-lesson-one/</link>
<pubDate>Fri, 17 May 2013 22:26:29 +0000</pubDate>
<dc:creator>machinelearning1</dc:creator>
<guid>http://machinelearning1.wordpress.com/2013/05/17/briefly-ros-lesson-one/</guid>
<description><![CDATA[This tutorial is just as a fast and quick reminder. To see details about the commands check this lin]]></description>
<content:encoded><![CDATA[<p>This tutorial is just as a fast and quick reminder. To see details about the commands check this <a href="http://www.ros.org/wiki/ROS/Tutorials" target="_blank">link</a>.</p>
<p>1- run `<strong>roscore</strong>&#8216;<br />
2- in a new tab check the existing nodes: `<strong>rosnode list</strong>&#8216;<br />
3- for checking the information about the nodes use : `<strong>rosnode info /rosout</strong>&#8216;<br />
4- to run a node from inside a package we use: <strong>rosrun [packagename] [nodename]</strong><br />
e.g. <strong>rosrun turtlesim turtlesim_node</strong><br />
5- open a new tab check again the existing nodes: `<strong>rosnode list</strong>&#8216; it should include a new one<br />
6- you can kill a running rosnode by using ctrl+c<br />
7- create another node by a specific name: <strong>rosrun turtlesim turtlesim_node</strong> <strong>__name:=new_name</strong><br />
8- then if you check `<strong>rosnode list</strong>&#8216; there will be a new rosnode by the name <strong>new_name</strong><br />
9- if the previous rosnode still exist when you run rosnode list, then you can use `<strong>rosnode cleanup</strong>&#8216; to clean the dead rosnodes<br />
10- you can check the activity of the rosnode using : `<strong>rosnode ping rosnode_name</strong>&#8216;</p>
<p>######################## SO FAR  ######################<br />
<strong>roscore</strong> : runs the core of the ros<br />
<strong>rosrun</strong> : runs a node from inside a package (e.g. turtlesim_node node inside turtlesim package)<br />
#################################################</p>
<p>11 &#8211; start `<strong>roscore</strong>&#8216;<br />
12 &#8211; start `<strong>rosrun turtlesim turtlesim_node</strong>&#8216;<br />
13 &#8211; start something (a node) to control the turtle `<strong>rosrun turtlesim turtle_teleop_key</strong>&#8216;<br />
14 &#8211; The turtlesim_node and the turtle_teleop_key nodes are communicating with each other over a ROS Topic.<br />
15 &#8211; so topic is something to  communicate between nodes, if we consider nodes as exe/dll files then the topics are the embedded functions inside those<br />
16- use `<strong>rosrun rqt_graph rqt_graph</strong>&#8216; to show the graph between the nodes<br />
17- we use rostopic command to work with topics<br />
18 &#8211; type <strong>rostopic -h</strong><br />
<strong>rostopic bw</strong>     display bandwidth used by topic<br />
<strong>rostopic echo</strong>   print messages to screen<br />
<strong>rostopic hz</strong>     display publishing rate of topic<br />
<strong>rostopic list</strong>   print information about active topics<br />
<strong>rostopic pub</strong>    publish data to topic<br />
<strong>rostopic type</strong>   print topic type</p>
<p>19- <strong>rostopic echo</strong> shows the data published on the topic<br />
<strong>rostopic echo topic_name</strong><br />
`<strong>rostopic echo /turtle1/command_velocity</strong>&#8216;<br />
20 &#8211; to see rostopic list use : `<strong>rostopic list</strong>&#8216;<br />
`<strong>rostopic list -v</strong>&#8216;<br />
21 &#8211; Communication on topics happens by sending ROS messages between nodes.<br />
<strong>rostopic type  /turtle1/command_velocity</strong><br />
22 &#8211; then you can find information about the detail of that message:<br />
`<strong>rosmsg show turtlesim/Velocity</strong>&#8216;<br />
23 &#8211; we can send a single message to turtlesim package and tell it to move with a velocity and angular velocity:<br />
`<strong>rostopic pub -1 /turle1/command_velocity turtlesim/Velocity &#8212; 2.0 1.8</strong>&#8216;<br />
24 &#8211; rostopic(use a function)+publish(give input to the function)+topic_name+msg_name(variable name)+inputs(assign input to the variables)</p>
<p>################################ SO FAR  ##############<br />
rosnode is a dll/exe<br />
rostopic is a function embedded inside the dll/exe<br />
rostopic list -v   &#8211;&#62; find the list of messages<br />
rostopic type  /turtle1/command_velocity  &#8212;&#62; find the type of messages (data)<br />
now we can publish on a topic:<br />
rostopic(use a function)+publish(give input to the function)+topic_name+msg_name(variable name)+inputs(assign input to the variables)<br />
in detail:<br />
rostopic pub : publish messages to a given topic<br />
-1 : causes rostopic to use when pubishing one message then exit<br />
/turtle1/command_velocity : name of the topic to publish to<br />
turtlesim/Velocity : the message type to use when publishing the topic<br />
&#8211; : says the arguments are not options<br />
2.0 1.8 : two inputs to publish</p>
<p>###################################################</p>
<p>25 &#8211; `<strong>rostopic hz [topicname]</strong>&#8216; reports the rate at which data is published</p>
<p>26 &#8211; for using rqt_plot you sould run it as a node: <strong>rosrun rqt_plot rqt_plot</strong><br />
then in the new plot window enter: <strong>/turtle1/pose/x</strong> and <strong>/turtle1/pose/y</strong></p>
<p>27 &#8211; services are another way that nodes can communicate with each other. services allow nodes to send request and receive a response. `<strong>rosservice</strong>&#8216;</p>
<p><strong>rosservice list</strong>         print information about active services<br />
<strong>rosservice call</strong>         call the service with the provided args<br />
<strong>rosservice type</strong>         print service type<br />
<strong>rosservice find</strong>         find services by service type<br />
<strong>rosservice uri</strong>          print service ROSRPC uri</p>
<p>28 &#8211; use &#8216;<strong>rosservice list</strong>&#8216; to get a list of services</p>
<p>29 &#8211; to find the type of a service use : <strong>rosservice type [servicename]</strong><br />
(e.g. <strong>rosservice type clear</strong>)</p>
<p>30 &#8211; to call a service with arguments : <strong>rosservice call [servicename] [args]</strong><br />
(e.g. <strong>rosservice call clear</strong>)<br />
(e.g <strong>rosservice type spawn&#124; rossrv show</strong>)<br />
(then <strong>rosservice call spawn 2 2 0.2</strong> &#8220;&#8221;)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Git workflow and links]]></title>
<link>http://pseudotrue.com/2013/05/17/git-workflow-and-links/</link>
<pubDate>Fri, 17 May 2013 21:57:16 +0000</pubDate>
<dc:creator>Gray</dc:creator>
<guid>http://pseudotrue.com/2013/05/17/git-workflow-and-links/</guid>
<description><![CDATA[I&#8217;m setting up a real. honest-to-goodness public opensource project, which is an opportunity t]]></description>
<content:encoded><![CDATA[<p>I&#8217;m setting up a real. honest-to-goodness public opensource project, which is an opportunity to learn more about the software that I kind of take for granted.  I use Git for version control, you should use it too, and store a lot of files on <a href="https://github.com/gcalhoun">GitHub</a>.  Apparently people really like &#8220;no fast-forward&#8221; merges and I&#8217;ve never really understood it so I looked into it some more and decided that I&#8217;m quite happy with rebasing heavily (it seems like you can get the apparent benefits of <em>no-ff</em> just by tagging a lot, so I&#8217;m still a little mystified by its attraction).</p>
<ul>
<li>If none of that made sense, <a href="http://nvie.com/posts/a-successful-git-branching-model">this seems to be a dominant git workflow</a>, and it helped me get started.  But, again, I don&#8217;t like no-ff merges and like to rebase before merging back into the main branches (this preference is not necessarily apparent if you go to my GitHub page&#8230;)</li>
<li>These two posts, by <a href="https://sandofsky.com/blog/git-workflow.html">Benjamin Sandofsky</a> and <a href="http://blog.izs.me/post/37650663670/git-rebase">Isaac Schlueter</a>, describe rebase well and make me really think that I need to start using git-bisect.</li>
<li><a href="http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html">Linus Torvald&#8217;s email on git workflow for the Linux Kernel is really helpful too</a>.</li>
</ul>
<p>This post is really an excuse for me to have a place to put these links. obviously.</p>
<p>&#160;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Do Your Own Website?]]></title>
<link>http://halleson.net/2013/05/17/do-your-own-website/</link>
<pubDate>Fri, 17 May 2013 21:29:39 +0000</pubDate>
<dc:creator>R. Z. Halleson</dc:creator>
<guid>http://halleson.net/2013/05/17/do-your-own-website/</guid>
<description><![CDATA[Like many, or even most writers, expendable cash is limited, but long ago I invested in a domain nam]]></description>
<content:encoded><![CDATA[<p><a href="http://halleson.files.wordpress.com/2013/05/beware.gif"><img class="alignright size-full wp-image-377" alt="Beware" src="http://halleson.files.wordpress.com/2013/05/beware.gif?w=144&#038;h=390" width="144" height="390" /></a>Like many, or even most writers, expendable cash is limited, but long ago I invested in a domain name and a hosting site. I have always used <a title="Register.com" href="http://www.register.com/" target="_blank">Register.com</a>, and the folks there have always been helpful in answering my questions.</p>
<p>Creating a website in the early-to-mid-nineties was different than it is now. There weren&#8217;t the variety of tools available that we see today. You were much more on your own to get it developed. I began with an HTML program called <a title="HoTMetaL Pro" href="http://en.wikipedia.org/wiki/HoTMetaL" target="_blank">HoTMetaL Pro</a> and not only programmed my own website, but also the first one for my employer <a title="Presbyterian Homes" href="http://www.presbyterianhomes.org/" target="_blank">Presbyterian Homes</a> where I worked as the Marketing Manager until retirement. It was a bit of a learning curve, but as I was doing it all on my own time in the evenings, I was able to slowly figure it out.  HoTMetaL Pro eventually disappeared and I turned to Macromedia <a title="Dreamweaver" href="http://www.adobe.com/products/dreamweaver.html" target="_blank">Dreamweaver</a> as the next big thing.  Having already used a rather simplistic program, by today&#8217;s standards, I learned to use Dreamweaver without too much trouble.  Those were the days when tables were used as a basic layout tool.  Now they are discouraged, why? I don&#8217;t know, because they are a lot easier to use than the so-called &#8220;layers.&#8221;</p>
<p>Dreamweaver is now an Adobe product, and when time came to revise my website , I dutifully upgraded to the latest version and got to work.  OMG!!!!  Was I in for a surprise! With CSS6 as its basis, it has gotten so complicated that I could barely handle it. No wonder huge teams of programmers get paid actual money to develop websites! I searched the web for an easier alternative, and found that there are many out there. The problem was that I knew what I wanted, and none of the alternatives gave me the freedom to develop my web message my own way.</p>
<p>So I returned to my paid-for Dreamweaver upgrade, and after a month of eat-breathe and sleeping CSS and HTML, I uploaded my newly revised website.  Please take a look at</p>
<p><a href="http://halleson.com/index.html">http://halleson.com/index.html</a>.</p>
<p>The code is a bit messy, the look is sort of homemade-ish, but it&#8217;s all mine. No fancy high-paid web designer nerds. No slick templates. As a retired person trying to build a platform as a writer, it&#8217;s the best I could do for the moment.</p>
<p>If you, the reader, are a dedicated HTML/CSS6 user, you&#8217;ll probably look at the code, and let your mouth drop open in horror.  Sorry about that. I used the <a title="W3c" href="http://en.wikipedia.org/wiki/W3C_Markup_Validation_Service">W3c validator</a>.  I really did, but when I tried to fix the code violations, it gave me a lot of &#8220;This HTML is obsolete, use CSS instead.&#8221; Yeah, right! So tell me HOW to do that, you young whippersnapper programmers!!!</p>
<p>Nevertheless, my website is up there for all the world to see.  What&#8217;s more important than it looking like a streamlined corporate look-alike, is the message that it conveys.  At least that&#8217;s what I&#8217;m believing at this moment. This is who I am. This is what I write. This is my take on the world we live in.</p>
<p>Please buy my books and contribute to my helping children and grandchildren get through college and/or paying off their loans.  I&#8217;d appreciate it so very much.</p>
<p>Leave a comment and let me know your thoughts.</p>
<p>RZ</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Los Angeles:  Angels in the Parks]]></title>
<link>http://cityparksblog.org/2013/05/17/los-angeles-angels-in-the-parks/</link>
<pubDate>Fri, 17 May 2013 21:17:50 +0000</pubDate>
<dc:creator>Kathy Blaha</dc:creator>
<guid>http://cityparksblog.org/2013/05/17/los-angeles-angels-in-the-parks/</guid>
<description><![CDATA[Not all angels have wings.  Some are clearly grounded and quietly working in Los Angeles city parks]]></description>
<content:encoded><![CDATA[<p>Not all angels have wings.  Some are clearly grounded and quietly working in Los Angeles city parks thanks to the partnership between the Recreation and Parks Department (RAP) and the <a href="www.laparksfoundation.org">Los Angeles Parks Foundation</a>.  Just over $106 million has been secured to put 50 new parks in the city in the neighborhoods most in need, based on a 2009 RAP assessment that found that many dense areas of the city lacked sufficient park space.</p>
<p><a href="http://cityparksblog.files.wordpress.com/2013/05/lapf-logo1.jpg"><img class="alignleft size-full wp-image-4424" alt="LAPF Logo1" src="http://cityparksblog.files.wordpress.com/2013/05/lapf-logo1.jpg?w=218&#038;h=69" width="218" height="69" /></a>Under its 50 Parks Initiative, 53 sites for new parks have been acquired by the city – taking advantage of the real estate downturn and bulldozing foreclosed homes in some cases – and are being developed into parks, playgrounds and recreation areas.  A quarter of the 50 parks are smaller than an acre in size.</p>
<p>“With the addition of the 50 Parks Initiative, about 20% of the parks established during this department’s long history will be the work of the last seven years,” says Barry Sanders, Recreation and Parks Commission President.  One important partner in this initiative has been the Los Angeles Parks Foundation, founded in 2008 and just hitting its stride.</p>
<p>“Probably thirty years of thinking preceded the creation of the foundation,” says Judith Kieffer, Executive Director of the Foundation.  But like many successful start-ups, it took the convergence of some good leaders – including Sanders – and Jon Kirk Mukri, General Manager for the Recreation and Parks Department.  Sanders now wears two hats as head of the Parks Commission and chair of the Foundation.  “Barry is absolutely the right person for the job – and probably the only one who can make this dual-hat role work,” says Kieffer.</p>
<p>The Foundation’s mission is all about a partnership with RAP.  They are not leading but listening, doing things with and for the department as a support organization, not a policy advocate with a “distinct and bright line of separation” between them so as to be independent enough to bring real value.  They promote the department, raise funds for parks and develop a broader constituency for the fate of public parks.</p>
<p><strong><span style="text-decoration:underline;">It Takes Two</span></strong><br />
“We have a good working relationship and we communicate constantly – one of the keys to making our partnership work.”</p>
<p>It worked well when the Republic of Korea came to the Mayor with a request to restore the Korean Friendship Bell, a gift from the Republic to the city in 1976.  The bell sits high on a hillside in Angel’s Gate Park and had become so rusty that it had stopped ringing.  Korea wanted to provide funds so that the bell would be fixed. The Foundation accepted the funds and then hired an expert to repair the bell which now once again rings for ceremonies and services.</p>
<p><a href="http://cityparksblog.files.wordpress.com/2013/05/lapf-photo-2.jpg"><img class="alignright size-full wp-image-4425" alt="LAPF Photo 2" src="http://cityparksblog.files.wordpress.com/2013/05/lapf-photo-2.jpg?w=208&#038;h=157" width="208" height="157" /></a>Typically there is some re-energized interest in projects that drive their joint interest; there is no formal priority setting.  The Foundation receives donations designated for a specific purpose that the RAP is interested in and the Foundation acts as a record-keeper.  In other cases, they will take the lead and take on the role of general contractor while working closely with the department. They have helped to construct huge projects, especially ones that have been in the system for years lacking the funding to move forward – and including the 50 Parks initiative.</p>
<p>The 50 Parks Initiative was generated by the department and may be the largest urban park expansion in the country.  RAP spearheaded all the initial fundraising and the Foundation supported them.  Together, everybody was cranking to find sources of funding from numerous public and private not for profit sources.  The Foundation hosted meetings with major donors and local banks; teamed with RAP while they pitched the idea to other city agencies, like Housing; and secured funding from philanthropic foundations that only give to nonprofit corporations.<br />
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/8ra048KrUHM?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span><br />
As of May of this year, 45 sites are now publicly owned and ready to be developed as parks.  RAP has built 13 of the sites already.  Once again, the Foundation plays a role in helping with site development, often taking possession and then hiring a contractor to build, working with the city at every step.  “We get a right of entry from the city to take ‘temporary ownership’ of a park, hire developers, get the park built and then turn the site back over to the city.”</p>
<p><span style="text-decoration:underline;"><strong>Corporate Partners</strong></span><br />
One way that the Foundation has provided value is by building a reputation with the corporate community, with new partners stepping up for the parks in big and small ways.  The challenge is to gain their support for not only the upfront capital expense but the long term maintenance of a new facility.  “The sustainability issue is probably the key thing in making the partnerships work. No one wants to do anything that is a downstream maintenance issue for the city.”</p>
<p>So for any capital project or program where the parks department sees a need, the Foundation raises additional funds – as they did for the restoration of the mounted patrol horse unit, where they identified funds for the ongoing need for trainers, feed, vets, etc.  Originally created in the early 1970&#8242;s, the Ranger Mounted Unit was established to provide services to the users of Griffith Park&#8217;s extensive bridle trails. The Foundation, as one of its first projects, provided the funding to restore the unit and add more horses to the fold.</p>
<p>In another case, the Foundation is raising funds for the planned nature conservancy in Griffith Park and the goal will include a $5 million endowment, thanks to their outreach efforts in helping donors understand the value of an ongoing reserve.</p>
<p>Along with corporate support comes the issue of donor recognition.  The Foundation is finding ways to work with the city on signage that recognizes donors, such as plaques on benches – trying to reflect corporate support without compromising the public park experience.  Recently the city had its first ‘naming’ request and is learning the importance of a program and policies to recognize donors.  More requests are coming, too, from promoters, regarding events in the park that can provide value to both to themselves and the city.</p>
<p><span style="text-decoration:underline;"><strong>A Business Model Taking Shape</strong></span><br />
The LA Parks Foundation is small.  They currently have two half time employees who provide help with bookkeeping, communications, the website and membership.  Judith herself works three quarter time.  And this year, a new full time project manager has been hired which they share with the department.</p>
<p>They share that staffer with RAP so both can take advantage of his expertise.  RAP, like many other city park departments across the nation, has seen both cutbacks (30% of their operations budget in the last 4 years) and the retirement of some of its most seasoned staffers.</p>
<p>“Typically we don’t do fundraising for city staffing – this has been a baseline issue for us.  As much as we work well with the department, we know we can’t underwrite their staffing.  We try to be sensitive about the best place we can provide value.”</p>
<p>The Foundation has just crossed the $6.5 million level in fundraising since 2008.  They have exceeded their budget every year since forming as the community embraces the idea of a private entrepreneurial partner committed to the city and its goals for parks.  Their success is linked to a 15-member board that uses its own gifts to leverage more – their giving provides a floor for the Foundation’s operations.  When the Foundation takes on a larger role in construction projects, they work with donors and the city on support for their administrative efforts.</p>
<p>“I also needed to understand and see how the city worked in order to figure out how we could work together,” said Judith. There are no weekly staff meetings between the two organizations, but Judith is talking all the time with the department, and she is out in the parks – a lot.  She also attends meetings with park advisory boards, other city departments, city council members and potential donors.</p>
<p>“We team up all the time and represent each other as needed on the same mission. This integrating of our resources around a common mission has absolutely been the key ingredient to our success.”  The City now embraces the partnership and sees how the Foundation can serve the department – and the staff sees it as a tool for them to have more success around their initiatives. “Everything we do is collaborative; we are hand in glove to get where we need to be.”</p>
<p>As the organization grows and takes on additional projects with the city and with friends of the parks groups around the city, they are looking more thoughtfully at their own future.  “We have always had an annual strategic plan which we revisit regularly with the board.  We are poised for a longer term view to help us identify where the next growth spurt will come from.  The fact that we have exceeded our budget expectations every year – that’s a good sign.”</p>
<p>Lessons learned?  “It was so critical that I work very carefully and slowly to integrate the foundation into the city system; building good relations with the city was key.  We slowly built trust as a reliable partner who wanted to work on their behalf – because the city can take money from donors and offer tax benefits without a foundation.  But RAP knew that money was being left on the table by donors not comfortable with giving money to the city for any number of reasons.”</p>
<p>Los Angeles already has a library and a police foundation.  The LA Parks Foundation is the third of its kind, and one more example of the importance of a private partner playing the role of a go-between, adding value with its flexibility and business-like approach.</p>
<p><em><a href="http://cityparksblog.files.wordpress.com/2013/01/kblaha.jpg"><img class="alignleft size-thumbnail wp-image-4127" alt="KBlaha" src="http://cityparksblog.files.wordpress.com/2013/01/kblaha.jpg?w=109&#038;h=96" width="109" height="96" /></a>Kathy Blaha writes about parks and other urban green spaces, and the role of public-private partnerships in their development and management. When she’s not writing for the blog, she consults on advancing park projects and sustainable land use solution</em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[VBA - Fizz Buzz]]></title>
<link>http://csgod.wordpress.com/2013/05/17/vba-fizz-buzz/</link>
<pubDate>Fri, 17 May 2013 21:03:01 +0000</pubDate>
<dc:creator>thecsgod</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/vba-fizz-buzz/</guid>
<description><![CDATA[Problem: Write a program which iterates from 0 to 100 and does one of the following: Prints out “Fiz]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program which iterates from 0 to 100 and does one of the following:</p>
<ol>
<li>Prints out “Fizz” if the number is divisible by 3</li>
<li>Prints out “Buzz” if the number is divisible by 5</li>
<li>Prints out “Fizz Buzz” if the number is divisible by 3 and 5</li>
</ol>
<p>You should put this operation in its own function.</p>
<h2>Code:</h2>
<pre class="brush: vb; title: ; notranslate" title="">
Function Modulo(a, b)
    Modulo = a - (b * (a \ b))
End Function

Public Sub FizzBuzz(n as Integer)
   Dim i as Integer
   For i = 0 To n
      If Modulo(i, 5) = 0 And Modulo(i, 3) = 0 Then
         MsgBox(&#34;Fizz Buzz&#34;)
      Else If Modulo(i, 3) = 0 Then
         MsgBox(&#34;Fizz&#34;)
      Else If Modulo(i, 5) = 0 Then
         MsgBox(&#34;Buzz&#34;)
      End If
   Next
End Sub
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Northeast Treatment Free Beekeeping Conference! July 16-21 Register with Golden Rule Honey]]></title>
<link>http://festooning.wordpress.com/2013/05/17/northeast-treatment-free-beekeeping-conference-july-16-21-register-with-golden-rule-honey/</link>
<pubDate>Fri, 17 May 2013 20:57:00 +0000</pubDate>
<dc:creator>Afterswarm</dc:creator>
<guid>http://festooning.wordpress.com/2013/05/17/northeast-treatment-free-beekeeping-conference-july-16-21-register-with-golden-rule-honey/</guid>
<description><![CDATA[Festooning is honored to offer children’s programming at Golden Rule Honey’s 2013 Northeast Treatmen]]></description>
<content:encoded><![CDATA[<p>Festooning is honored to offer children’s programming at<strong> Golden Rule Honey’s</strong> <strong><a href="http://www.beeuntoothers.com/index.php/events/2013-netfbc">2013 Northeast Treatment Free Beekeeping Conference</a>. </strong>Join us at the Fraternal Order of Eagles, 456 Litchfield Street  Leominster, MA 01453 for several levels of events. <strong>Register for Beginners Intensive, Field Day, Main Conference, and Childrens’ Programming at the link above</strong>. Confirmed Speakers include some of the most progressive and natural beekeepers from across the country: Dee Lusby, Michael Bush, Les Crowder, Dr. Paul Arnold, Sam Comfort, Dean (deknow) Stiglitz, Laurie (Ramona) Herboldsheimer, and more! View who else is attending at <a href="http://www.meetup.com/Boston-Beekeepers-Club/events/119942952/">Boston Beekeepers Club Meetup!</a></p>
<p>Topics to include Treatment-Free Models, Bee Breeding, Queen Rearing, Langstroth Management, Top Bar Hive Management, Honeybee Microbes, Flower Nectaries, and more!</p>
<p><a href="http://festooning.wordpress.com/?attachment_id=819" rel="attachment wp-att-819"><img class="alignnone size-large wp-image-819" alt="Waggle Dancing!" src="http://festooning.files.wordpress.com/2013/03/img_0982.jpg?w=710&#038;h=532" width="710" height="532" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby - Fizz Buzz]]></title>
<link>http://csgod.wordpress.com/2013/05/17/ruby-fizz-buzz/</link>
<pubDate>Fri, 17 May 2013 20:54:19 +0000</pubDate>
<dc:creator>thecsgod</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/ruby-fizz-buzz/</guid>
<description><![CDATA[Problem: Write a program which iterates from 0 to 100 and does one of the following: Prints out “Fiz]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program which iterates from 0 to 100 and does one of the following:</p>
<ol>
<li>Prints out “Fizz” if the number is divisible by 3</li>
<li>Prints out “Buzz” if the number is divisible by 5</li>
<li>Prints out “Fizz Buzz” if the number is divisible by 3 and 5</li>
</ol>
<p>You should put this operation in its own function.</p>
<h2>Code:</h2>
<pre class="brush: ruby; title: ; notranslate" title="">
def fizzbuzz(n)
   for i in (0..n)
      if i % 5 == 0 and i % 3 == 0
         puts &#34;Fizz buzz!&#34;
      elsif i % 3 == 0
         puts &#34;Fizz!&#34;
      elsif i % 5 == 0
         puts &#34;Buzz!&#34;
      end
   end
end

fizzbuzz(101)
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[GCJ - Garbled Email]]></title>
<link>http://caethan.wordpress.com/2013/05/17/gcj-garbled-email/</link>
<pubDate>Fri, 17 May 2013 20:54:00 +0000</pubDate>
<dc:creator>caethan</dc:creator>
<guid>http://caethan.wordpress.com/2013/05/17/gcj-garbled-email/</guid>
<description><![CDATA[Garbled Email, Round 1B 2013. This is a tricky problem.  The first tricky part is figuring out an ef]]></description>
<content:encoded><![CDATA[<p><a href="https://code.google.com/codejam/contest/2434486/dashboard#s=p2">Garbled Email</a>, Round 1B 2013.</p>
<p>This is a tricky problem.  The first tricky part is figuring out an efficient way to store the dictionary so that we can quickly identify whether a particular substring is a prefix of a word in the dictionary.  This is a well-studied problem, and the right data structure is a <a href="http://en.wikipedia.org/wiki/Trie">trie</a>.  Suppose we&#8217;re working with a small dictionary containing the words <strong>a, aac, acb, baa, bbc, bc, caba, caab</strong>.  We&#8217;ll start our trie with an empty node, and then keep adding words until we&#8217;re finished.  We start by adding the word <strong>a</strong>.  We link a node with the letter <em>a</em> to the root, and then link a marker node to that to show that this is the end of a word.</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/trie11.png"><img class="aligncenter size-full wp-image-122" alt="A simple trie." src="http://caethan.files.wordpress.com/2013/05/trie11.png?w=25&#038;h=116" width="25" height="116" /></a></p>
<p>Next, we&#8217;ll add in the word <strong>aac</strong>. We already have the letter <em>a</em> linked to the root, so we go there and add more letters to that node.</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/trie2.png"><img class="aligncenter size-full wp-image-123" alt="A larger trie." src="http://caethan.files.wordpress.com/2013/05/trie2.png?w=93&#038;h=207" width="93" height="207" /></a></p>
<p>And we repeat this until all the words are in the tree. For each letter in the new word, if that letter is already a child of the current node, we walk to that child. If not, we create a new child. Once we&#8217;re at the end of the word, we add a marker child to the last node denoting the end of the word. After we&#8217;re finished with our small dictionary, we end up with this:</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/trie3.png"><img class="aligncenter size-full wp-image-124" alt="A full trie." src="http://caethan.files.wordpress.com/2013/05/trie3.png?w=298&#038;h=252" width="298" height="252" /></a></p>
<p>Each of the red nodes marks the end of a word, so we can see that we have all eight words in the trie.</p>
<p>Now that we have our data stored in an easily-accessible manner, let&#8217;s start with a simpler problem than the one asked.  Suppose that there was no garbling, just spaces removed, and we&#8217;re given some string, say, <strong>aacaabbc</strong>.  How can we use this structure to quickly find out whether this string could be divided up into words from our dictionary?  Start at the root of the tree and look at the first letter a of the string.  <em>a</em> is a child of our current node, so we&#8217;ll walk to that node and move to the next letter.  Here we see an end node as a child, marking that we&#8217;ve now finished a possible node.  So we know we can split off the word <strong>a</strong> from our string, leaving <strong>acaabbc</strong> behind.  This split will produce a valid word separation for the whole string if and only if <strong>acaabbc</strong> can itself be divided up into words from our dictionary.</p>
<p>First, though, we need to finish walking down and make sure we&#8217;ve found the only possible split.  The next letter is <em>a</em>, which is a child of our current node, so we move there.  This node has no end node as a child, so it&#8217;s not a possible word separation.  The third letter is <em>c</em>, which is a child of this node, so we&#8217;ll move there next.  This node is another word separation, giving us <strong>aac</strong> as the first word and <strong>aabbc</strong> as the remainder of the string.  There are no other children of this node, so these are the only possible word separations.</p>
<p>So we now know that <strong>aacaabbc</strong> is divisible into words if and only if at least one of its two suffixes <strong>acaabbc</strong> and <strong>aabbc</strong> are divisible into words.  This suggests that we might be able to use dynamic programming for our problem.  We can create an array of boolean variables telling us whether each suffix of our string can be divided into words.  We can look at the suffixes of our string in order of increasing size and calculate whether each of them is divisible.  The larger suffixes can then use the calculations previously done on the smaller suffixes to quickly calculate whether they themselves are divisible.</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/dyn.png"><img class="aligncenter size-full wp-image-127" alt="Dynamic programming results." src="http://caethan.files.wordpress.com/2013/05/dyn.png?w=250&#038;h=73" width="250" height="73" /></a></p>
<p>Starting with the smallest suffix, <strong>c</strong>, we quickly find that it is not a word, so we mark that index as False.  <strong>bc</strong>, the next smallest, so we mark it as True, and similarly for <strong>bbc</strong>.  <strong>abbc</strong> gives a potential split at <strong>a&#124;bbc</strong>, and we know that <strong>bbc</strong> is True, so <strong>abbc</strong> must be True as well.  We then keep working backwards until we reach the beginning of the string, and then the final answer is simply the result in the first element of our array.  Doing this we quickly find that <strong>aacaabba</strong> is in fact divisible.</p>
<p>So this works for messages where there is no garbling at all.  Now let&#8217;s add the garbling in and see if we can work out a solution.  We&#8217;ll simplify the problem slightly, though, by allowing any character in the string to be garbled, ignoring the constraints on how close the garbled characters are allowed to be.  Suppose we have the string <strong>abbbcbba</strong>.  We can work backwards, just as before, from smaller to larger suffixes.  This time, though, instead of only storing whether or not a suffix is divisible into words, we&#8217;ll store how many changes are needed to make it divisible.</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/dyn_count.png"><img class="aligncenter size-full wp-image-131" alt="Dynamic programming with counts." src="http://caethan.files.wordpress.com/2013/05/dyn_count.png?w=250&#038;h=61" width="250" height="61" /></a><strong>c</strong> alone, for instance, isn&#8217;t a word, but we can change it into <strong>a</strong> with a single substitution, so our answer is one.  The next two suffixes, <strong>bc</strong> and <strong>bbc</strong>, are both words, so they get values of zero.  <strong>cbbc</strong> isn&#8217;t valid, but if we swap it to <strong>abbc</strong> we can split it at <strong>a&#124;bbc</strong>, giving us two valid words, for an answer of one.  We keep working backwards just as before, looking for all possible words we can construct at the start of our suffix, splitting it, and then putting the minimum changes required into our array.  Once we&#8217;re finished, the final answer is just the result in the first element of our array.  So we find that <strong>abbbcbbc</strong> can be made divisible with only a single character swap.</p>
<p>Finally, we want to incorporate the closeness requirements for our garbled characters &#8211; changes must have at least four non-garbled characters between them.  Now for each suffix we want to store five different values, giving the minimum changes required for this suffix when the first <em>x</em> characters are required to match perfectly, with <em>x</em> ranging between 0 and 4 inclusive.  Let&#8217;s look at this array for the string <strong>abbbcbba</strong>.</p>
<p><a href="http://caethan.files.wordpress.com/2013/05/dyn_final.png"><img class="aligncenter size-full wp-image-133" alt="Final dynamic programming array." src="http://caethan.files.wordpress.com/2013/05/dyn_final.png?w=275&#038;h=186" width="275" height="186" /></a></p>
<p>Here <strong>N</strong> is marking divisions that are not possible at all.  Otherwise, we fill the array with the number of changes required.  Again, let&#8217;s start at the back and move towards the front of the string.  <strong>a</strong>, the last suffix, is a word itself, so we fill its column with zeros.  <strong>ba</strong> is not a word, but could be divisible if we change one of the characters, to either <strong>bc</strong> or <strong>a&#124;a</strong>.  The bottom three rows require us to keep the first two characters unchanged, so those entries are marked as <strong>N.  </strong>Both of the top two are possible with only a single change.  <strong>bba</strong> is valid only if changed into <strong>bbc</strong>, which requires no more than two characters held unchanged, so we mark up the column appropriately.  We continue in the same manner, looking for potential word divisions and marking down the minimum changes required that allow the required distance between changes.  Then, just as with the simpler problems, we read off our final answer as the entry in the first column and the first row.  <!--more--></p>
<pre class="brush: python; title: ; notranslate" title="">

def precalculate():
    #We're going to load the dictionary into a trie
    global tree
    global end
    tree = {}
    end = ''

    def add_branch(tree, word):
        for char in word:
            if not char in tree:
                tree[char] = {}
            tree = tree[char]
        tree[end] = True

    infile = open('./garbled_email_dictionary.txt')
    for line in infile.readlines():
        add_branch(tree, line.strip())
    infile.close()

def match_words(S, prefix, index, required):
    suffix = S[index:]

    #Walk down the tree to find the right branch
    branch = tree
    for char in prefix:
        branch = branch[char]

    if suffix == '':
        if end in branch:
            return 0
        else:
            return -1

    def check(best, new, inc=0):
        if new == -1:
            return best
        if best is None:
            best = new + inc
        else:
            best = min(best, new + inc)
        return best

    best = None

    char = suffix[0]
    if char in branch: #valid match
        if end in branch[char]: #end of a word
            best = check(best, mincosts[index + 1, max(0, required - 1)])
        best = check(best, match_words(S, prefix + char, index + 1, max(0, required - 1)))
    if required == 0:
        for this in branch:
            if this == end or this == char:
                continue
            if end in branch[this]:
                best = check(best, mincosts[index + 1, 4], 1)
            if best is None or best &#62; 1: #Don't bother checking if best is already good enough
                best = check(best, match_words(S, prefix + this, index + 1, 4), 1)

    if best is None:
        return -1
    else:
        return best

def solve_case(S):
    global mincosts

    mincosts = np.zeros((len(S) + 1, 5), dtype=int)

    for index in range(len(S))[::-1]:
        for required in range(5):
            mincosts[index, required] = match_words(S, '', index, required)
    return mincosts[0,0]

</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Python - Fizz Buzz]]></title>
<link>http://csgod.wordpress.com/2013/05/17/python-fizz-buzz/</link>
<pubDate>Fri, 17 May 2013 20:50:13 +0000</pubDate>
<dc:creator>thecsgod</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/python-fizz-buzz/</guid>
<description><![CDATA[Problem: Write a program which iterates from 0 to 100 and does one of the following: Prints out “Fiz]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program which iterates from 0 to 100 and does one of the following:</p>
<ol>
<li>Prints out “Fizz” if the number is divisible by 3</li>
<li>Prints out “Buzz” if the number is divisible by 5</li>
<li>Prints out “Fizz Buzz” if the number is divisible by 3 and 5</li>
</ol>
<p>You should put this operation in its own function.</p>
<h2>Code:</h2>
<pre class="brush: python; title: ; notranslate" title="">
def fizzbuzz(n):
   for i in range(n):
      if i % 5 == 0 and i % 3 == 0:
         print &#34;Fizz Buzz&#34;
      elif i % 3 == 0:
         print &#34;Fizz&#34;
      elif i % 5 == 0:
         print &#34;Buzz&#34;
fizzbuzz(101)
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C - Fizz Buzz Program]]></title>
<link>http://csgod.wordpress.com/2013/05/17/c-fizz-buzz-program/</link>
<pubDate>Fri, 17 May 2013 20:45:48 +0000</pubDate>
<dc:creator>thecsgod</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/c-fizz-buzz-program/</guid>
<description><![CDATA[Problem: Write a program which iterates from 0 to 100 and does one of the following: Prints out “Fiz]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program which iterates from 0 to 100 and does one of the following:</p>
<ol>
<li>Prints out “Fizz” if the number is divisible by 3</li>
<li>Prints out “Buzz” if the number is divisible by 5</li>
<li>Prints out “Fizz Buzz” if the number is divisible by 3 and 5</li>
</ol>
<p>You should put this operation in its own function.</p>
<h2>Code:</h2>
<pre class="brush: cpp; title: ; notranslate" title="">
#include &#60;stdio.h&#62;

void fizzbuzz(int n) {
   int i;
   for (i = 0; i &#60; n; ++i) {
      if (i % 5 == 0 &#38;&#38; i % 3 == 0) {
         printf(&#34;Fizz Buzz!\n&#34;);
      }
      else if (i % 3 == 0) {
         printf(&#34;Fizz\n&#34;);
      }
      else if (i % 5 == 0) {
         printf(&#34;Buzz\n&#34;);
      }
   }
}

int main(void) {
   fizzbuzz(101);
   return 0;
}
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CEOs Must Learn Computer Programming To Become Better Leaders For Their Organizations]]></title>
<link>http://knogimmicks.com/2013/05/17/ceos-must-learn-computer-programming-to-become-better-leaders-for-their-organizations/</link>
<pubDate>Fri, 17 May 2013 20:41:18 +0000</pubDate>
<dc:creator>KnoGimmicks Social Media &amp; Web Design™</dc:creator>
<guid>http://knogimmicks.com/2013/05/17/ceos-must-learn-computer-programming-to-become-better-leaders-for-their-organizations/</guid>
<description><![CDATA[As a current CEO of a pre-venture startup, Social Media Expert and computer programmer specializing]]></description>
<content:encoded><![CDATA[As a current CEO of a pre-venture startup, Social Media Expert and computer programmer specializing]]></content:encoded>
</item>
<item>
<title><![CDATA[Festooning @ Tour de Hives! ]]></title>
<link>http://festooning.wordpress.com/2013/05/17/festooning-tour-de-hives/</link>
<pubDate>Fri, 17 May 2013 20:40:00 +0000</pubDate>
<dc:creator>Afterswarm</dc:creator>
<guid>http://festooning.wordpress.com/2013/05/17/festooning-tour-de-hives/</guid>
<description><![CDATA[The Boston Beekeepers have just launched tickets to participate in their 3rd annual Tour de Hives, a]]></description>
<content:encoded><![CDATA[<p>The Boston Beekeepers have just launched <a href="http://www.brownpapertickets.com/event/383795">tickets to participate in their <strong>3rd annual Tour de Hives</strong></a>, a biking tour of honey beehives in Boston scheduled for<strong> June 9, 2013</strong>. Festooning will host picnic festivities in and about the beehive including tastes of delicious treatment free honey courtesy of<strong> <a href="http://www.beeuntoothers.com/">Golden Rule</a> </strong>whose community hives are situated in the Victory Gardens. More information and a schedule of events may be found at the <a href="https://www.facebook.com/events/380670525384817/">facebook</a> and meetup event postings.</p>
<p><strong>Meet us at the Fenway Victory Gardens from 12:30-3pm for Picnic Inflation!</strong></p>
<div id="id_5196906e7c7146a90784475">The 3rd Annual Boston Tour de Hives will engage, educate and enchant you with a first-hand look at honeybees in hives across the city, and will be guided by the humans who tend them. Downtown Boston, the North End, the South End &#38; Fenway Victory Gardens will all be stops on this year&#8217;s tour, which you will visit by bike (or other means of transport if you prefer). Join us for one stop or the whole day!</p>
<p><img class="alignnone" alt="" src="https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/260537_547069675344355_1788680684_n.jpg" width="576" height="576" /></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ubuntu: A simple way to create boot messages dialog box for the console]]></title>
<link>http://joekuan.wordpress.com/2013/05/17/ubuntu-a-simple-way-to-create-boot-messages-dialog-box-for-the-console/</link>
<pubDate>Fri, 17 May 2013 20:34:49 +0000</pubDate>
<dc:creator>Joe Kuan</dc:creator>
<guid>http://joekuan.wordpress.com/2013/05/17/ubuntu-a-simple-way-to-create-boot-messages-dialog-box-for-the-console/</guid>
<description><![CDATA[I need to create a customised version of Ubuntu LiveCD to install our company software onto rackmoun]]></description>
<content:encoded><![CDATA[I need to create a customised version of Ubuntu LiveCD to install our company software onto rackmoun]]></content:encoded>
</item>
<item>
<title><![CDATA[VBA - Hello World]]></title>
<link>http://csgod.wordpress.com/2013/05/17/vba-hello-world/</link>
<pubDate>Fri, 17 May 2013 19:59:50 +0000</pubDate>
<dc:creator>blenz3</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/vba-hello-world/</guid>
<description><![CDATA[Problem: Write a sub-routine which displays the text, &#8220;Hello, World&#8221;, in a message box t]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a sub-routine which displays the text, &#8220;Hello, World&#8221;, in a message box to the user.</p>
<h2>Code:</h2>
<pre class="brush: vb; title: ; notranslate" title="">
Public Sub Hello()
   MsgBox(&#34;Hello, World!&#34;)
End Sub
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby - Hello World]]></title>
<link>http://csgod.wordpress.com/2013/05/17/ruby-hello-world/</link>
<pubDate>Fri, 17 May 2013 19:55:40 +0000</pubDate>
<dc:creator>blenz3</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/ruby-hello-world/</guid>
<description><![CDATA[Problem: Write a program to write the string literal, &#8220;Hello, World&#8221;, to the terminal or]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program to write the string literal, &#8220;Hello, World&#8221;, to the terminal or standard output location. This should be completed in one line.</p>
<h2>Code:</h2>
<pre class="brush: ruby; title: ; notranslate" title="">
puts &#34;Hello, World&#34;
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Python - Hello World]]></title>
<link>http://csgod.wordpress.com/2013/05/17/python-hello-world/</link>
<pubDate>Fri, 17 May 2013 19:50:57 +0000</pubDate>
<dc:creator>blenz3</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/python-hello-world/</guid>
<description><![CDATA[Problem: Write a program that displays the string literal, &#8220;Hello World&#8221;, to the termina]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program that displays the string literal, &#8220;Hello World&#8221;, to the terminal or standard output location. This program should consist of only a single line.</p>
<h2>Code:</h2>
<pre class="brush: python; title: ; notranslate" title="">
print(&#34;Hello, World&#34;)
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C - Hello World]]></title>
<link>http://csgod.wordpress.com/2013/05/17/c-hello-world-2/</link>
<pubDate>Fri, 17 May 2013 19:47:47 +0000</pubDate>
<dc:creator>blenz3</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/c-hello-world-2/</guid>
<description><![CDATA[Problem: Write a C program to output the string literal, &#8220;Hello, World&#8221;, to the standard]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a C program to output the string literal, &#8220;Hello, World&#8221;, to the standard output location. </p>
<h2>Code:</h2>
<pre class="brush: cpp; title: ; notranslate" title="">
#include &#60;stdio.h&#62;

int main(void) {
   printf(&#34;Hello, World!\n&#34;);
   return 0;
}
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ - Hello World]]></title>
<link>http://csgod.wordpress.com/2013/05/17/c-hello-world/</link>
<pubDate>Fri, 17 May 2013 19:42:15 +0000</pubDate>
<dc:creator>blenz3</dc:creator>
<guid>http://csgod.wordpress.com/2013/05/17/c-hello-world/</guid>
<description><![CDATA[Problem: Write a program in C++ which simply outputs the string literal &#8220;Hello, World&#8221; t]]></description>
<content:encoded><![CDATA[<h2>Problem:</h2>
<p>Write a program in C++ which simply outputs the string literal &#8220;Hello, World&#8221; to standard output. </p>
<h2>Code:</h2>
<pre class="brush: cpp; title: ; notranslate" title="">
#include &#60;iostream&#62;

int main() {
   std::cout &#60;&#60; &#34;Hello, World&#34; &#60;&#60; std::endl;
   return 0;
}
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[That which doesn't kill you...]]></title>
<link>http://pmatanyc.wordpress.com/2013/05/17/that-which-doesnt-kill-you/</link>
<pubDate>Fri, 17 May 2013 18:57:36 +0000</pubDate>
<dc:creator>Paola Mata</dc:creator>
<guid>http://pmatanyc.wordpress.com/2013/05/17/that-which-doesnt-kill-you/</guid>
<description><![CDATA[Enjoying &#8220;poutine&#8221; in Montreal I&#8217;ve been away from the blog for some time. I kept]]></description>
<content:encoded><![CDATA[Enjoying &#8220;poutine&#8221; in Montreal I&#8217;ve been away from the blog for some time. I kept]]></content:encoded>
</item>
<item>
<title><![CDATA[Practice Room SRM 176 DIV 2, Problem 500 Rep]]></title>
<link>http://topblogcoder.wordpress.com/2013/05/17/practice-room-srm-176-div-2-problem-500-rep/</link>
<pubDate>Fri, 17 May 2013 18:57:21 +0000</pubDate>
<dc:creator>Alethor</dc:creator>
<guid>http://topblogcoder.wordpress.com/2013/05/17/practice-room-srm-176-div-2-problem-500-rep/</guid>
<description><![CDATA[Here a new problem I´ve solved right now! Here i decided to create an array with all the possibiliti]]></description>
<content:encoded><![CDATA[<p>Here a new problem I´ve solved right now!</p>
<p>Here i decided to create an array with all the possibilities and use a counter to go throught them, then with a for loop, check if the first[i] and second[i] are equal, if they are, then put in the result the same, and if not check if the elements in the array are != to first[i] and second[i], then add the other possibilitie to the result. At the end of each iteration of the for loop, increment the counter +3.</p>
<p>Here the <strong>problem statement</strong>:</p>
<p>You are playing a game in which you have to find sets of three cards that share certain characteristics. Each card has some symbols on it. Each symbol is either a circle, a squiggle, or a diamond. Each symbol is either colored blue, red, or green. Each symbol is either solid, striped, or empty. And finally each card has either one, two, or three occurrences of the same symbol. A set is formed by three cards, and each characteristic is either the same on all three cards or different on all three cards.</p>
<p> For example, a card with one solid blue diamond, a card with two solid green diamonds, and a card with three solid red diamonds all form a set. The symbols on each card have the same shape and the same shading, and none of the cards has the same number or the same color. Any two cards will form a set with exactly one other card. You want to know, given two cards, what is the other card that completes the set. Create a class Matching with a method findMatch that takes two string[]s, <b>first</b> and <b>second</b>, representing the characteristics of two cards, and returns a string[] representing the characteristics of the third card.</p>
<p> <b>first</b> and <b>second</b> will both contain exactly four elements. The first element of each will denote the shape of the symbols on the card and will be either &#8220;CIRCLE&#8221;, &#8220;SQUIGGLE&#8221;, or &#8220;DIAMOND&#8221;. The second element will denote the color and will be either &#8220;RED&#8221;, &#8220;BLUE&#8221;, or &#8220;GREEN&#8221;. The third element of each will denote the shading and will be either &#8220;SOLID&#8221;, &#8220;STRIPED&#8221;, or &#8220;EMPTY&#8221;. The fourth element of each will denote the number of symbols, and will be either &#8220;ONE&#8221;, &#8220;TWO&#8221;, or &#8220;THREE&#8221;. The return element should contain exactly four elements, and should follow the same format as the input. </p>
<p>Here <strong>my code</strong>:</p>
<pre>public class Matching
    {
        public string[] findMatch(string[] first, string[] second)
        {
            string[] temp1 = { "DIAMOND", "CIRCLE", "SQUIGGLE", "GREEN", "BLUE", "RED", "SOLID", "EMPTY", "STRIPED", "ONE", "TWO", "THREE" };
            string[] res = new string[4];
            int index = 0;
            for (int i = 0; i &#60; first.Length; i++)
            {
                if (first[i] == second[i])
                    res[i] = first[i];
                else
                {
                    for (int a = index; a &#60; temp1.Length; a++)
                    {
                        if (temp1[a] != first[i] &#38;&#38; temp1[a] != second[i])
                        {
                            res[i] = temp1[a];
                            break;
                        }
                    }
                }
                index += 3;
            }
            return res;
        }
    }</pre>
<p>If you have another approach, please share with me in a comment!</p>
<p>Thank you very much</p>
]]></content:encoded>
</item>

</channel>
</rss>
