Category Archives: computer science

Pi Day 2019

Today was a very pi-saturated day for me (which is wonderful!). After waking up, I took a shower behind a pi shower curtain:

(that’s right, I have a shower curtain filled with the digits of pi, which are colored differently to make the shape of the pi symbol stand out…)

I dressed with a pi day t-shirt as my undershirt, and a pi tie (the same pi tie I wore last year).

On my way into work, I did a few pi day routines:

  1. reciting pi to myself to make sure I still know the digits (I usually falter in the mid 100’s and need to refresh my memory the day before so I’m solid at 200 like I was in high school, then I continue to practice that morning)
  2. buying some pies from the grocery store for my students
  3. decorating my board with pi digits and facts

We had been invited on a field trip to have our students celebrate Pi Day in Annapolis at the Maryland State House Office Building, with legislators, the lieutenant governor, and representatives from other schools and STEM education organizations. So we brought six students and three bins full of projects and things to show off, from our engineering program, our computer science program, and our STEM after-school clubs. We brought a 3D printer, which was a big hit, in constant operation producing little raven figurines which we gave away to visitors to our table (many of them younger children). We brought a laptop with Python and Java programs coded by my students that simulated flipping coins, drew a beautiful geometric flower, merged two photos together (a primitive Photoshop), and an “artificial intelligence” program that interacted with a weather API to obtain the current weather and give advice to humans on what to wear. Also some tablets with student-coded apps, and electronic devices like a robot butterfly, a random-number-generator dice LED board, and a soda-can lamp. There was also a solar-powered car, a hovercraft, and designs and blocks and shapes carved out by students using CNC mill and lathe.

For lunch there was pizza pi(e) and mini dessert pi(e)s, as you can see in the following picture of the students each holding up a slice of pie, a pie, or a pi:

Returning to school for my last period class and our after-school makerspaces club, we celebrated in the traditional way by eating more pie. ūüôā

When I got home, my neighbors invited me over for a pi day and birthday celebration for their kid. So even more pizza pie for dinner, lemon meringue and key lime pies for dessert, and some discussion of pi day trivia at the dinner table, as well as anecdotes of how the neighbors celebrate pi day at their offices. A wonderful time!

Overall, lots of pi and pie from morning ’til night. A great way to celebrate a great day!

Here are some pi-day tidbits of news, information, and links about pi:

  • Today, Google announced that one of their employees, Emma Haruka Iwao, together with the Google Computing Engine, calculated pi out to 31,415,926,535,897 digits (i.e. pi times ten trillion digits, some self-referential humor in their choice of where to stop). This shatters the previous world record of 22 trillion! (sources: BBC, Forbes, 538)
  • Here are some ways NASA uses and celebrates pi.
  • As pi day gets more and more popular, I’ve seen more backlash of pi day skeptics recently (though nothing like the great pi / e wars and debates of my Williams College days, nor the great Pi/Tau Debate of 2011). I am still a pi fan, but here are some other numbers you might enjoy and wish to celebrate as well!
  • Since we handed out 3D-printed ravens as Maryland-themed souvenirs at today’s event, I feel like I need to re-post this link to the renowned retelling of Poe’s “The Raven” which has words of lengths equal to the digits of pi. Poe, E. Near a Raven.
  • In honor of my new neighbor’s birthday, there are some other famous folks who share a birthday with pi day: Many people know about Albert Einstein, but also Waclaw Sierpinski, the Polish mathematician famous for fractals, and also Alexey Pajitnov, the developer of Tetris. (h/t to Michael Lugo for the latter fact).

And finally, a few pi day jokes. Each image is linked to its source:

Hope you all had a wonderful pi day, and continue to celebrate math all year long!

Nick the Pi Guy

Leave a comment

Filed under computer science, engineering, math, teaching

Triangle Spaghetto?

So, this is an interesting question to think about…

If you were to break a piece of spaghetti randomly twice, to yield three smaller pieces, what are the chances that your three pieces would form a triangle?


I encourage you to take some time to think about this before reading my solution.
















I had a little intuition based on the triangle inequality, which says that for any pair of sides of a triangle, their sum must be greater than the third side: a+b>c.

After making that guess, I actually tried to prove this to myself geometrically before moving to try a simulation via computer program, so I guess I’m still a mathematician at heart even though my current teaching load is all computer science courses! ūüôā


