<?xml version="1.0" encoding="UTF-8"?><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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>math Archives | Programming Zen</title>
	<atom:link href="https://programmingzen.com/tag/math/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/tag/math/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Fri, 11 Oct 2019 03:38:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">1397766</site>	<item>
		<title>Exploring Mathematics with Matplotlib and Python</title>
		<link>https://programmingzen.com/exploring-mathematics-with-matplotlib-and-python/</link>
					<comments>https://programmingzen.com/exploring-mathematics-with-matplotlib-and-python/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Sat, 03 Aug 2019 20:36:47 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[exploration]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2097</guid>

					<description><![CDATA[<p>We, humans, are visual creatures. We evolved reasonable abstraction capabilities but we shine when we can visualize the problem at hand. This is why I&#x2019;m a big fan of Data Visualization as a discipline. Data has the answers. Visualization helps us better understand and interpret them. (For a great introduction to the subject, consider taking the Data Visualization course by my colleague Alex Aklson, Ph.D.) Perhaps, above all, I like the exploratory nature of visualizing data. We must be mindful of clustering illusions and type I errors, but it&#x2019;s fun to explore unbridled, feeding our intuition and the part of </p>
<p>The post <a href="https://programmingzen.com/exploring-mathematics-with-matplotlib-and-python/">Exploring Mathematics with Matplotlib and Python</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We, humans, are visual creatures. We evolved reasonable abstraction capabilities but we shine when we can visualize the problem at hand.</p>



<p>This is why I&#8217;m a big fan of Data Visualization as a discipline. Data has the answers. Visualization helps us better understand and interpret them.</p>



<p>(For a great introduction to the subject, consider taking the <a href="https://www.coursera.org/learn/python-for-data-visualization" target="_blank" rel="noreferrer noopener" aria-label="Data Visualization course (opens in a new tab)">Data Visualization course</a> by my colleague Alex Aklson, Ph.D.) </p>



<p>Perhaps, above all, I like the exploratory nature of visualizing data. We must be mindful of <a rel="noreferrer noopener" aria-label="clustering illusions (opens in a new tab)" href="https://en.wikipedia.org/wiki/Apophenia" target="_blank">clustering illusions</a> and type I errors, but it&#8217;s fun to explore unbridled, feeding our intuition and the part of our brain that seeks patterns.</p>



<p>Let&#8217;s consider an example. Take a look at this list of numbers.</p>



<p class="has-background has-pale-cyan-blue-background-color">[21, 71, 41, 35, 41, 83, 48, 62, 26, 40, 46, 90, 50, 23, 11, 86, 95, 4, 50, 25, 93, 19, 67, 10, 27, 38, 78, 6, 71, 15, 11, 13, 10, 89, 3, 52, 98, 65, 97, 17, 64, 25, 33, 78, 28, 25, 85, 68, 2, 72, 63, 50, 9, 2, 52, 61, 62, 73, 89, 77, 10, 95, 5, 85, 46, 89, 70, 47, 20, 51, 6, 4, 51, 44, 79, 24, 63, 55, 99, 92, 29, 63, 16, 78, 15, 6, 91, 85, 8, 71, 23, 63, 67, 28, 44, 86, 83, 98, 57, 91]</p>



<p>Notice anything interesting?</p>



<p>If you look at it hard enough, chances are your brain will come up with something. Don&#8217;t feel bad if it didn&#8217;t as this is just a list of 100 random numbers (technically, pseudo-random numbers).</p>



<p>If we chart these points, we get a representation of this randomness.</p>



<div class="wp-block-image"><figure class="aligncenter"><img fetchpriority="high" decoding="async" width="1600" height="1100" src="https://i2.wp.com/programmingzen.com/wp-content/uploads/2019/08/random-100.png?fit=1024%2C704&amp;ssl=1" alt="100 random draws." class="wp-image-2104" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/random-100.png?w=1600&amp;ssl=1 1600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/random-100.png?resize=300%2C206&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/random-100.png?resize=768%2C528&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/random-100.png?resize=1024%2C704&amp;ssl=1 1024w" sizes="(max-width: 1060px) 100vw, 1060px" /></figure></div>



<p>There is no pattern to be had. Charting these scattered points is not entirely useless, however.</p>



<p>Knowing full well that my brain will try to find a pattern, I let it play and noticed something. Nothing too surprising, but some dots appear to line up. This can easily be seen above y = 40, for example.</p>



<p>Well, big deal, some numbers are randomly repeated. Yes, but&#8230; now, I&#8217;m curious. How often are numbers repeated?</p>



<p>Let&#8217;s chart once more, this time using the frequency of occurrence on the y-axis.</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" width="1600" height="1100" src="https://i2.wp.com/programmingzen.com/wp-content/uploads/2019/08/100.png?fit=1024%2C704&amp;ssl=1" alt="Frequency of random occurrences with N=100." class="wp-image-2105" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100.png?w=1600&amp;ssl=1 1600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100.png?resize=300%2C206&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100.png?resize=768%2C528&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100.png?resize=1024%2C704&amp;ssl=1 1024w" sizes="(max-width: 1060px) 100vw, 1060px" /></figure></div>



<p>This looks a little less random, doesn&#8217;t it? With this set of 100 draws, the range appears to be between 0 (the number wasn&#8217;t drawn) and 4 repetitions (in the case of number 63).</p>



<p>(This conjured some unrelated thoughts about the <a href="https://en.wikipedia.org/wiki/Survivorship_bias" target="_blank" rel="noreferrer noopener" aria-label="survivorship bias (opens in a new tab)">survivorship bias</a>. I humorously imagined the top dots on the chart selling books to the lower dots about how to succeed. But I digress.)</p>



<p>It&#8217;s also visually obvious that there are fewer and fewer numbers as the frequency of repetition goes up. This makes sense. The odds of a number being present at least once are fairly high:</p>



<p style="text-align:center"><img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+P_%7B1%7D+%3D+1+-+%28%5Cfrac%7B99%7D%7B100%7D%29%5E%7B100%7D+%5Capprox+0.6339+%5Capprox+63%5C%25&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;displaystyle P_{1} = 1 - (&#92;frac{99}{100})^{100} &#92;approx 0.6339 &#92;approx 63&#92;%" class="latex" /></p>



<p>While the odds of it being repeated 100 times are virtually zero:</p>



<p style="text-align:center"><img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+P_%7B100%7D+%3D+%5Cfrac%7B1%7D%7B100%5E%7B100%7D%7D+%3D+1%5Ctimes%7B10%7D%5E%7B-200%7D+%5Capprox+0%5C%25&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;displaystyle P_{100} = &#92;frac{1}{100^{100}} = 1&#92;times{10}^{-200} &#92;approx 0&#92;%" class="latex" /></p>



<p>Every other frequency falls in between these two bounds.</p>



<p>Okay, cool, with 100 draws we seem to have quite a few numbers repeating 3 times, with one number even repeating 4 times.</p>



<h2 class="wp-block-heading">A hypothesis emerges</h2>



<p>We can hypothesize that as the number of draws increases, we might see a larger number of maximum repetitions as well. With 100, we comfortably hit 3 repetitions with several numbers, and we even had a 4. What happens with 1000, 10,000, 100,000 draws?</p>



<p>It feels like the odds of a number appearing even more frequently by chance should go up.</p>



<p>In other words, the maximum number of repetitions, as a function of the number of draws, should diverge. Very slowly, mind you, but it should diverge.</p>



<p>Hmm, slowly diverge. Logarithmically, perhaps? Just a hunch, but let&#8217;s throw caution to the wind, and hazard an even stronger hypothesis.</p>



<p>With n=100, observation leads us to a fairly safe guess. Namely, it&#8217;s very likely that at least one number will repeat at least 3 times. 3, in our case, happens to be <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 1" class="latex" />.</p>



<p>I bet the odds aren&#8217;t too bad for <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 2" class="latex" /> either, but <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 1" class="latex" /> seems extremely likely.</p>



<p>So our guess/hypothesis becomes:</p>



<p class="has-background has-pale-cyan-blue-background-color">Given n integers randomly selected from 1 to n, there is a high probability that at least one number will be repeated at least log n + 1 times.</p>



<p>This would imply:</p>



<table class="wp-block-table aligncenter has-fixed-layout"><tbody><tr><td>n</td><td>Repetitions</td></tr><tr><td>1000</td><td>4</td></tr><tr><td>10,000</td><td>5</td></tr><tr><td>100,000</td><td>6</td></tr></tbody></table>



<p>Let&#8217;s fire up good ol&#8217; Python and see where we land.</p>



<p>When I ran the code (shown at the end) for n = 1000 I got the following chart.</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" width="1600" height="1100" src="https://i1.wp.com/programmingzen.com/wp-content/uploads/2019/08/1000.png?fit=1024%2C704&amp;ssl=1" alt="Frequency of random occurrences with N=1000.
" class="wp-image-2122" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/1000.png?w=1600&amp;ssl=1 1600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/1000.png?resize=300%2C206&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/1000.png?resize=768%2C528&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/1000.png?resize=1024%2C704&amp;ssl=1 1024w" sizes="(max-width: 1060px) 100vw, 1060px" /></figure></div>



<p>Look at all those points on y = 4. Even <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+2+%3D+5&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 2 = 5" class="latex" /> is holding up. Methinks, we are onto something.</p>



<p>Let&#8217;s try n = 10,000.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="1600" height="1100" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/10000.png?fit=1024%2C704&amp;ssl=1" alt="Frequency of random occurrences with N=10,000." class="wp-image-2123" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/10000.png?w=1600&amp;ssl=1 1600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/10000.png?resize=300%2C206&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/10000.png?resize=768%2C528&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/10000.png?resize=1024%2C704&amp;ssl=1 1024w" sizes="auto, (max-width: 1060px) 100vw, 1060px" /></figure></div>



<p>Yup. We expected some numbers to be repeated 5 times, and we got quite a few of those.</p>



<p>Okay, time to bring out the big guns. n=100,000.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="1600" height="1100" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100_000.png?fit=1024%2C704&amp;ssl=1" alt="Frequency of random occurrences with N=100,000." class="wp-image-2124" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100_000.png?w=1600&amp;ssl=1 1600w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100_000.png?resize=300%2C206&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100_000.png?resize=768%2C528&amp;ssl=1 768w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2019/08/100_000.png?resize=1024%2C704&amp;ssl=1 1024w" sizes="auto, (max-width: 1060px) 100vw, 1060px" /></figure></div>



<p>It looks like it still holds. There is a multitude of numbers with 6 repetitions.</p>



<h2 class="wp-block-heading">So what</h2>



<p>OK, so we started off with random data and through visualization and a bit of intuition, we came up with a pretty neat (if conservative) rule about how often numbers repeat by chance. Along with some room to refine our guess and experiment further.</p>



<p>This is the essence of science. You observe phenomena, formulate a hypothesis, and then try to prove or disprove it through experimentation.</p>



<p>Now, before the rigorous mathematicians among my readers have a conniption, all this doesn&#8217;t prove the hypothesis above. Of course.</p>



<p>What does highly likely even mean in this context? Is it 90%, or 99.999% How does it vary as n varies? You&#8217;ll want to analytically verify this and calculate what the actual odds for the occurrence of at least <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 1" class="latex" /> and <img decoding="async" src="https://s0.wp.com/latex.php?latex=%5Clog%7Bn%7D+%2B+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="&#92;log{n} + 2" class="latex" /> repetitions are.</p>



<p>I have not had the time to take this further step (the solution is likely not as trivial as it first looks). At the risk of enraging you with a flashback from your college days, I&#8217;m afraid I&#8217;ll have to leave this as an exercise for the reader. 😉</p>



<p>But this fun exploration is what got us to the hypothesis and these follow up questions in the first place. Historically, people have often figured out some mathematical relation or hint of it before they could rigorously prove it or had the exact answer.</p>



<p>The Babylonians come to mind, as they might have figured out the Pythagorean Theorem before they had a rigorous proof:</p>



<blockquote style="text-align:left" class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>The famous and controversial Plimpton 322 clay tablet, believed to date from around 1800 BCE, suggests that the Babylonians may well have known the secret of right-angled triangles (that the square of the hypotenuse equals the sum of the square of the other two sides) many centuries before the&nbsp;Greek&nbsp;Pythagoras. The tablet appears to list 15 perfect Pythagorean triangles with whole number sides, although some claim that they were merely academic exercises, and not deliberate manifestations of Pythagorean triples.</p><cite>&#8212; <a rel="noreferrer noopener" aria-label="Luke Mastin (opens in a new tab)" href="https://www.storyofmathematics.com/sumerian.html" target="_blank">Luke Mastin</a></cite></blockquote>



<p>Computer simulation and data visualization have just opened us up to a world of mathematical exploration not previously accessible to any human.</p>



<h2 class="wp-block-heading">Plotting in Python with Matplotlib</h2>



<p>If all the math above isn&#8217;t very interesting to you, the Python 3 code I used to plot the charts may be of greater interest.</p>



<p>This is the code in its entirety.</p>



<pre class="wp-block-code"><code>import matplotlib.pyplot as plt
import random

MAX_NUM = 1000

x_values = range(1, MAX_NUM + 1)
values = [random.randint(1, MAX_NUM) for x in x_values]
y_values = [values.count(x) for x in x_values]

plt.style.use("seaborn")
fig, ax = plt.subplots()
ax.scatter(x_values, y_values, s=10)

ax.set_title(f"Random Number Occurrences (N = {MAX_NUM})", fontsize=18)
ax.set_xlabel("Number", fontsize=14)
ax.set_ylabel("Occurrences", fontsize=14)

ax.tick_params(axis="both", which="major", labelsize=14)

plt.show()</code></pre>



<p>Let&#8217;s break it down. We start off by importing <code>pyplot</code> from <code>matplotlib</code> and <code>random</code> since we&#8217;ll be generating pseudo-random numbers.</p>



<p>In truth, we could use <code>secrets</code> for better randomness, but it&#8217;s overkill here and the results are unaffected.</p>



<pre class="wp-block-code"><code>
import matplotlib.pyplot as plt
import random</code></pre>



<p><br>We then set our input size (<code>MAX_NUM</code>), generate that number of random values (<code>values</code>) and aggregate their frequency in <code>y_values</code>.</p>



<pre class="wp-block-code"><code>MAX_NUM = 1000

x_values = range(1, MAX_NUM + 1)
values = [random.randint(1, MAX_NUM) for x in x_values]
y_values = [values.count(x) for x in x_values]</code></pre>



<p><br>Here we set some styling for the chart so that it looks a bit better. We pick the <code>seaborn</code> style, set the thickness of the dots (10 made them fairly visible), and set the labels for the axes.</p>



<pre class="wp-block-code"><code>plt.style.use("seaborn")
fig, ax = plt.subplots()
ax.scatter(x_values, y_values, s=10)

ax.set_title(f"Random Number Occurrences (N = {MAX_NUM})", fontsize=18)
ax.set_xlabel("Number", fontsize=14)
ax.set_ylabel("Occurrences", fontsize=14)

ax.tick_params(axis="both", which="major", labelsize=14)</code></pre>



<p>Finally, we show the graph.</p>



<pre class="wp-block-code"><code>plt.show()</code></pre>



<p>Let me know if you enjoy this type of exploration and I might create a few more posts like this. Or conversely, feel free to tell me why I&#8217;m wrong about everything, in the comments below. 🙂</p>



<p><em>Special thanks to John McGowan of <a href="http://www.mathematical-software.com/" target="_blank" rel="noreferrer noopener" aria-label="Mathematical Sofware (opens in a new tab)">Mathematical Sofware</a>. I&#8217;m immensely grateful for his comments on an earlier draft of the article, although any errors remain my own.</em></p>
<p>The post <a href="https://programmingzen.com/exploring-mathematics-with-matplotlib-and-python/">Exploring Mathematics with Matplotlib and Python</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/exploring-mathematics-with-matplotlib-and-python/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2097</post-id>	</item>
		<item>
		<title>Learn New Programming Languages with Project Euler</title>
		<link>https://programmingzen.com/learn-new-programming-languages-with-project-euler/</link>
					<comments>https://programmingzen.com/learn-new-programming-languages-with-project-euler/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Tue, 02 Dec 2014 16:09:05 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[beginners]]></category>
		<category><![CDATA[exercises]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[project-euler]]></category>
		<guid isPermaLink="false">http://programmingzen.com/?p=1573</guid>

					<description><![CDATA[<p>Lately I&#x2019;ve been thinking a lot about beginners and the very understandable struggle to grasp programming that many of them face. This post is mostly aimed at those who currently find themselves in this position. When it comes to creating, there is no substitute for hands-on experience and the same rings true for programming as well. If you can spend three months reading a 1,000 page reference book on a given programming language, you&#x2019;ll almost certainly walk away with some theoretical knowledge. Useful, but not very practical on its own. You&#x2019;ll get the big picture, no doubt, but you won&#x2019;t </p>
<p>The post <a href="https://programmingzen.com/learn-new-programming-languages-with-project-euler/">Learn New Programming Languages with Project Euler</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Lately I’ve been thinking a lot about beginners and the very understandable struggle to grasp programming that many of them face. This post is mostly aimed at those who currently find themselves in this position.</p>
<p>When it comes to creating, there is no substitute for hands-on experience and the same rings true for programming as well.</p>
<p>If you can spend three months reading a 1,000 page reference book on a given programming language, you’ll almost certainly walk away with some theoretical knowledge. Useful, but not very practical on its own. You’ll get the big picture, no doubt, but you won’t be productive or have much confidence in your newfound knowledge until you actually start writing code.</p>
<p>To me this is akin to reading a large DYI book cover to cover. I won’t be an expert on mending a fence, turning a table leg on lathe, or putting up storm drains simply because I know how such things are done in theory. It’s possible, nay, likely that when the first problem arises, I won’t know how to handle it, save for employing common sense. I’ll have to figure things out, try, make mistakes, and (hopefully) ultimately fix them. It is in this struggle that real skill is developed, honed, and ultimately mastered.</p>
<p>For that reason, I’m a huge fan of seeing beginners get their hands dirty. To this day even, when I’m learning a new programming language or framework, I like to solve practical problems as a way to quickly get acquainted with the ins and outs of said language.</p>
<p>Being passionate about mathematics, my go-to place when I’m learning a new programming language is <a href="https://projecteuler.net">Project Euler</a>. <a id="fnref:1" class="footnote" title="see footnote" href="#fn:1">[1]</a></p>
<div style="text-align: center;">
<p><div id="attachment_1574" style="width: 310px" class="wp-caption aligncenter"><a href="https://i0.wp.com/programmingzen.com/wp-content/uploads/2014/12/project-euler.png?ssl=1" target="_blank"><img data-recalc-dims="1" loading="lazy" decoding="async" aria-describedby="caption-attachment-1574" class="wp-image-1574 size-medium" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2014/12/project-euler-300x257.png?resize=300%2C257&#038;ssl=1" alt="Project Euler" width="300" height="257" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2014/12/project-euler.png?resize=300%2C257&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2014/12/project-euler.png?resize=1024%2C877&amp;ssl=1 1024w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2014/12/project-euler.png?w=1066&amp;ssl=1 1066w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-1574" class="wp-caption-text">Click for a larger image</p></div></p>
</div>
<p>I like the approach that it presents for for several reasons:</p>
<ul>
<li>The self-contained problems go from extremely obvious to fairly hard. The progression is gradual.</li>
<li>In the process of solving problems, you will, out of necessity, end up learning about numbers, string manipulation, files, conditionals, functions, classes, etc. All of the basics that you should master in order to get started on real projects will be exercised to some degree.</li>
<li>The emphasis is on getting the result, but many problems will not be solvable with naive algorithms, particularly when using scripting languages like Ruby and Python. This is an opportunity to learn more about algorithms (if you are a beginner) or more about optimizing code in a given language (if you are learning that language, but are otherwise an experienced programmer).</li>
<li>You can look at other people’s solutions, which are often posted in a forum that’s accessible to those who have solved the problem themselves. You’ll learn about algorithms, more elegant ways to accomplish the same result, and even discover new languages you haven’t heard of before.</li>
<li>There is an element of gamification. It’s fun to see yourself go up in the leaderboard as you solve more problems.</li>
</ul>
<p>The only downside is that it’s quite math heavy and that can scare away some beginners. If this doesn’t put you off tough, I highly recommend giving it a shot. <a id="fnref:2" class="footnote" title="see footnote" href="#fn:2">[2]</a> Be forewarned though, it can be rather addictive. 🙂</p>
<p><strong>UPDATE</strong>: Follow up post about alternative<a href="https://programmingzen.com/2014/12/04/10-programming-challenges-sites/"> programming challenges sites</a>.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">They got hacked at some point, so I no longer have my existing account. I created a brand new one while writing this post. <a class="reversefootnote" style="text-decoration: none;" title="return to article" href="#fnref:1">^</a></li>
<li id="fn:2">Of course, Project Euler isn’t exactly unknown at this point. So if you’re an existing programmer, your reply to this might be “duh!”. <a class="reversefootnote" style="text-decoration: none;" title="return to article" href="#fnref:2">^</a></li>
</ol>
</div>
<p>The post <a href="https://programmingzen.com/learn-new-programming-languages-with-project-euler/">Learn New Programming Languages with Project Euler</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/learn-new-programming-languages-with-project-euler/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1573</post-id>	</item>
	</channel>
</rss>
