<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Teaching on Nicola Iarocci</title>
    <link>https://nicolaiarocci.com/tags/teaching/</link>
    <description>Recent content in Teaching on Nicola Iarocci</description>
    <generator>Hugo -- 0.143.1</generator>
    <language>en</language>
    <copyright>Produced / Written / Maintained by Nicola Iarocci since 2010</copyright>
    <lastBuildDate>Mon, 05 Apr 2021 07:05:25 +0100</lastBuildDate>
    <atom:link href="https://nicolaiarocci.com/tags/teaching/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>School assignments that count: simulating the COVID outbreak with the C language</title>
      <link>https://nicolaiarocci.com/school-assignments-that-count-simulating-the-covid-outbreak-with-the-c-language/</link>
      <pubDate>Mon, 05 Apr 2021 07:05:25 +0100</pubDate>
      <guid>https://nicolaiarocci.com/school-assignments-that-count-simulating-the-covid-outbreak-with-the-c-language/</guid>
      <description>&lt;p&gt;Giulia got an exciting assignment from her teacher:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a C program that simulates (a simplified version of) COVID outbreak
spreading across a population of 200 people. When a healthy person comes into
contact with a sick person, the healthy person becomes ill, too. After some
time, a sick person will recover. A recovered person cannot infect a healthy
person nor become sick again after coming in contact with a sick person.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Giulia got an exciting assignment from her teacher:</p>
<blockquote>
<p>Write a C program that simulates (a simplified version of) COVID outbreak
spreading across a population of 200 people. When a healthy person comes into
contact with a sick person, the healthy person becomes ill, too. After some
time, a sick person will recover. A recovered person cannot infect a healthy
person nor become sick again after coming in contact with a sick person.</p></blockquote>
<p>In more prosaic terms: the world comprises a 30*50 cell grid. Of these, 200
cells are randomly selected to be alive. Throughout the simulation, each of
these cells can be in one of the following three states: healthy, sick, or
recovered. If a cell is ill, at the next cycle, all neighbouring cells will
also be diseased. A cell stays sick for 14 cycles. At cycle 15, it is healed.
The simulation ends when all 200 cells are either recovered or healthy.</p>
<p>Giulia&rsquo;s implementation was fine, but a couple of subtle bugs prevented it from
succeeding, and that&rsquo;s how I got involved. In general, she doesn&rsquo;t ask for
help, nor do I ask her about her progress. If she reaches out to me, it&rsquo;s only
for serious trouble, and when that happens, I enjoy working with her. Besides,
while I do a lot C# these days, I don&rsquo;t do C since aeons ago, so it&rsquo;s great to
get back to it every once in a while.</p>
<p><img alt="first cyckle" loading="lazy" src="/images/covid-sim-prima-esecuzione.png">
Above, the healthy population inhabiting its 1500-cells world, right before the outbreak.</p>
<p><img alt="intermediate" loading="lazy" src="/images/covid-sim-esecuzione-intermedia.png">
Halfway through the simulation, 86 cells are healthy, 46 are sick, and 68 are
healed.</p>
<p><img alt="final cycle" loading="lazy" src="/images/covid-sim-ultima-esecuzione.png">
End of the simulation. It doesn&rsquo;t matter how many times you run it; the number
of people who were never infected is stunningly low by the end. Moreover,
a simulation like this one, albeit simplified, reveals how dramatically an epidemic
can spread if not contained with social distancing.</p>
<p>I was pleasantly surprised by this assignment. Here we have a teacher who
doesn&rsquo;t constraint herself to the standard, well-established routine. Instead,
she keeps her students engaged and challenges them. At the same time, she takes
the chance to educate them on the current sanitary emergency. Giulia tells me
that her teacher was inspired by a March 2020 Washington Post article: <em><a href="https://www.washingtonpost.com/graphics/2020/world/corona-simulator/">Why
outbreaks like coronavirus spread exponentially, and how to &ldquo;flatten the
curve.&rdquo;</a></em> That&rsquo;s excellent work. It includes several animated simulations,
Giulia&rsquo;s assignment being one of them.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