The outer triangle, AEF, is the probability space for the spaghetto we’re talking about, assuming (without loss of generality) that the original spaghetto has length 1. The x-axis represents our (random) choice for the first break, which could be any number between 0 and 1 with equal/uniform probability.¬† Let’s call the random number chosen x*. The y-axis then represents our (random) choice for the second break, which is now constrained with an upper bound of 1-x*, based on however long our first broken piece was (thus the hypotenuse of the right triangle, y=1-x). Only two breaks (or, equivalently, random numbers) are needed, 0‚ȧx*‚ȧ1, and 0‚ȧy*‚ȧ1-x*, since the third piece is completely determined by the first two, as 1-x*-y*.

Within our probability space, the bluish-green region in the lower right is out-of-bounds for trianglehood, since an initial break of my first piece x*>0.5 would mean that I’m left with a piece less than 0.5 which still needs to be broken into two, and that means those two pieces could never sum to more than my first piece (the triangle inequality). The magenta region near the top is similarly off-limits, even if my initial break is small enough, if my second break yields a y*>0.5, the first and third pieces could never sum to more than the second. Finally, the yellow region near the bottom represents non-triangles where both the first and second breaks are two short, yielding a combined sum less than 0.5, and therefore a third/final piece greater than 0.5 which would dominate the first two and thus not allow triangularity to flourish from our three pieces of spaghetti.

So the only triangularly-valid region is the center, which is 1/4 the total area of our probability space.

After becoming certain of this answer, I did mock up a quick random number generator function in Python:


While this was indeed closer to 0.25 than any other option in the initial poll, the fact that I ran 10,000,000 trials and got consistently less than 0.2 (and not closer to 0.25) does worry me that I coded one of the assumptions wrong. I’m still 99% certain that 0.25 is the correct answer. But if anyone spots a program error, or a logic error, please let me know!

Leave a comment

Filed under computer science, math

PI DAY 2018!

Happy pi day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Pi Day as a holiday is 30 years old this year¬†(unless someone had been celebrating quietly on 3/14’s before Larry Shaw publicly founded Pi Day at the San Francisco Exploratorium in 1988)!

While last year was a pi day snow day for us, this year the snow has mostly missed us in Maryland, while Boston area folks have had several huge storms in a row, and some of them do have a pi day snow day today!

The day was off to a good start this morning with a beautiful pi day sunrise:

I was up early to buy some pies, as per usual, when I stumbled across a pi-day pie sale! While I’ve seen photos of these before on social media, this is the first time I’ve actually come across one in person on a pi day myself!


I made my chalkboard a little busier than usual, including a few extra pi facts:

I also wore a new pi tie today (some years I’ve worn pi t-shirts). You can’t tell from the photo, but the image/pattern is made up of pi’s digits!

My first period AP CS A (Java / object-oriented programming class, with juniors and seniors) is the only class I did a pi-focused lesson with this year. In my other classes, we took a ten-minute pi and pie break, and talked about pi facts while eating, then back to our regularly-scheduled lesson. But in AP CS A, we coded an infinite series for pi in Java. We used the Leibniz formula, relatively easy to understand and code: 1/1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + 1/13 – …

This actually converges fairly slowly, compared to other infinite series for pi. Here are the results after ten terms, with the terms included on the left, and the running summation on the right of each line:

Here we are after 1000 iterations, just the sums:

And after a million terms, we’re getting pi accurate to five digits:

A million terms took a few minutes to run, so we didn’t dare try ten million, for fear we would break our ancient computers! Nor did we try to break the record of 22 trillion digits of pi, which would need many many times more terms if we were to use this series ūüôā

Also today, in other news, a nationwide walkout against gun violence, which students at my school participated in as well. And I took two students on a field trip; the students had built a custom-engineered bicycle for a kid with a disability last month during National Engineering Week, and today we got to deliver the bike to the kid and his mother. So that was pretty cool.

Anyway, that’s how my day went, hope your pi day was similarly awesome!

Here’s my round-up of a few Pi Links:

And a few really creative pi-related photos, found via Twitter (linked to their sources):

1 Comment

Filed under computer science, math, teaching

CS Ed Week, Part 2

To continue with my post from 12/4, a few more emails for Computer Science Education Week 2017!

Thu 12/7: Hour of Code week almost over!

