Category Archives: math

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):

Leave a comment

Filed under computer science, math, 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

Daily Agendas on Google Docs

I’ve been doing this with a few classes for the past two years, but this year made the move to all: I keep a Google Doc with the day’s agenda for each class. This is useful as a central location from which all of the day’s activities can progress, with links to assignment documents, links to online quizzes, links to videos, and links to resources all embedded in there. In review surveys at the end of each class, this has consistently been a highlight and something they really appreciate. For example: “The links on the agenda and the directions that gave us to do what we had to do”, and “Somenthing that I really liked about this class was the agenda because if by any reason you was absent you just have to go to the online agenda and you can make up from your home.”

Because of these reviews, this year I’m moving to all classes having an online agenda. Combined with the fact that I’m a fan of the website for shortening and choosing your own url, I was laughing with a few of my students this afternoon that today I had my students use 5 different tinyurls for these agendas (and of course have to keep them straight in my head):


[Year 12, Day 2 post]


Leave a comment

Filed under computer science, engineering, math, teaching

Year 12, Day 0

This week teachers headed into school to prepare for next week and students’ return. This will be my twelfth year!

My teaching this year will include more computer science than ever before:

  • AP Computer Science Principles (full year)
  • AP Computer Science A (full year)
  • Foundations of Computer Science  (spring)
  • Computer Integrated Manufacturing (fall)
  • Precalculus independent study (fall, three students, three separate periods)

I’ll also be working with our new engineering teacher and our librarian+new-computer-science-teacher to help them with their lessons, and collaborating with two geometry teachers around standards-based-grading.

Extracurricular activities and competitions:

  • Coding Club (app development, cybersecurity, & more)
  • Women’s Transportation Seminar’s “Transportation You!” Mentoring Program
  • TRAC bridge builder competition
  • CyberPatriot competition
  • STEM Competition
  • possible (in my mind, I want to do each of these this year): Cyber Movie Mondays, Saturday AP & PLTW study groups, Girls Who Code club
  • probably several others…

Ongoing projects that will occupy some of my time this year include:

  • Comp Hydro (teaching hydrology and flooding through computational simulations & modeling, in partnership with the Baltimore Ecosystem Study)
  • MyDesign (engineering design process app and learning management system, in partnership with NSF & the University of Maryland)
  • Internet of Things project to measure air quality and other environmental factors in schools (in partnership with Cool Green Schools, Johns Hopkins University, and Morgan State University)
  • Continuing work toward my Master’s Degree in Computer Science (taking “Artificial Intelligence ” course this semester)
  • Baltimore City Engineering Alliance, a nonprofit 501(c)(3) we created to provide opportunities to Baltimore City students to further their engineering education, and for which I am treasurer

School starts for students on Tuesday, after Labor Day for the first time in my twelve years here teaching in Baltimore. Wish us luck!

Leave a comment

Filed under computer science, engineering, math, teaching

Pythagorean Triple Answers

As a follow-up to yesterday’s post, here are some answers and steps toward figuring out the scarcity (or frequency) of Pythagorean triple days (like yesterday 8/15/17) in a century:

I will mention I did not get the answer right away but needed some prompting (from a math-teacher colleague on Twitter), so I’ll take you through my thought processes.

  1. I have certain primitive Pythagorean triples memorized (like 9/40/41) — perhaps from several years of teaching geometry, or from studying number theory in college where integer (or rational) values for algebraic relations are important (cf. Euclid’s formula for Pythagorean triples, Diophantine Equations, & Fermat’s Last Theorem), or perhaps even a few recalled from taking high school geometry. In my head I tried these, saw several had occurred already in the past (5/12/13), while others were not interpretable as months days and years, like 9/40/41 (since there are max 31 days in a month). To go beyond the primitive triples, I tried multiplying each times 2, times 3, etc. In this way I discovered yet to come this century: 10/24/26 (twice 5/12/13) and 12/16/20 (quadruple 3/4/5).
  2. I thought I had them all, but had forgotten some primitive triples, like 7/24/25! At this point, referring to this list of primitive Pythagorean triples, I tried to systematically enumerate all with a≤12, then go through multiples of those until all values were larger than 12 (and therefore none could fill the month slot). I did this in Excel, color coding as blue dates already past, yellow yet to come, and red invalid date formats:excel1
  3. In creating that chart I did mentally transpose months and dates to see for example, that 12/5/13 could also work as a Pythagorean triple date in addition to 5/12/13. But this only yielded more in the past so I didn’t bother to write them out. My fatal flaw, though, was not permutating with the years also, so I neglected to find two more future dates: 7/25/24 and 10/26/24. After realizing this, I did add more to my Excel chart, going through each permutation that yielded a valid date in rows below the main ones:excel2
  4. I do believe this is now a complete list of past, present, and future Pythagorean triple days, written month/day/year. By my count there will be a total of 28 this century, 23 now past and 5 still in the future. Let me know if I missed any!


By the way, here’s an awesome interactive generator of Pythagorean triples by Vincent Pantaloni (shared on twitter).





Leave a comment

Filed under math, teaching

Happy Pythagorean Triple Day!

Today is 8/15/17 (abbreviating the year to two digits), which are three natural numbers that make up a Pythagorean triple! That is, three numbers that satisfy the equation from the Pythagorean Theorem a2 + b2 = c2 , and therefore make up valid integer side lengths on a right triangle.

Try it! 82 is 64, plus 152 (225), makes 289, which is 172 .

In fact, 8/15/17 is even more special than other Pythagorean triple days like 6/8/10, or 12/9/15, since it is a primitive Pythagorean triple: that is, its numbers share no common factor (e.g. 6/8/10 all share a 2, which if factored out yields the more familiar 3/4/5).


A great question to ponder: how many more Pythagorean triple days will we have this century? (question and image from Chris Smith, on Twitter)



Also, how many already occurred (and perhaps we didn’t even realize it)?


Will post answers to these questions tomorrow…

1 Comment

Filed under math, teaching