Hi Patterson peeps,

Just a reminder that we are nearing the end of Computer Science Education Week. I hope you have all had the chance to try out one of the awesome lessons yourself and with your classes (or have plans to do so today or tomorrow!).


I leave you with this:

Fri 12/8: Last push РHour of Code!

As Computer Science Education Week draws to a close this weekend, let me leave you with three resources, two facts, and one reminder:


  1. A new video from in which basketball star Stephen Curry talks about coding and persistence
  2. A video produced last year, called¬†“Computer Science is Changing Everything”, that really hits home that CS is found in every field, from agriculture to medicine to dance
  3. If you’re not able to do a whole hour of code, check out this¬†five-minutes-of-code¬†¬†activity¬†in which you can design your own snowflake and holiday card (with thanks to Mr. Callahan)


  1. CS Education Week was founded in honor of Admiral Grace Hopper, one of the pioneers of computer science, whose birthday is tomorrow 12/9 (if alive, she would be 111 years old tomorrow, which is sort-of a binary age!)
  2. Coding is for everyone, in the same way writing is for everyone, a way “to organize, express, and share ideas in new ways, in a new medium” (okay, maybe that’s an opinion and not a fact, but seriously, check out¬†this interview with Mitch Resnick¬†from MIT, it may change the way you think about coding).
  1. Don’t forget to send me student names and have your students who do the Hour of Code¬†complete the survey!
Happy holidays, and happy coding!
Nick Yates

Finally, here’s a photo of my colleagues and I encouraging everyone to “Code Like a Girl”:


Leave a comment

Filed under computer science, teaching

Computer Science Education Week 2017

Hi all, it’s CS Education Week! Am forming a blog post of the emails I send out to my school to encourage participation in the Hour of Code. Will update this post (or maybe a new one) as I email more.


Thu 11/30 (before CS Ed Week):

Greetings Patterson Family!

Next week is Computer Science Education Week, and we have celebrated this each of the last several years at Patterson by having students do an Hour of Code! Please check out and consider picking one day next week to teach coding in each of your classes.
The Hour of Code is a global movement reaching tens of millions of students in 180+ countries. Anyone, anywhere can organize an Hour of Code event.


There are a variety of activities, including ones that can be done on computer workstations, ones that can be done on students’ call phones / mobile devices, and ones that are “unplugged” using cups or printable manipulatives etc. Depending on your classroom dynamic, you could also work together as a whole class to complete coding exercises on your teacher computer / projector screen. Or, if you’re feeling ambitious, you could try to come up with your own lesson that relates coding to your content area, and teaches problem-solving or algorithmic thinking (e.g. peanut butter and jelly making as clear communication, necessary for ELA/writing classes and also for writing computer code that breaks a process down into multiple steps and communicates them clearly to the computer to run).


FYI – for our ESOL population, many (though not all) of the computer-based coding activities have instructions in multiple languages that can be adjusted at the bottom of the screen.

Please let me know if you plan to do an activity, or if you want to chat about different possibilities. For computer access, I can offer my room for second period (all days next week) or fifth period (except Monday). There may also be laptop carts available on a first-come first-serve basis that you can follow the usual process to reserve. Additionally, I am interested in tracking which activities are used, as well as student names for certificates.
Happy coding!
Nick Yates
Mon 12/4 AM: The Hour of Code is here!

Greetings Patterson Family!

CS Education Week is here, and with it the Hour of Code!

Please consider teaching a coding lesson in one of your classes this week, so that we can help our students become creators of technology rather than merely consumers of technology.

Here are some intro videos to the HoC: (YouTube + download link in case YT is blocked)

Among the¬†activities, there seem to be two new ones for this year¬†that I’ve noticed near the top: Minecraft (three versions, one from each of the past two years, plus a new tutorial for this year) and Google Design-Your-Own-Logo-with-Scratch.

You can also sort the activities by the technology you plan to use (computers, student mobile devices, or unplugged Рno devices), AND nicely by content area (e.g. if you teach Science and want to teach a cross-curricular science+coding lesson):



Please let me know if I can help in any way, whether by consulting with you on which lesson might best fit your class, or having you bring your class down to my room, etc.



Nick Yates and the Academy of Engineering and Technology Team

Mon 12/4 PM: Google Doodle today celebrates 50 years of kids coding!

Hey Patterson people,

The Logo programming language, designed for kids with a turtle that moved around and could draw pictures, was invented 50 years ago! Today’s Google Doodle celebrated that fact. In case you missed it, and want to try it out,¬†here’s a link that will still work after today is over:¬†¬†.¬†It is a cool symbol-based (no words, so should work for students of any language!) HoC-style activity within a Google Doodle, with a rabbit trying to eat some carrots. Check it out!


Celebrating 50 years of Kids Coding #GoogleDoodle
Also, if you’re interested, there is an actual¬†Hour of Code activity¬†based on that original turtle (updated to the Python language), which can be found at¬†
Happy CS Education Week!


Tue 12/5: Hour of Code subject recommendations

If you haven’t started the Hour of Code yet because you don’t have access to a classroom set of computers and aren’t sure what coding has to do with your curriculum, here are my recommendations for unplugged subject-specific activities!

  • Science –¬†Rock Paper Scissors,¬†with connections to biological population modeling¬†(unplugged activity plus presentation on teacher screen)
  • Social Studies – History of Codes and Ciphers (one lesson, plenty more material as well e.g.¬†wikipedia)
  • Art –¬†Algorithmic Doodles¬†(fractals & algorithms)
  • Math –¬†Hexahexaflexagons¬†(geometry, discrete math w/ directed graphs and finite state machines)
  • English / Language Arts –¬†Magical Book Magic¬†(computational thinking and patterns with words)

If any English teachers do have access to a set of computers, the Automatic Homework Excuse Generator looks pretty cool too!

Happy coding,

Nick Yates & the AOET Team

1 Comment

Filed under computer science, teaching

Number Systems

Binary and hexadecimal today in AP CSP:



When I was in elementary school, I was fascinated with number systems. I know I read about some different number systems used by different cultures through history in a book of number history my parents had, and was also inspired by some discussion of binary / ternary / base-4 in The Math Curse. I asked my mom to explain them, and she did.

Somehow (I forget the source, if it was a news article or an “interesting fact” in some book), I got really into the Inupiaq number system, both the symbols and the base-20 place value system for writing them. I remember writing the date in the upper right-hand corners of my papers using Inupiaq numerals each day in Mrs. McCarthy’s 4th grade class (or was it 6th grade? — she was my teacher both those years).

Always lots of fun teaching number systems! One of my favorite topics. ūüôā

#day16 #apcsp #teach180 #180blog

Leave a comment

Filed under computer science, math, teaching

Planning In Code

One of the skills I work with students on in many of my classes is how to plan to code, in a helpful and efficient way. This is true certainly in my computer science classes but also in my Principles of Engineering (POE) and Computer Integrated Manufacturing (CIM) classes as well. Pseudocode, flow charts, process flow diagrams, are all structures and formats I have used before with students, with varying degrees of success.

This year, with Advanced Placement Computer Science A (AP CSA), I definitely plan to use several of the UML diagram formats with Java coding. Certainly class diagrams (like this one I posted last week) fit very well with an object-oriented language like Java. The course I took this summer on the Software Development Process, and especially our group project there, helped me understand several of the UML formats in a deeper way; I can definitely see myself using the Use Case and perhaps Sequence diagrams as well.

Anyway, today I worked with my AP CSA students to develop a few less-formal diagrams on the board: We did some mind mapping together as we brainstormed attributes or variables with values that would apply to weather (for a weather app):


And then we did the beginning of a decision tree:


My engineering students are using a planning table on paper to plan out their G&M-codes they will use to control the CNC milling machine to carve out their initials.

And my AP CS Principles students haven’t gotten deep enough into code yet to use a planning template. We have done some coding using Python as a calculator and to draw pictures (turtle library), and to play interactively against the “intelligent paper”. But most of our time so far has been discussing computing innovations, their impact on society, and working on a research presentation.

After school today, I had students stay for CyberPatriot practice, and it was also the first day of Interactive Mural Lab, led by some folks from MICA, which will help coach some students to creative a computer-programmed, electronics-infused, creative mural on a wall of our school! I’m super-excited to watch their progress over the course of this year, both to see how the mural turns out, and to see what skills and techniques students will learn as a part of this project.

Phew – I’m exhausted just writing about all that! ūüôā¬† Have a good evening.

#day15 #180blog #teach180

Leave a comment

Filed under computer science, teaching